1 /****************************************************************************
5 Copyright (C) 1999-2001 Lubos Lunak <l.lunak@kde.org>
7 Distributed under the terms of the GNU General Public License version 2.
9 ****************************************************************************/
14 #include <sys/types.h>
18 #include <Qt3Support/Q3PtrList>
19 #include <QtGui/QWidgetList>
21 #include <netwm_def.h>
23 #include "khotkeysglobal.h"
30 const int SUPPORTED_WINDOW_TYPES_MASK
= NET::NormalMask
| NET::DesktopMask
| NET::DockMask
31 | NET::ToolbarMask
| NET::MenuMask
| NET::DialogMask
| NET::OverrideMask
| NET::TopMenuMask
32 | NET::UtilityMask
| NET::SplashMask
;
35 /*class ActionDataBase;*/
37 class KDE_EXPORT Windows
42 Windows( bool enable_signals_P
, QObject
* parent_P
);
44 QString
get_window_class( WId id_P
);
45 QString
get_window_role( WId id_P
);
47 void set_action_window( WId window
);
49 WId
find_window( const Windowdef_list
* window_P
);
50 static WId
window_at_position( int x
, int y
);
51 static void activate_window( WId id_P
);
53 void window_added( WId window_P
);
54 void window_removed( WId window_P
);
55 void active_window_changed( WId window_P
);
56 void window_changed( WId window_P
);
57 void window_changed( WId window_P
, unsigned int flags_P
);
59 void window_added_slot( WId window_P
);
60 void window_removed_slot( WId window_P
);
61 void active_window_changed_slot( WId window_P
);
62 void window_changed_slot( WId window_P
);
63 void window_changed_slot( WId window_P
, unsigned int flags_P
);
69 struct KDE_EXPORT Window_data
71 Window_data( WId id_P
);
72 QString title
; // _NET_WM_NAME or WM_NAME
73 QString role
; // WM_WINDOW_ROLE
74 QString wclass
; // WM_CLASS
78 class KDE_EXPORT Windowdef
80 Q_DISABLE_COPY( Windowdef
)
83 Windowdef( const QString
& comment_P
);
84 Windowdef( KConfigGroup
& cfg_P
);
86 const QString
& comment() const;
87 virtual bool match( const Window_data
& window_P
) = 0;
88 static Windowdef
* create_cfg_read( KConfigGroup
& cfg_P
/*, ActionDataBase* data_P*/ );
89 virtual void cfg_write( KConfigGroup
& cfg_P
) const = 0;
90 virtual Windowdef
* copy( /*ActionDataBase* data_P*/ ) const = 0;
91 virtual const QString
description() const = 0;
96 class KDE_EXPORT Windowdef_list
97 : public Q3PtrList
< Windowdef
>
99 Q_DISABLE_COPY( Windowdef_list
)
102 Windowdef_list( const QString
& comment_P
);
103 Windowdef_list( KConfigGroup
& cfg_P
/*, ActionDataBase* data_P*/ );
104 void cfg_write( KConfigGroup
& cfg_P
) const;
105 bool match( const Window_data
& window_P
) const;
106 Windowdef_list
* copy( /*ActionDataBase* data_P*/ ) const;
107 typedef Q3PtrListIterator
< Windowdef
> Iterator
;
108 const QString
& comment() const;
113 class KDE_EXPORT Windowdef_simple
116 typedef Windowdef base
;
130 WINDOW_TYPE_NORMAL
= ( 1 << NET::Normal
),
131 WINDOW_TYPE_DESKTOP
= ( 1 << NET::Desktop
),
132 WINDOW_TYPE_DOCK
= ( 1 << NET::Dock
),
133 // WINDOW_TYPE_TOOL = ( 1 << NET::Tool ),
134 // WINDOW_TYPE_MENU = ( 1 << NET::Menu ),
135 WINDOW_TYPE_DIALOG
= ( 1 << NET::Dialog
)
137 Windowdef_simple( const QString
& comment_P
, const QString
& title_P
,
138 substr_type_t title_type_P
, const QString
& wclass_P
, substr_type_t wclass_type_P
,
139 const QString
& role_P
, substr_type_t role_type_P
, int window_types_P
);
140 Windowdef_simple( KConfigGroup
& cfg_P
);
141 virtual bool match( const Window_data
& window_P
);
142 virtual void cfg_write( KConfigGroup
& cfg_P
) const;
143 const QString
& title() const;
144 substr_type_t
title_match_type() const;
145 const QString
& wclass() const;
146 substr_type_t
wclass_match_type() const;
147 const QString
& role() const;
148 substr_type_t
role_match_type() const;
149 int window_types() const;
150 bool type_match( window_type_t type_P
) const;
151 bool type_match( NET::WindowType type_P
) const;
152 virtual Windowdef
* copy( /*ActionDataBase* data_P*/ ) const;
153 virtual const QString
description() const;
155 bool is_substr_match( const QString
& str1_P
, const QString
& str2_P
,
156 substr_type_t type_P
);
159 substr_type_t title_type
;
161 substr_type_t wclass_type
;
163 substr_type_t role_type
;
167 //***************************************************************************
169 //***************************************************************************
174 Windowdef::Windowdef( const QString
& comment_P
)
175 : _comment( comment_P
)
180 const QString
& Windowdef::comment() const
186 Windowdef::~Windowdef()
193 Windowdef_list::Windowdef_list( const QString
& comment_P
)
194 : Q3PtrList
< Windowdef
>(), _comment( comment_P
)
196 setAutoDelete( true );
200 const QString
& Windowdef_list::comment() const
208 const QString
& Windowdef_simple::title() const
214 Windowdef_simple::substr_type_t
Windowdef_simple::title_match_type() const
220 const QString
& Windowdef_simple::wclass() const
226 Windowdef_simple::substr_type_t
Windowdef_simple::wclass_match_type() const
232 const QString
& Windowdef_simple::role() const
238 Windowdef_simple::substr_type_t
Windowdef_simple::role_match_type() const
244 int Windowdef_simple::window_types() const
246 return _window_types
;
250 bool Windowdef_simple::type_match( window_type_t type_P
) const
252 return window_types() & type_P
;
256 bool Windowdef_simple::type_match( NET::WindowType type_P
) const
258 return ( window_types() & ( 1 << type_P
))
259 || ( type_P
== NET::Unknown
&& ( window_types() & WINDOW_TYPE_NORMAL
));
260 // CHECKME HACK haaaack !
263 } // namespace KHotKeys