6655d0207d
/*! 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
364 lines
7.9 KiB
C++
364 lines
7.9 KiB
C++
/*****************************************************************
|
|
kwin - the KDE window manager
|
|
|
|
Copyright (C) 1999, 2000 Matthias Ettrich <ettrich@kde.org>
|
|
******************************************************************/
|
|
#ifndef CLIENT_H
|
|
#define CLIENT_H
|
|
|
|
#include "options.h"
|
|
#include <qframe.h>
|
|
#include <qvbox.h>
|
|
#include <qpixmap.h>
|
|
#include <qtimer.h>
|
|
#include <netwm_def.h>
|
|
#include <X11/X.h>
|
|
#include <X11/Xlib.h>
|
|
#include <X11/Xutil.h>
|
|
|
|
class Workspace;
|
|
class Client;
|
|
class WinInfo;
|
|
|
|
class WindowWrapper : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
WindowWrapper( WId w, Client *parent=0, const char* name=0);
|
|
~WindowWrapper();
|
|
|
|
WId window() const;
|
|
void releaseWindow();
|
|
void invalidateWindow();
|
|
QSize sizeHint() const;
|
|
QSizePolicy sizePolicy() const;
|
|
|
|
void setActive( bool );
|
|
|
|
protected:
|
|
void resizeEvent( QResizeEvent * );
|
|
void showEvent( QShowEvent* );
|
|
void hideEvent( QHideEvent* );
|
|
bool x11Event( XEvent * ); // X11 event
|
|
|
|
|
|
private:
|
|
WId win;
|
|
Time lastMouseEventTime;
|
|
bool reparented;
|
|
};
|
|
|
|
inline WId WindowWrapper::window() const
|
|
{
|
|
return win;
|
|
}
|
|
|
|
|
|
|
|
class Client : public QWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
Client( Workspace *ws, WId w, QWidget *parent=0, const char *name=0, WFlags f = 0);
|
|
~Client();
|
|
|
|
WId window() const;
|
|
WindowWrapper* windowWrapper() const;
|
|
Workspace* workspace() const;
|
|
void releaseWindow();
|
|
void invalidateWindow();
|
|
WId transientFor() const;
|
|
bool isTransient() const;
|
|
Client* mainClient();
|
|
NET::WindowType windowType() const;
|
|
|
|
virtual bool windowEvent( XEvent * );
|
|
|
|
void manage( bool isMapped = FALSE );
|
|
|
|
void setMappingState( int s );
|
|
int mappingState() const;
|
|
|
|
void requestActivation();
|
|
void withdraw();
|
|
|
|
QSize adjustedSize( const QSize& ) const;
|
|
|
|
QPixmap icon() const;
|
|
QPixmap miniIcon() const;
|
|
|
|
|
|
// is the window in withdrawn state?
|
|
bool isWithdrawn(){
|
|
return state == WithdrawnState;
|
|
}
|
|
// is the window in iconic state?
|
|
bool isIconified(){
|
|
return state == IconicState;
|
|
}
|
|
// is the window in normal state?
|
|
bool isNormal(){
|
|
return state == NormalState;
|
|
}
|
|
|
|
bool isActive() const;
|
|
void setActive( bool );
|
|
|
|
int desktop() const;
|
|
void setDesktop( int );
|
|
bool isOnDesktop( int d ) const;
|
|
|
|
bool isShade() const;
|
|
virtual void setShade( bool );
|
|
|
|
bool isMaximized() const;
|
|
enum MaximizeMode { MaximizeVertical, MaximizeHorizontal, MaximizeFull };
|
|
|
|
bool isSticky() const;
|
|
void setSticky( bool );
|
|
|
|
|
|
// auxiliary functions, depend on the windowType
|
|
bool wantsTabFocus() const;
|
|
bool isMovable() const;
|
|
bool isDesktop() const;
|
|
bool isDock() const;
|
|
|
|
void takeFocus();
|
|
|
|
void setMask( const QRegion & );
|
|
const QRegion& getMask() const;
|
|
|
|
// transparent stuff
|
|
virtual void drawbound( const QRect& geom );
|
|
virtual void clearbound();
|
|
|
|
|
|
// shape extensions
|
|
bool shape() const;
|
|
void updateShape();
|
|
|
|
void setGeometry( int x, int y, int w, int h );
|
|
void setGeometry( const QRect &r )
|
|
{ setGeometry( r.left(), r.top(), r.width(), r.height() ); }
|
|
void move( int x, int y );
|
|
void move( const QPoint & p )
|
|
{ move( p.x(), p.y() ); }
|
|
|
|
|
|
|
|
bool providesContextHelp() const;
|
|
|
|
bool performMouseCommand( Options::MouseCommand, QPoint globalPos );
|
|
|
|
QCString windowRole();
|
|
QCString sessionId();
|
|
|
|
QRect adjustedClientArea( const QRect& area ) const;
|
|
|
|
public slots:
|
|
void iconify();
|
|
void closeWindow();
|
|
void killWindow();
|
|
void maximize( MaximizeMode );
|
|
void maximize();
|
|
void toggleSticky();
|
|
void contextHelp();
|
|
|
|
protected:
|
|
void paintEvent( QPaintEvent * );
|
|
void mousePressEvent( QMouseEvent * );
|
|
void mouseReleaseEvent( QMouseEvent * );
|
|
void mouseMoveEvent( QMouseEvent * );
|
|
void keyPressEvent( QKeyEvent * );
|
|
void resizeEvent( QResizeEvent * );
|
|
virtual void windowWrapperShowEvent( QShowEvent* ){}
|
|
virtual void windowWrapperHideEvent( QHideEvent* ){}
|
|
void enterEvent( QEvent * );
|
|
void leaveEvent( QEvent * );
|
|
void showEvent( QShowEvent* );
|
|
void hideEvent( QHideEvent* );
|
|
bool x11Event( XEvent * ); // X11 event
|
|
|
|
virtual void activateLayout();
|
|
|
|
bool eventFilter( QObject *, QEvent * );
|
|
|
|
|
|
virtual void init();
|
|
virtual void captionChange( const QString& name );
|
|
virtual void iconChange();
|
|
virtual void activeChange( bool );
|
|
virtual void maximizeChange( bool );
|
|
virtual void stickyChange( bool );
|
|
|
|
|
|
enum MousePosition {
|
|
Nowhere, TopLeft , BottomRight, BottomLeft, TopRight, Top, Bottom, Left, Right, Center
|
|
};
|
|
|
|
virtual MousePosition mousePosition( const QPoint& ) const;
|
|
virtual void setMouseCursor( MousePosition m );
|
|
|
|
// handlers for X11 events
|
|
bool mapRequest( XMapRequestEvent& e );
|
|
bool unmapNotify( XUnmapEvent& e );
|
|
bool configureRequest( XConfigureRequestEvent& e );
|
|
bool propertyNotify( XPropertyEvent& e );
|
|
bool clientMessage( XClientMessageEvent& e );
|
|
|
|
private:
|
|
QSize sizeForWindowSize( const QSize&, bool ignore_height = FALSE ) const;
|
|
void getWmNormalHints();
|
|
void fetchName();
|
|
void gravitate( bool invert );
|
|
|
|
|
|
WId win;
|
|
WindowWrapper* wwrap;
|
|
Workspace* wspace;
|
|
int desk;
|
|
bool buttonDown;
|
|
bool moveResizeMode;
|
|
bool isMove() const {
|
|
return moveResizeMode && mode == Center;
|
|
}
|
|
bool isResize() const {
|
|
return moveResizeMode && !isMove();
|
|
}
|
|
MousePosition mode;
|
|
QPoint moveOffset;
|
|
QPoint invertedMoveOffset;
|
|
QSize clientSize;
|
|
XSizeHints xSizeHint;
|
|
void sendSynteticConfigureNotify();
|
|
int state;
|
|
QRect original_geometry;
|
|
QRect geom; //### TODO
|
|
WId transient_for;
|
|
uint shaded :1;
|
|
uint active :1;
|
|
uint is_sticky :1;
|
|
uint is_shape :1;
|
|
uint may_move :1;
|
|
uint passive_focus :1;
|
|
uint Pdeletewindow :1; // does the window understand the DeleteWindow protocol?
|
|
uint Ptakefocus :1;// does the window understand the TakeFocus protocol?
|
|
uint Pcontexthelp : 1; // does the window understand the ContextHelp protocol?
|
|
uint input :1; // does the window want input in its wm_hints
|
|
uint mapped :1; // keeps track of our visiblity within the asynchronous event flow
|
|
void getWMHints();
|
|
void getWindowProtocols();
|
|
QPixmap icon_pix;
|
|
QPixmap miniicon_pix;
|
|
QRect geom_restore;
|
|
QRegion mask;
|
|
WinInfo* info;
|
|
|
|
};
|
|
|
|
inline WId Client::window() const
|
|
{
|
|
return win;
|
|
}
|
|
|
|
inline WindowWrapper* Client::windowWrapper() const
|
|
{
|
|
return wwrap;
|
|
}
|
|
|
|
inline Workspace* Client::workspace() const
|
|
{
|
|
return wspace;
|
|
}
|
|
|
|
inline WId Client::transientFor() const
|
|
{
|
|
return transient_for;
|
|
}
|
|
|
|
inline bool Client::isTransient() const
|
|
{
|
|
return transient_for != 0;
|
|
}
|
|
|
|
|
|
|
|
inline int Client::mappingState() const
|
|
{
|
|
return state;
|
|
}
|
|
|
|
|
|
inline bool Client::isActive() const
|
|
{
|
|
return active;
|
|
}
|
|
|
|
/*!
|
|
Returns the virtual desktop within the workspace() the client window
|
|
is located in, -1 if it isn't located on any special desktop. This may be
|
|
if the window wasn't mapped yet or if the window is sticky. Do not use
|
|
desktop() directly, use isOnDesktop() instead.
|
|
*/
|
|
inline int Client::desktop() const
|
|
{
|
|
return desk;
|
|
}
|
|
|
|
/*!
|
|
Returns whether the client is on visible or iconified on the virtual
|
|
desktop \a d. This is always TRUE for sticky clients.
|
|
*/
|
|
inline bool Client::isOnDesktop( int d ) const
|
|
{
|
|
return desk == d || desk == -1 || isSticky();
|
|
}
|
|
|
|
|
|
inline QPixmap Client::icon() const
|
|
{
|
|
return icon_pix;
|
|
}
|
|
|
|
inline QPixmap Client::miniIcon() const
|
|
{
|
|
return miniicon_pix;
|
|
}
|
|
|
|
|
|
/*!
|
|
Is the client maximized?
|
|
*/
|
|
inline bool Client::isMaximized() const
|
|
{
|
|
return !geom_restore.isNull();
|
|
}
|
|
|
|
inline bool Client::isSticky() const
|
|
{
|
|
return is_sticky;
|
|
}
|
|
|
|
|
|
inline bool Client::shape() const
|
|
{
|
|
return is_shape;
|
|
}
|
|
|
|
|
|
inline const QRegion& Client::getMask() const
|
|
{
|
|
return mask;
|
|
}
|
|
|
|
class NoBorderClient : public Client
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
NoBorderClient( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 );
|
|
~NoBorderClient();
|
|
|
|
};
|
|
|
|
#endif
|