1
/*****************************************************************
3
Copyright (c) 2002 Siegfried Nijssen <snijssen@liacs.nl>
4
Copyright (c) 2003 Lubos Lunak <l.lunak@suse.cz>
6
Permission is hereby granted, free of charge, to any person obtaining a copy
7
of this software and associated documentation files (the "Software"), to deal
8
in the Software without restriction, including without limitation the rights
9
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
copies of the Software, and to permit persons to whom the Software is
11
furnished to do so, subject to the following conditions:
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
******************************************************************/
25
#ifndef _MENUAPPLET_H_
26
#define _MENUAPPLET_H_
30
#include <qvaluelist.h>
34
#include <kpanelapplet.h>
35
#include <kmanagerselection.h>
37
#include <dcopobject.h>
38
#include <dcopclient.h>
40
#include <karrowbutton.h>
44
namespace KickerMenuApplet
50
* @short A central menu bar
52
* @description All status change, such as when an window is activated,
53
* a new window popped up, etc, is received via @ref KWin::WindowInfo and @ref
54
* NETWinInfo. Status changes for X selections are done via KSelectionWatcher.
56
* How it works in broad terms: KickerMenuApplet gets notified as soon a window
57
* changes(a new pops up etc.) and accordingly updates the list @ref menus,
58
* which contains all known menus. When a new window gains focus, it looks up the
59
* correct MenuEmbed in @ref menus, and then switches to that one.
61
* The documentation is a bit rusty -- read it with a critical eye.
63
* @author Siegfried Nijssen <snijssen@liacs.nl>
64
* @author Lubos Lunak <l.lunak@suse.cz>
67
class Applet : public KPanelApplet, public DCOPObject
75
* Called by the Kicker configuration(KCM). Does in turn call
81
Applet( const QString& configFile, QWidget *parent );
83
virtual int widthForHeight( int height ) const;
84
virtual int heightForWidth( int width ) const;
87
* Looks up @param embed in @ref menus, and removes it.
89
void menuLost( MenuEmbed* embed );
90
void updateMenuGeometry( MenuEmbed* embed );
95
virtual void paletteChange(const QPalette& );
96
virtual void positionChange( Position p );
97
virtual void moveEvent(QMoveEvent *);
102
* Called each time a window is added. When the selection is
103
* initially claimed, it is called for every window. It does the big
104
* work, and does the embedding with MenuEmbed.
106
void windowAdded( WId w );
109
* Finds @p w's menubar in @see menus, and then activates it.
111
* @param w the activated window.
113
void activeWindowChanged( WId w );
116
* Called when the selection(selection_atom) is lost. Deletes the
117
* embedded menus, and starts listening for the selection again.
120
void lostSelection();
123
* Reads whether a central menu bar should be used or not, basically.
126
void claimSelection();
131
* Returns true if the selection is Not owned. That is, the menu applet
132
* isn't "running" and is listening for the selection to be released.
134
bool isDisabled() const;
136
WId tryTransientFor( WId w );
139
* Does some sanity checks, and then sets active_menu to @param embed.
141
void activateMenu( MenuEmbed* embed );
144
* Creates msg_type_atom and selection_atom, and returns the latter.
146
static Atom makeSelectionAtom();
147
void updateTopEdgeOffset();
151
* List of all known menus.
153
QValueList< MenuEmbed* > menus;
156
* A pointer to the current active menu, which is member
159
MenuEmbed* active_menu;
161
KSelectionOwner* selection;
164
* Only the messenger. Dispatches signals to claimSelection().
166
KSelectionWatcher* selection_watcher;
169
* Whether the Desktop menu should be used, when a window
170
* with no menu is used.
173
DCOPClient dcopclient;
176
* The distance to the top of the screen.
183
* @author Siegfried Nijssen <snijssen@liacs.nl>
184
* @author Lubos Lunak <l.lunak@suse.cz>
194
* Default constructor
196
* @param mainwindow window ID for the window to be plugged
197
* @param desktop true if @p mainwindow is the desktop
199
MenuEmbed( WId mainwindow, bool desktop,
200
QWidget* parent = NULL, const char* name = NULL );
202
void setBackground();
205
* @returns the window ID for the handled window.
207
WId mainWindow() const;
211
bool isDesktopMenu() const;
212
virtual void setMinimumSize( int w, int h );
213
void setMinimumSize( const QSize& s ) { setMinimumSize( s.width(), s.height()); }
218
* When @p w is None, that is the embedded window was lost, it calls
219
* menuLost() such that the this is deleted from @ref menus list.
221
virtual void windowChanged( WId w );
223
virtual bool x11Event( XEvent* ev );
227
void sendSyntheticConfigureNotifyEvent();
231
* If the window is the desktop window.
237
bool Applet::isDisabled() const
239
assert( ( selection == NULL && selection_watcher != NULL )
240
|| ( selection != NULL && selection_watcher == NULL ));
241
return selection == NULL;
245
WId MenuEmbed::mainWindow() const
251
bool MenuEmbed::isDesktopMenu() const