kwin/workspace.h

349 lines
7.4 KiB
C
Raw Normal View History

/*****************************************************************
kwin - the KDE window manager
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
******************************************************************/
#ifndef WORKSPACE_H
#define WORKSPACE_H
#include <qwidget.h>
#include <qapplication.h>
#include <qpopupmenu.h>
#include <qguardedptr.h>
#include <qvaluelist.h>
#include <qlist.h>
#include "options.h"
#include "plugins.h"
#include "KWinInterface.h"
#include <X11/Xlib.h>
class Client;
class TabBox;
class KConfig;
class KGlobalAccel;
class RootInfo;
typedef QValueList<Client*> ClientList;
class SystemTrayWindow
{
public:
SystemTrayWindow()
: win(0),winFor(0)
{}
SystemTrayWindow( WId w )
: win(w),winFor(0)
{}
SystemTrayWindow( WId w, WId wf )
: win(w),winFor(wf)
{}
bool operator==( const SystemTrayWindow& other )
{ return win == other.win; }
WId win;
WId winFor;
};
typedef QValueList<SystemTrayWindow> SystemTrayWindowList;
struct SessionInfo
{
QCString sessionId;
QCString windowRole;
int x;
int y;
int width;
int height;
int desktop;
bool iconified;
bool sticky;
};
class Shape {
public:
static bool hasShape( WId w);
static int shapeEvent();
};
class Motif {
public:
static bool noBorder( WId w );
};
class Workspace : public QObject, virtual public KWinInterface
{
Q_OBJECT
public:
Workspace( bool restore = FALSE );
virtual ~Workspace();
virtual bool workspaceEvent( XEvent * );
bool hasClient(Client *);
Client* findClient( WId w ) const;
QRect geometry() const;
QRect clientArea();
bool destroyClient( Client* );
void killWindowAtPosition(int x, int y);
WId rootWin() const;
/**
* Returns the active client, i.e. the client that has the focus (or None
* if no client has the focus)
*/
Client* activeClient() const;
void setActiveClient( Client* );
void activateClient( Client* );
void requestFocus( Client* c);
void setFocusChangeEnabled(bool b) { focus_change = b; }
bool focusChangeEnabled() { return focus_change; }
void doPlacement( Client* c );
QPoint adjustClientPosition( Client* c, QPoint pos );
void raiseClient( Client* c );
void lowerClient( Client* c, bool dropFocus=true );
void clientHidden( Client* );
/**
* Returns the current virtual desktop of this workspace
*/
int currentDesktop() const;
/**
* Returns the number of virtual desktops of this workspace
*/
int numberOfDesktops() const;
void setNumberOfDesktops( int n );
QWidget* desktopWidget();
void grabKey(KeySym keysym, unsigned int mod);
Client* nextClient(Client*) const;
Client* previousClient(Client*) const;
Client* nextStaticClient(Client*) const;
Client* previousStaticClient(Client*) const;
/**
* Returns the list of clients sorted in stacking order, with topmost client
* at the last position
*/
const ClientList& stackingOrder() const;
focus policies and alt-tab style: /*! Different focus policies: <ul> <li>ClickToFocus - Clicking into a window activates it. This is also the default. <li>FocusFollowsMouse - Moving the mouse pointer actively onto a normal window activates it. For convenience, the desktop and windows on the dock are excluded. They require clicking. <li>FocusUnderMouse - The window that happens to be under the mouse pointer becomes active. The invariant is: no window can have focus that is not under the mouse. This also means that Alt-Tab won't work properly and popup dialogs are usually unsable with the keyboard. Note that the desktop and windows on the dock are excluded for convenience. They get focus only when clicking on it. <li>FocusStrictlyUnderMouse - this is even worse than FocusUnderMouse. Only the window under the mouse pointer is active. If the mouse points nowhere, nothing has the focus. If the mouse points onto the desktop, the desktop has focus. The same holds for windows on the dock. Note that FocusUnderMouse and FocusStrictlyUnderMouse are not particulary useful. They are only provided for old-fashined die-hard UNIX people ;-) </ul> */ FocusPolicy=ClickToFocus | FocusFollowsMouse | FocusUnderMouse | FocusStrictlyUnderMouse /** Different Alt-Tab-Styles: <ul> <li> KDE - the recommended KDE style. Alt-Tab opens a nice icon box that makes it easy to select the window you want to tab to. The order automatically adjusts to the most recently used windows. Note that KDE style does not work with the FocusUnderMouse and FocusStrictlyUnderMouse focus policies. Choose ClickToFocus or FocusFollowsMouse instead. <li> CDE - the old-fashion CDE style. Alt-Tab cycles between the windows in static order. The current window gets raised, the previous window gets lowered. </ul> */ AltTabStyle=KDE | CDE svn path=/trunk/kdebase/kwin/; revision=54010
2000-06-22 18:08:35 +00:00
Client* topClientOnDesktop() const;
void sendClientToDesktop( Client* c, int desktop );
QPopupMenu* clientPopup( Client* );
void setDesktopClient( Client* );
bool iconifyMeansWithdraw( Client* );
void iconifyOrDeiconifyTransientsOf( Client* );
void setStickyTransientsOf( Client*, bool sticky );
bool hasCaption( const QString& caption );
void performWindowOperation( Client* c, Options::WindowOperation op );
void storeSession( KConfig* config );
SessionInfo* takeSessionInfo( Client* );
virtual void updateClientArea();
// dcop interface
void cascadeDesktop();
void unclutterDesktop();
void reconfigure();
void doNotManage(QString);
QString desktopName( int desk );
bool isNotManaged( const QString& title );
public slots:
void setCurrentDesktop( int new_desktop );
// keybindings
void slotSwitchDesktop1();
void slotSwitchDesktop2();
void slotSwitchDesktop3();
void slotSwitchDesktop4();
void slotSwitchDesktop5();
void slotSwitchDesktop6();
void slotSwitchDesktop7();
void slotSwitchDesktop8();
void slotSwitchDesktopRight();
void slotSwitchDesktopLeft();
void slotWindowMaximize();
void slotWindowMaximizeVertical();
void slotWindowMaximizeHorizontal();
void slotWindowIconify();
void slotWindowShade();
void slotWindowRaise();
void slotWindowLower();
void slotWindowOperations();
void slotWindowClose();
void slotWindowMove();
void slotWindowResize();
void slotMouseEmulation();
void slotResetAllClients();
void slotLogout();
void slotKillWindow();
private slots:
void desktopPopupAboutToShow();
void clientPopupAboutToShow();
void sendToDesktop( int );
void clientPopupActivated( int );
protected:
bool keyPress( XKeyEvent key );
bool keyRelease( XKeyEvent key );
bool keyPressMouseEmulation( XKeyEvent key );
bool netCheck( XEvent* e );
private:
void init();
void createKeybindings();
void freeKeyboard(bool pass);
ClientList constrainedStackingOrder( const ClientList& list );
Client* clientFactory(WId w);
void raiseTransientsOf( ClientList& safeset, Client* c );
void lowerTransientsOf( ClientList& safeset, Client* c );
void randomPlacement(Client* c);
void smartPlacement(Client* c);
void cascadePlacement(Client* c, bool re_init = false);
void focusToNull();
Client* findClientWidthId( WId w ) const;
void propagateClients( bool onlyStacking = FALSE);
bool addSystemTrayWin( WId w );
bool removeSystemTrayWin( WId w );
void propagateSystemTrayWins();
SystemTrayWindow findSystemTrayWin( WId w );
//CT needed for cascading+
struct CascadingInfo {
QPoint pos;
int col;
int row;
};
// desktop names and number of desktops
void loadDesktopSettings();
void saveDesktopSettings();
// mouse emulation
WId getMouseEmulationWindow();
enum MouseEmulation { EmuPress, EmuRelease, EmuMove };
unsigned int sendFakedMouseEvent( QPoint pos, WId win, MouseEmulation type, int button, unsigned int state ); // returns the new state
// ------------------
SystemTrayWindowList systemTrayWins;
int current_desktop;
int number_of_desktops;
QGuardedPtr<Client> popup_client;
void loadSessionInfo();
QWidget* desktop_widget;
QList<SessionInfo> session;
QValueList<CascadingInfo> cci;
Client* desktop_client;
Client* active_client;
Client* should_get_focus;
ClientList clients;
ClientList stacking_order;
ClientList focus_chain;
bool control_grab;
bool tab_grab;
bool mouse_emulation;
unsigned int mouse_emulation_state;
WId mouse_emulation_window;
bool focus_change;
TabBox* tab_box;
QPopupMenu *popup;
QPopupMenu *desk_popup;
KGlobalAccel *keys;
WId root;
PluginMgr mgr;
RootInfo *rootInfo;
QWidget* supportWindow;
QRect area;
// swallowing
QStringList doNotManageList;
};
inline WId Workspace::rootWin() const
{
return root;
}
inline Client* Workspace::activeClient() const
{
return active_client;
}
inline int Workspace::currentDesktop() const
{
return current_desktop;
}
inline int Workspace::numberOfDesktops() const
{
return number_of_desktops;
}
inline const ClientList& Workspace::stackingOrder() const
{
return stacking_order;
}
#endif