summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@compiz-fusion.org>2008-09-15 22:05:41 +0200
committerDennis Kasprzyk <onestone@compiz-fusion.org>2008-09-15 22:05:41 +0200
commitd5acffa9795add9ebc9c6e6920a5e80581584863 (patch)
treea55558b31b3b8b455aa9286cf139b9f6c19df003
parent8fcba7fa8ec54cac55d4136cfd41a3a8d9ccb192 (diff)
downloadunity-window-decorator-d5acffa9795add9ebc9c6e6920a5e80581584863.tar.gz
unity-window-decorator-d5acffa9795add9ebc9c6e6920a5e80581584863.tar.bz2
Merge CompCore and CompDisplay into CompScreen class.
-rw-r--r--include/compaction.h18
-rw-r--r--include/compcore.h176
-rw-r--r--include/compdisplay.h443
-rw-r--r--include/compiz-core.h2
-rw-r--r--include/compiz.h3
-rw-r--r--include/compmatch.h4
-rw-r--r--include/compmetadata.h33
-rw-r--r--include/compobject.h8
-rw-r--r--include/compoption.h12
-rw-r--r--include/compplugin.h30
-rw-r--r--include/compscreen.h386
-rw-r--r--include/compwindow.h75
-rw-r--r--include/core/atoms.h135
-rw-r--r--include/core/timer.h42
-rw-r--r--metadata/core.xml.in6
-rw-r--r--src/Makefile.am7
-rw-r--r--src/action.cpp59
-rw-r--r--src/actions.cpp353
-rw-r--r--src/atoms.cpp299
-rw-r--r--src/core.cpp681
-rw-r--r--src/display.cpp2396
-rw-r--r--src/event.cpp366
-rw-r--r--src/main.cpp33
-rw-r--r--src/match.cpp55
-rw-r--r--src/metadata.cpp207
-rw-r--r--src/object.cpp9
-rw-r--r--src/option.cpp147
-rw-r--r--src/plugin.cpp42
-rw-r--r--src/privatecore.h55
-rw-r--r--src/privatedisplay.h210
-rw-r--r--src/privatematch.h1
-rw-r--r--src/privateoption.h1
-rw-r--r--src/privatescreen.h247
-rw-r--r--src/privatewindow.h3
-rw-r--r--src/screen.cpp3280
-rw-r--r--src/session.cpp14
-rw-r--r--src/timer.cpp107
-rw-r--r--src/window.cpp298
38 files changed, 4578 insertions, 5665 deletions
diff --git a/include/compaction.h b/include/compaction.h
index 3f789cd..0ae702c 100644
--- a/include/compaction.h
+++ b/include/compaction.h
@@ -61,8 +61,8 @@ class CompAction {
unsigned int modifiers ();
int keycode ();
- bool fromString (CompDisplay *d, const CompString str);
- CompString toString (CompDisplay *d);
+ bool fromString (const CompString str);
+ CompString toString ();
private:
unsigned int mModifiers;
@@ -77,8 +77,8 @@ class CompAction {
unsigned int modifiers ();
int button ();
- bool fromString (CompDisplay *d, const CompString str);
- CompString toString (CompDisplay *d);
+ bool fromString (const CompString str);
+ CompString toString ();
private:
unsigned int mModifiers;
@@ -87,7 +87,7 @@ class CompAction {
typedef unsigned int State;
typedef unsigned int BindingType;
- typedef boost::function <bool (CompDisplay *, CompAction *, State, CompOption::Vector &)> CallBack;
+ typedef boost::function <bool (CompAction *, State, CompOption::Vector &)> CallBack;
public:
CompAction ();
@@ -119,12 +119,12 @@ class CompAction {
bool operator== (const CompAction& val);
CompAction & operator= (const CompAction &action);
- void keyFromString (CompDisplay *d, const CompString str);
- void buttonFromString (CompDisplay *d, const CompString str);
+ void keyFromString (const CompString str);
+ void buttonFromString (const CompString str);
void edgeMaskFromString (const CompString str);
- CompString keyToString (CompDisplay *d);
- CompString buttonToString (CompDisplay *d);
+ CompString keyToString ();
+ CompString buttonToString ();
CompString edgeMaskToString ();
static CompString edgeToString (unsigned int edge);
diff --git a/include/compcore.h b/include/compcore.h
deleted file mode 100644
index 20dbf9d..0000000
--- a/include/compcore.h
+++ /dev/null
@@ -1,176 +0,0 @@
-#ifndef _COMPCORE_H
-#define _COMPCORE_H
-
-#include <list>
-#include <boost/function.hpp>
-
-#include <compwrapsystem.h>
-
-#include <compoption.h>
-#include <compobject.h>
-#include <compsession.h>
-
-class PrivateCore;
-class CompCore;
-class CompDisplay;
-class CompPlugin;
-class CompMetadata;
-typedef std::list<CompDisplay *> CompDisplayList;
-
-extern CompCore *core;
-extern CompMetadata *coreMetadata;
-
-#define GET_CORE_CORE(object) (dynamic_cast<CompCore *> (object))
-#define CORE_CORE(object) CompCore *c = GET_CORE_SCREEN (object)
-
-#define NOTIFY_CREATE_MASK (1 << 0)
-#define NOTIFY_DELETE_MASK (1 << 1)
-#define NOTIFY_MOVE_MASK (1 << 2)
-#define NOTIFY_MODIFY_MASK (1 << 3)
-
-typedef boost::function<void ()> FdWatchCallBack;
-typedef boost::function<void (const char *)> FileWatchCallBack;
-
-typedef int CompFileWatchHandle;
-typedef int CompWatchFdHandle;
-
-struct CompFileWatch {
- char *path;
- int mask;
- FileWatchCallBack callBack;
- CompFileWatchHandle handle;
-};
-
-class CoreInterface : public WrapableInterface<CompCore, CoreInterface> {
- public:
-
- virtual void fileWatchAdded (CompFileWatch *fw);
- virtual void fileWatchRemoved (CompFileWatch *fw);
-
- virtual bool initPluginForObject (CompPlugin *p, CompObject *o);
- virtual void finiPluginForObject (CompPlugin *p, CompObject *o);
-
- virtual bool setOptionForPlugin (CompObject *o, const char *plugin,
- const char *name,
- CompOption::Value &v);
-
- virtual void objectAdd (CompObject *parent, CompObject *child);
- virtual void objectRemove (CompObject *parent, CompObject *child);
-
- virtual void sessionEvent (CompSession::Event event,
- CompOption::Vector &options);
-};
-
-class CompCore : public WrapableHandler<CoreInterface, 8>, public CompObject {
-
- public:
- class Timer {
-
- public:
-
- typedef boost::function<bool ()> CallBack;
-
- Timer ();
- ~Timer ();
-
- bool active ();
- unsigned int minTime ();
- unsigned int maxTime ();
- unsigned int minLeft ();
- unsigned int maxLeft ();
-
- void setTimes (unsigned int min, unsigned int max = 0);
- void setCallback (CallBack callback);
-
- void start ();
- void start (unsigned int min, unsigned int max = 0);
- void start (CallBack callback,
- unsigned int min, unsigned int max = 0);
- void stop ();
-
- friend class CompCore;
- friend class PrivateCore;
-
- private:
- bool mActive;
- unsigned int mMinTime;
- unsigned int mMaxTime;
- int mMinLeft;
- int mMaxLeft;
- CallBack mCallBack;
- };
-
- // functions
- public:
- CompCore ();
- ~CompCore ();
-
- CompString objectName ();
-
- bool
- init ();
-
- bool
- addDisplay (const char *name);
-
- void
- removeDisplay (CompDisplay *);
-
- void
- eventLoop ();
-
- CompDisplayList &
- displays();
-
- CompFileWatchHandle
- addFileWatch (const char *path,
- int mask,
- FileWatchCallBack callBack);
-
- void
- removeFileWatch (CompFileWatchHandle handle);
-
- CompWatchFdHandle
- addWatchFd (int fd,
- short int events,
- FdWatchCallBack callBack);
-
- void
- removeWatchFd (CompWatchFdHandle handle);
-
- void storeValue (CompString key, CompPrivate value);
- bool hasValue (CompString key);
- CompPrivate getValue (CompString key);
- void eraseValue (CompString key);
-
-
- static int allocPrivateIndex ();
- static void freePrivateIndex (int index);
-
- // Wrapable interface
-
- WRAPABLE_HND(0, CoreInterface, void, fileWatchAdded, CompFileWatch *)
- WRAPABLE_HND(1, CoreInterface, void, fileWatchRemoved, CompFileWatch *)
-
- WRAPABLE_HND(2, CoreInterface, bool, initPluginForObject,
- CompPlugin *, CompObject *)
- WRAPABLE_HND(3, CoreInterface, void, finiPluginForObject,
- CompPlugin *, CompObject *)
-
- WRAPABLE_HND(4, CoreInterface, bool, setOptionForPlugin, CompObject *,
- const char *, const char *, CompOption::Value &)
-
- WRAPABLE_HND(5, CoreInterface, void, objectAdd,
- CompObject *, CompObject *)
- WRAPABLE_HND(6, CoreInterface, void, objectRemove,
- CompObject *, CompObject *)
-
- WRAPABLE_HND(7, CoreInterface, void, sessionEvent, CompSession::Event,
- CompOption::Vector &)
-
- friend class Timer;
- private:
- PrivateCore *priv;
-};
-
-#endif
diff --git a/include/compdisplay.h b/include/compdisplay.h
deleted file mode 100644
index 6feef85..0000000
--- a/include/compdisplay.h
+++ /dev/null
@@ -1,443 +0,0 @@
-#ifndef _COMPDISPLAY_H
-#define _COMPDISPLAY_H
-
-#include <list>
-
-#include <X11/Xlib-xcb.h>
-#include <X11/Xutil.h>
-#include <X11/Xregion.h>
-#include <X11/extensions/Xinerama.h>
-
-#include <compobject.h>
-#include <compmatch.h>
-#include <compcore.h>
-#include <compaction.h>
-#include <compwrapsystem.h>
-
-class CompDisplay;
-class CompScreen;
-class CompOutput;
-class PrivateDisplay;
-typedef std::list<CompScreen *> CompScreenList;
-
-extern REGION emptyRegion;
-extern REGION infiniteRegion;
-
-extern int lastPointerX;
-extern int lastPointerY;
-extern int pointerX;
-extern int pointerY;
-
-#define GET_CORE_DISPLAY(object) (dynamic_cast<CompDisplay *> (object))
-#define CORE_DISPLAY(object) CompDisplay *d = GET_CORE_DISPLAY (object)
-
-class DisplayInterface :
- public WrapableInterface<CompDisplay, DisplayInterface>
-{
- public:
-
- virtual void handleEvent (XEvent *event);
- virtual void handleCompizEvent (const char * plugin, const char *event,
- CompOption::Vector &options);
-
- virtual bool fileToImage (const char *path, const char *name,
- int *width, int *height,
- int *stride, void **data);
- virtual bool imageToFile (const char *path, const char *name,
- const char *format, int width, int height,
- int stride, void *data);
-
- virtual CompMatch::Expression *matchInitExp (const CompString value);
-
- virtual void matchExpHandlerChanged ();
- virtual void matchPropertyChanged (CompWindow *window);
-
- virtual void logMessage (const char *componentName,
- CompLogLevel level,
- const char *message);
-};
-
-class CompDisplay :
- public WrapableHandler<DisplayInterface, 8>,
- public CompObject
-{
-
- public:
-
- class Atoms {
- public:
- Atom supported;
- Atom supportingWmCheck;
-
- Atom utf8String;
-
- Atom wmName;
-
- Atom winType;
- Atom winTypeDesktop;
- Atom winTypeDock;
- Atom winTypeToolbar;
- Atom winTypeMenu;
- Atom winTypeUtil;
- Atom winTypeSplash;
- Atom winTypeDialog;
- Atom winTypeNormal;
- Atom winTypeDropdownMenu;
- Atom winTypePopupMenu;
- Atom winTypeTooltip;
- Atom winTypeNotification;
- Atom winTypeCombo;
- Atom winTypeDnd;
-
- Atom winOpacity;
- Atom winBrightness;
- Atom winSaturation;
- Atom winActive;
- Atom winDesktop;
-
- Atom workarea;
-
- Atom desktopViewport;
- Atom desktopGeometry;
- Atom currentDesktop;
- Atom numberOfDesktops;
-
- Atom winState;
- Atom winStateModal;
- Atom winStateSticky;
- Atom winStateMaximizedVert;
- Atom winStateMaximizedHorz;
- Atom winStateShaded;
- Atom winStateSkipTaskbar;
- Atom winStateSkipPager;
- Atom winStateHidden;
- Atom winStateFullscreen;
- Atom winStateAbove;
- Atom winStateBelow;
- Atom winStateDemandsAttention;
- Atom winStateDisplayModal;
-
- Atom winActionMove;
- Atom winActionResize;
- Atom winActionStick;
- Atom winActionMinimize;
- Atom winActionMaximizeHorz;
- Atom winActionMaximizeVert;
- Atom winActionFullscreen;
- Atom winActionClose;
- Atom winActionShade;
- Atom winActionChangeDesktop;
- Atom winActionAbove;
- Atom winActionBelow;
-
- Atom wmAllowedActions;
-
- Atom wmStrut;
- Atom wmStrutPartial;
-
- Atom wmUserTime;
-
- Atom wmIcon;
- Atom wmIconGeometry;
-
- Atom clientList;
- Atom clientListStacking;
-
- Atom frameExtents;
- Atom frameWindow;
-
- Atom wmState;
- Atom wmChangeState;
- Atom wmProtocols;
- Atom wmClientLeader;
-
- Atom wmDeleteWindow;
- Atom wmTakeFocus;
- Atom wmPing;
- Atom wmSyncRequest;
-
- Atom wmSyncRequestCounter;
-
- Atom closeWindow;
- Atom wmMoveResize;
- Atom moveResizeWindow;
- Atom restackWindow;
-
- Atom showingDesktop;
-
- Atom xBackground[2];
-
- Atom toolkitAction;
- Atom toolkitActionMainMenu;
- Atom toolkitActionRunDialog;
- Atom toolkitActionWindowMenu;
- Atom toolkitActionForceQuitDialog;
-
- Atom mwmHints;
-
- Atom xdndAware;
- Atom xdndEnter;
- Atom xdndLeave;
- Atom xdndPosition;
- Atom xdndStatus;
- Atom xdndDrop;
-
- Atom manager;
- Atom targets;
- Atom multiple;
- Atom timestamp;
- Atom version;
- Atom atomPair;
-
- Atom startupId;
- };
-
- public:
- // functions
- CompDisplay ();
- ~CompDisplay ();
-
- CompString objectName ();
-
- bool
- init (const char *name);
-
- bool
- addScreen (int screenNum);
-
- void
- removeScreen (CompScreen *);
-
- Atoms
- atoms();
-
- Display *
- dpy();
-
- CompScreenList &
- screens();
-
- CompOption *
- getOption (const char *);
-
- bool
- setOption (const char *name,
- CompOption::Value &value);
-
- std::vector<XineramaScreenInfo> &
- screenInfo ();
-
- bool
- XRandr ();
-
- int randrEvent ();
-
- bool
- XShape ();
-
- int shapeEvent ();
-
- int syncEvent ();
-
- SnDisplay *
- snDisplay ();
-
- Window
- below ();
-
- Window
- activeWindow ();
-
- Window
- autoRaiseWindow ();
-
- XModifierKeymap *
- modMap ();
-
- unsigned int
- ignoredModMask ();
-
- const char *
- displayString ();
-
- unsigned int
- lastPing ();
-
- CompWatchFdHandle
- getWatchFdHandle ();
-
- void
- setWatchFdHandle (CompWatchFdHandle);
-
- void
- processEvents ();
-
- void
- updateModifierMappings ();
-
- unsigned int
- virtualToRealModMask (unsigned int modMask);
-
- unsigned int
- keycodeToModifiers (int keycode);
-
- CompScreen *
- findScreen (Window root);
-
- CompWindow *
- findWindow (Window id);
-
- CompWindow *
- findTopLevelWindow (Window id, bool override_redirect = false);
-
-
-
- bool
- readImageFromFile (const char *name,
- int *width,
- int *height,
- void **data);
-
- bool
- writeImageToFile (const char *path,
- const char *name,
- const char *format,
- int width,
- int height,
- void *data);
-
- void
- updateScreenInfo ();
-
- Window
- getActiveWindow (Window root);
-
- int
- getWmState (Window id);
-
- void
- setWmState (int state, Window id);
-
- unsigned int
- windowStateMask (Atom state);
-
-
- static unsigned int
- windowStateFromString (const char *str);
-
- unsigned int
- getWindowState (Window id);
-
- void
- setWindowState (unsigned int state, Window id);
-
- unsigned int
- getWindowType (Window id);
-
- void
- getMwmHints (Window id,
- unsigned int *func,
- unsigned int *decor);
-
-
- unsigned int
- getProtocols (Window id);
-
-
- unsigned int
- getWindowProp (Window id,
- Atom property,
- unsigned int defaultValue);
-
-
- void
- setWindowProp (Window id,
- Atom property,
- unsigned int value);
-
-
- bool
- readWindowProp32 (Window id,
- Atom property,
- unsigned short *returnValue);
-
-
- unsigned short
- getWindowProp32 (Window id,
- Atom property,
- unsigned short defaultValue);
-
-
- void
- setWindowProp32 (Window id,
- Atom property,
- unsigned short value);
-
- void
- addScreenActions (CompScreen *s);
-
- static int allocPrivateIndex ();
- static void freePrivateIndex (int index);
-
- static int checkForError (Display *dpy);
-
- // wrapable interface
- WRAPABLE_HND (0, DisplayInterface, void, handleEvent, XEvent *event)
- WRAPABLE_HND (1, DisplayInterface, void, handleCompizEvent,
- const char *, const char *, CompOption::Vector &)
-
- WRAPABLE_HND (2, DisplayInterface, bool, fileToImage, const char *,
- const char *, int *, int *, int *, void **data)
- WRAPABLE_HND (3, DisplayInterface, bool, imageToFile, const char *,
- const char *, const char *, int, int, int, void *)
-
-
- WRAPABLE_HND (4, DisplayInterface, CompMatch::Expression *,
- matchInitExp, const CompString);
- WRAPABLE_HND (5, DisplayInterface, void, matchExpHandlerChanged)
- WRAPABLE_HND (6, DisplayInterface, void, matchPropertyChanged,
- CompWindow *)
-
- WRAPABLE_HND (7, DisplayInterface, void, logMessage, const char *,
- CompLogLevel, const char*)
-
- private:
-
- PrivateDisplay *priv;
-
- public:
-
- static bool
- runCommandDispatch (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool
- runCommandScreenshot(CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool
- runCommandWindowScreenshot(CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool
- runCommandTerminal (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static CompOption::Vector &
- getDisplayOptions (CompObject *object);
-
- static bool setDisplayOption (CompObject *object,
- const char *name,
- CompOption::Value &value);
-};
-
-
-#endif
diff --git a/include/compiz-core.h b/include/compiz-core.h
index 0b4f70f..33558af 100644
--- a/include/compiz-core.h
+++ b/include/compiz-core.h
@@ -67,8 +67,6 @@ typedef XBool Bool;
#endif
#include <compobject.h>
-#include <compcore.h>
-#include <compdisplay.h>
#include <compscreen.h>
#include <compwindow.h>
#include <compplugin.h>
diff --git a/include/compiz.h b/include/compiz.h
index 22d37f6..818e887 100644
--- a/include/compiz.h
+++ b/include/compiz.h
@@ -72,8 +72,7 @@ typedef enum {
} CompLogLevel;
void
-compLogMessage (CompDisplay *d,
- const char *componentName,
+compLogMessage (const char *componentName,
CompLogLevel level,
const char *format,
...);
diff --git a/include/compmatch.h b/include/compmatch.h
index 1527427..3a0c5f4 100644
--- a/include/compmatch.h
+++ b/include/compmatch.h
@@ -22,13 +22,11 @@ class CompMatch {
CompMatch (const CompMatch &);
~CompMatch ();
- void update (CompDisplay *display);
+ void update ();
bool evaluate (CompWindow *window);
CompString toString ();
- CompDisplay *display ();
-
CompMatch & operator= (const CompMatch &);
CompMatch & operator&= (const CompMatch &);
CompMatch & operator|= (const CompMatch &);
diff --git a/include/compmetadata.h b/include/compmetadata.h
index f102450..e482fe5 100644
--- a/include/compmetadata.h
+++ b/include/compmetadata.h
@@ -25,10 +25,8 @@ class CompMetadata {
public:
CompMetadata ();
CompMetadata (CompString plugin,
- const OptionInfo *displayOptionInfo = NULL,
- unsigned int nDisplayOptionInfo = 0,
- const OptionInfo *screenOptionInfo = NULL,
- unsigned int nScreenOptionInfo = 0);
+ const OptionInfo *optionInfo = NULL,
+ unsigned int nOptionInfo = 0);
~CompMetadata ();
std::vector<xmlDoc *> &doc ();
@@ -39,35 +37,22 @@ class CompMetadata {
xmlInputCloseCallback ioclose,
void *ioctx);
- bool initScreenOption (CompScreen *screen,
- CompOption *option,
- CompString name);
+ bool initOption (CompOption *option,
+ CompString name);
- bool initDisplayOption (CompDisplay *display,
- CompOption *option,
- CompString name);
+ bool initOptions (const OptionInfo *info,
+ unsigned int nOptions,
+ CompOption::Vector &options);
- bool initScreenOptions (CompScreen *screen,
- const OptionInfo *info,
- unsigned int nOptions,
- CompOption::Vector &options);
- bool initDisplayOptions (CompDisplay *display,
- const OptionInfo *info,
- unsigned int nOptions,
- CompOption::Vector &options);
CompString getShortPluginDescription ();
CompString getLongPluginDescription ();
- CompString getShortScreenOptionDescription (CompOption *option);
+ CompString getShortOptionDescription (CompOption *option);
- CompString getLongScreenOptionDescription (CompOption *option);
-
- CompString getShortDisplayOptionDescription (CompOption *option);
-
- CompString getLongDisplayOptionDescription (CompOption *option);
+ CompString getLongOptionDescription (CompOption *option);
CompString getStringFromPath (CompString path);
diff --git a/include/compobject.h b/include/compobject.h
index 461c9a6..f712059 100644
--- a/include/compobject.h
+++ b/include/compobject.h
@@ -7,11 +7,9 @@
#include <boost/function.hpp>
#define COMP_OBJECT_TYPE_ALL -1
-#define COMP_OBJECT_TYPE_CORE 0
-#define COMP_OBJECT_TYPE_DISPLAY 1
-#define COMP_OBJECT_TYPE_SCREEN 2
-#define COMP_OBJECT_TYPE_WINDOW 3
-#define COMP_OBJECT_TYPE_NUM 4
+#define COMP_OBJECT_TYPE_SCREEN 0
+#define COMP_OBJECT_TYPE_WINDOW 1
+#define COMP_OBJECT_TYPE_NUM 2
#define ARRAY_SIZE(array) \
(sizeof (array) / sizeof (array[0]))
diff --git a/include/compoption.h b/include/compoption.h
index fd8f626..227c156 100644
--- a/include/compoption.h
+++ b/include/compoption.h
@@ -151,19 +151,9 @@ class CompOption {
static CompString colorToString (unsigned short *rgba);
- static bool setScreenOption (CompScreen *s,
- CompOption &o,
- Value &value);
- static bool setDisplayOption (CompDisplay *d,
- CompOption &o,
- Value &value);
+ static bool setOption (CompOption &o, Value &value);
- static void finiScreenOptions (CompScreen *s,
- Vector &options);
-
- static void finiDisplayOptions (CompDisplay *d,
- Vector &options);
private:
diff --git a/include/compplugin.h b/include/compplugin.h
index 9c067a3..9d7aa5b 100644
--- a/include/compplugin.h
+++ b/include/compplugin.h
@@ -61,16 +61,9 @@
delete obj; \
}
-#define INIT_OBJECT(obj, hasCore, hasDisplay, hasScreen, hasWindow, \
- coreName, displayName, screenName, windowName) \
+#define INIT_OBJECT(obj, hasScreen, hasWindow, screenName, windowName) \
switch ( obj ->objectType ()) \
{ \
- case COMP_OBJECT_TYPE_CORE: \
- __INIT_PLUGIN_OBJECT_ ## hasCore (coreName, GET_CORE_CORE (obj)) \
- break; \
- case COMP_OBJECT_TYPE_DISPLAY: \
- __INIT_PLUGIN_OBJECT_ ## hasDisplay (displayName, GET_CORE_DISPLAY (obj)) \
- break; \
case COMP_OBJECT_TYPE_SCREEN: \
__INIT_PLUGIN_OBJECT_ ## hasScreen (screenName, GET_CORE_SCREEN (obj)) \
break; \
@@ -81,16 +74,9 @@
break; \
}
-#define FINI_OBJECT(obj, hasCore, hasDisplay, hasScreen, hasWindow, \
- coreName, displayName, screenName, windowName) \
+#define FINI_OBJECT(obj, hasScreen, hasWindow, screenName, windowName) \
switch ( obj ->objectType ()) \
{ \
- case COMP_OBJECT_TYPE_CORE: \
- __FINI_PLUGIN_OBJECT_ ## hasCore (coreName, GET_CORE_CORE (obj)) \
- break; \
- case COMP_OBJECT_TYPE_DISPLAY: \
- __FINI_PLUGIN_OBJECT_ ## hasDisplay (displayName, GET_CORE_DISPLAY (obj)) \
- break; \
case COMP_OBJECT_TYPE_SCREEN: \
__FINI_PLUGIN_OBJECT_ ## hasScreen (screenName, GET_CORE_SCREEN (obj)) \
break; \
@@ -101,13 +87,9 @@
break; \
}
-#define GET_OBJECT_OPTIONS(obj, hasDisplay, hasScreen, displayName, screenName) \
+#define GET_OBJECT_OPTIONS(obj, hasScreen, screenName) \
switch ( obj ->objectType ()) \
{ \
- case COMP_OBJECT_TYPE_DISPLAY: \
- __GET_PLUGIN_OBJECT_OPTIONS_ ## hasDisplay \
- (displayName, GET_CORE_DISPLAY (obj)) \
- break; \
case COMP_OBJECT_TYPE_SCREEN: \
__GET_PLUGIN_OBJECT_OPTIONS_ ## hasScreen \
(screenName, GET_CORE_SCREEN (obj)) \
@@ -116,13 +98,9 @@
break; \
}
-#define SET_OBJECT_OPTION(obj, hasDisplay, hasScreen, displayName, screenName) \
+#define SET_OBJECT_OPTION(obj, hasScreen, screenName) \
switch ( obj ->objectType ()) \
{ \
- case COMP_OBJECT_TYPE_DISPLAY: \
- __SET_PLUGIN_OBJECT_OPTION_ ## hasDisplay \
- (displayName, GET_CORE_DISPLAY (obj), name, value) \
- break; \
case COMP_OBJECT_TYPE_SCREEN: \
__SET_PLUGIN_OBJECT_OPTION_ ## hasScreen \
(screenName, GET_CORE_SCREEN (obj), name, value) \
diff --git a/include/compscreen.h b/include/compscreen.h
index 1846d7f..629845a 100644
--- a/include/compscreen.h
+++ b/include/compscreen.h
@@ -4,6 +4,9 @@
#include <compwindow.h>
#include <compoutput.h>
#include <compsession.h>
+#include <compmetadata.h>
+#include <compplugin.h>
+#include <compmatch.h>
class CompScreen;
class PrivateScreen;
@@ -15,6 +18,35 @@ extern bool indirectRendering;
extern bool strictBinding;
extern bool noDetection;
+extern CompScreen *screen;
+extern CompMetadata *coreMetadata;
+
+extern REGION emptyRegion;
+extern REGION infiniteRegion;
+
+extern int lastPointerX;
+extern int lastPointerY;
+extern int pointerX;
+extern int pointerY;
+
+#define NOTIFY_CREATE_MASK (1 << 0)
+#define NOTIFY_DELETE_MASK (1 << 1)
+#define NOTIFY_MOVE_MASK (1 << 2)
+#define NOTIFY_MODIFY_MASK (1 << 3)
+
+typedef boost::function<void ()> FdWatchCallBack;
+typedef boost::function<void (const char *)> FileWatchCallBack;
+
+typedef int CompFileWatchHandle;
+typedef int CompWatchFdHandle;
+
+struct CompFileWatch {
+ char *path;
+ int mask;
+ FileWatchCallBack callBack;
+ CompFileWatchHandle handle;
+};
+
/* camera distance from screen, 0.5 * tan (FOV) */
#define DEFAULT_Z_CAMERA 0.866025404f
@@ -75,6 +107,42 @@ struct CompActiveWindowHistory {
class ScreenInterface : public WrapableInterface<CompScreen, ScreenInterface> {
public:
+ virtual void fileWatchAdded (CompFileWatch *fw);
+ virtual void fileWatchRemoved (CompFileWatch *fw);
+
+ virtual bool initPluginForObject (CompPlugin *p, CompObject *o);
+ virtual void finiPluginForObject (CompPlugin *p, CompObject *o);
+
+ virtual bool setOptionForPlugin (CompObject *o, const char *plugin,
+ const char *name,
+ CompOption::Value &v);
+
+ virtual void objectAdd (CompObject *parent, CompObject *child);
+ virtual void objectRemove (CompObject *parent, CompObject *child);
+
+ virtual void sessionEvent (CompSession::Event event,
+ CompOption::Vector &options);
+
+ virtual void handleEvent (XEvent *event);
+ virtual void handleCompizEvent (const char * plugin, const char *event,
+ CompOption::Vector &options);
+
+ virtual bool fileToImage (const char *path, const char *name,
+ int *width, int *height,
+ int *stride, void **data);
+ virtual bool imageToFile (const char *path, const char *name,
+ const char *format, int width, int height,
+ int stride, void *data);
+
+ virtual CompMatch::Expression *matchInitExp (const CompString value);
+
+ virtual void matchExpHandlerChanged ();
+ virtual void matchPropertyChanged (CompWindow *window);
+
+ virtual void logMessage (const char *componentName,
+ CompLogLevel level,
+ const char *message);
+
virtual void enterShowDesktopMode ();
virtual void leaveShowDesktopMode (CompWindow *window);
@@ -83,12 +151,12 @@ class ScreenInterface : public WrapableInterface<CompScreen, ScreenInterface> {
class CompScreen :
- public WrapableHandler<ScreenInterface, 3>,
+ public WrapableHandler<ScreenInterface, 19>,
public CompObject
{
public:
- typedef void* grabHandle;
+ typedef void* GrabHandle;
public:
CompScreen ();
@@ -96,14 +164,128 @@ class CompScreen :
CompString objectName ();
- bool
- init (CompDisplay *, int);
+ bool init (const char *name);
+
+ void eventLoop ();
- bool
- init (CompDisplay *, int, Window, Atom, Time);
+ CompFileWatchHandle addFileWatch (const char *path,
+ int mask,
+ FileWatchCallBack callBack);
+
+ void removeFileWatch (CompFileWatchHandle handle);
+
+ CompWatchFdHandle addWatchFd (int fd,
+ short int events,
+ FdWatchCallBack callBack);
+
+ void removeWatchFd (CompWatchFdHandle handle);
+
+ void storeValue (CompString key, CompPrivate value);
+ bool hasValue (CompString key);
+ CompPrivate getValue (CompString key);
+ void eraseValue (CompString key);
+
+ Display * dpy();
+
+ CompOption * getOption (const char *);
+
+ bool setOption (const char *name,
+ CompOption::Value &value);
+
+ bool XRandr ();
+
+ int randrEvent ();
+
+ bool XShape ();
+
+ int shapeEvent ();
+
+ int syncEvent ();
+
+ SnDisplay * snDisplay ();
+
+ Window activeWindow ();
+
+ Window autoRaiseWindow ();
+
+ const char * displayString ();
+
+ unsigned int lastPing ();
+
+ void updateModifierMappings ();
+
+ unsigned int virtualToRealModMask (unsigned int modMask);
+
+ unsigned int keycodeToModifiers (int keycode);
+
+ CompWindow * findWindow (Window id);
+
+ CompWindow * findTopLevelWindow (Window id,
+ bool override_redirect = false);
+
+ bool readImageFromFile (const char *name,
+ int *width,
+ int *height,
+ void **data);
+
+ bool writeImageToFile (const char *path,
+ const char *name,
+ const char *format,
+ int width,
+ int height,
+ void *data);
+
+ Window getActiveWindow (Window root);
+
+ int getWmState (Window id);
+
+ void setWmState (int state, Window id);
+
+ unsigned int windowStateMask (Atom state);
+
+
+ static unsigned int windowStateFromString (const char *str);
+
+ unsigned int getWindowState (Window id);
+
+ void setWindowState (unsigned int state, Window id);
+
+ unsigned int getWindowType (Window id);
- CompDisplay *
- display ();
+ void getMwmHints (Window id,
+ unsigned int *func,
+ unsigned int *decor);
+
+
+ unsigned int getProtocols (Window id);
+
+
+ unsigned int getWindowProp (Window id,
+ Atom property,
+ unsigned int defaultValue);
+
+
+ void setWindowProp (Window id,
+ Atom property,
+ unsigned int value);
+
+
+ bool readWindowProp32 (Window id,
+ Atom property,
+ unsigned short *returnValue);
+
+
+ unsigned short getWindowProp32 (Window id,
+ Atom property,
+ unsigned short defaultValue);
+
+
+ void setWindowProp32 (Window id,
+ Atom property,
+ unsigned short value);
+
+ void
+ addScreenActions (CompScreen *s);
Window
root ();
@@ -117,25 +299,15 @@ class CompScreen :
CompWindowList &
windows ();
- CompOption *
- getOption (const char *name);
-
unsigned int
showingDesktopMask ();
- bool
- setOption (const char *name,
- CompOption::Value &value);
-
void
setCurrentOutput (unsigned int outputNum);
void
configure (XConfigureEvent *ce);
- bool
- hasGrab ();
-
void
warpPointer (int dx, int dy);
@@ -160,12 +332,6 @@ class CompScreen :
void
focusDefaultWindow ();
- CompWindow *
- findWindow (Window id);
-
- CompWindow *
- findTopLevelWindow (Window id, bool override_redirect = false);
-
void
insertWindow (CompWindow *w, Window aboveId);
@@ -175,14 +341,14 @@ class CompScreen :
void
eraseWindowFromMap (Window id);
- grabHandle
+ GrabHandle
pushGrab (Cursor cursor, const char *name);
void
- updateGrab (grabHandle handle, Cursor cursor);
+ updateGrab (GrabHandle handle, Cursor cursor);
void
- removeGrab (grabHandle handle, CompPoint *restorePointer);
+ removeGrab (GrabHandle handle, CompPoint *restorePointer);
bool
otherGrabExist (const char *, ...);
@@ -194,9 +360,6 @@ class CompScreen :
removeAction (CompAction *action);
void
- updatePassiveGrabs ();
-
- void
updateWorkarea ();
void
@@ -283,8 +446,6 @@ class CompScreen :
unsigned int &
pendingDestroys ();
- void
- removeDestroyed ();
unsigned int &
mapNum ();
@@ -319,54 +480,155 @@ class CompScreen :
CompOutput & fullscreenOutput ();
+ std::vector<XineramaScreenInfo> & screenInfo ();
+
static int allocPrivateIndex ();
static void freePrivateIndex (int index);
- WRAPABLE_HND (0, ScreenInterface, void, enterShowDesktopMode);
- WRAPABLE_HND (1, ScreenInterface, void, leaveShowDesktopMode,
+ WRAPABLE_HND (0, ScreenInterface, void, fileWatchAdded, CompFileWatch *)
+ WRAPABLE_HND (1, ScreenInterface, void, fileWatchRemoved, CompFileWatch *)
+
+ WRAPABLE_HND (2, ScreenInterface, bool, initPluginForObject,
+ CompPlugin *, CompObject *)
+ WRAPABLE_HND (3, ScreenInterface, void, finiPluginForObject,
+ CompPlugin *, CompObject *)
+
+ WRAPABLE_HND (4, ScreenInterface, bool, setOptionForPlugin, CompObject *,
+ const char *, const char *, CompOption::Value &)
+
+ WRAPABLE_HND (5, ScreenInterface, void, objectAdd,
+ CompObject *, CompObject *)
+ WRAPABLE_HND (6, ScreenInterface, void, objectRemove,
+ CompObject *, CompObject *)
+
+ WRAPABLE_HND (7, ScreenInterface, void, sessionEvent, CompSession::Event,
+ CompOption::Vector &)
+ WRAPABLE_HND (8, ScreenInterface, void, handleEvent, XEvent *event)
+ WRAPABLE_HND (9, ScreenInterface, void, handleCompizEvent,
+ const char *, const char *, CompOption::Vector &)
+
+ WRAPABLE_HND (10, ScreenInterface, bool, fileToImage, const char *,
+ const char *, int *, int *, int *, void **data)
+ WRAPABLE_HND (11, ScreenInterface, bool, imageToFile, const char *,
+ const char *, const char *, int, int, int, void *)
+
+
+ WRAPABLE_HND (12, ScreenInterface, CompMatch::Expression *,
+ matchInitExp, const CompString);
+ WRAPABLE_HND (13, ScreenInterface, void, matchExpHandlerChanged)
+ WRAPABLE_HND (14, ScreenInterface, void, matchPropertyChanged,
+ CompWindow *)
+
+ WRAPABLE_HND (15, ScreenInterface, void, logMessage, const char *,
+ CompLogLevel, const char*)
+ WRAPABLE_HND (16, ScreenInterface, void, enterShowDesktopMode);
+ WRAPABLE_HND (17, ScreenInterface, void, leaveShowDesktopMode,
CompWindow *);
- WRAPABLE_HND (2, ScreenInterface, void, outputChangeNotify);
+ WRAPABLE_HND (18, ScreenInterface, void, outputChangeNotify);
+ friend class CompTimer;
+ friend class CompWindow;
+ friend class PrivateWindow;
private:
PrivateScreen *priv;
public :
- static bool
- mainMenu (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool
- runDialog (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool
- showDesktop (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool
- windowMenu (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
+ static bool runCommandDispatch (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool runCommandScreenshot(CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool runCommandWindowScreenshot(CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool runCommandTerminal (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool mainMenu (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool runDialog (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool showDesktop (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool windowMenu (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool closeWin (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool unmaximizeWin (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool minimizeWin (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool maximizeWin (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool maximizeWinHorizontally (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool maximizeWinVertically (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool raiseWin (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool lowerWin (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool toggleWinMaximized (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool toggleWinMaximizedHorizontally (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool toggleWinMaximizedVertically (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+ static bool shadeWin (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options);
+
+
static CompOption::Vector &
- getScreenOptions (CompObject *object);
+ getOptions (CompObject *object);
- static bool setScreenOption (CompObject *object,
- const char *name,
- CompOption::Value &value);
+ static bool setOption (CompObject *object,
+ const char *name,
+ CompOption::Value &value);
static void
compScreenSnEvent (SnMonitorEvent *event,
void *userData);
+
+ static int checkForError (Display *dpy);
};
#endif
diff --git a/include/compwindow.h b/include/compwindow.h
index 519be79..baa0bf9 100644
--- a/include/compwindow.h
+++ b/include/compwindow.h
@@ -656,84 +656,13 @@ class CompWindow :
WRAPABLE_HND (12, WindowInterface, void, updateFrameRegion, Region);
friend class PrivateWindow;
+ friend class CompScreen;
+ friend class PrivateScreen;
private:
PrivateWindow *priv;
- public:
-
- // static action functions
- static bool
- closeWin (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool
- unmaximizeAction (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool
- minimizeAction (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool
- maximizeAction (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool
- maximizeHorizontally (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool
- maximizeVertically (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
- static bool
- raiseInitiate (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
- static bool
- lowerInitiate (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool
- toggleMaximized (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool
- toggleMaximizedHorizontally (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool
- toggleMaximizedVertically (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
- static bool
- shade (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options);
-
};
#endif
diff --git a/include/core/atoms.h b/include/core/atoms.h
new file mode 100644
index 0000000..d6bae16
--- /dev/null
+++ b/include/core/atoms.h
@@ -0,0 +1,135 @@
+#ifndef _ATOMS_H
+#define _ATOMS_H
+
+#include <X11/Xlib-xcb.h>
+
+namespace Atoms {
+ extern Atom supported;
+ extern Atom supportingWmCheck;
+
+ extern Atom utf8String;
+
+ extern Atom wmName;
+
+ extern Atom winType;
+ extern Atom winTypeDesktop;
+ extern Atom winTypeDock;
+ extern Atom winTypeToolbar;
+ extern Atom winTypeMenu;
+ extern Atom winTypeUtil;
+ extern Atom winTypeSplash;
+ extern Atom winTypeDialog;
+ extern Atom winTypeNormal;
+ extern Atom winTypeDropdownMenu;
+ extern Atom winTypePopupMenu;
+ extern Atom winTypeTooltip;
+ extern Atom winTypeNotification;
+ extern Atom winTypeCombo;
+ extern Atom winTypeDnd;
+
+ extern Atom winOpacity;
+ extern Atom winBrightness;
+ extern Atom winSaturation;
+ extern Atom winActive;
+ extern Atom winDesktop;
+
+ extern Atom workarea;
+
+ extern Atom desktopViewport;
+ extern Atom desktopGeometry;
+ extern Atom currentDesktop;
+ extern Atom numberOfDesktops;
+
+ extern Atom winState;
+ extern Atom winStateModal;
+ extern Atom winStateSticky;
+ extern Atom winStateMaximizedVert;
+ extern Atom winStateMaximizedHorz;
+ extern Atom winStateShaded;
+ extern Atom winStateSkipTaskbar;
+ extern Atom winStateSkipPager;
+ extern Atom winStateHidden;
+ extern Atom winStateFullscreen;
+ extern Atom winStateAbove;
+ extern Atom winStateBelow;
+ extern Atom winStateDemandsAttention;
+ extern Atom winStateDisplayModal;
+
+ extern Atom winActionMove;
+ extern Atom winActionResize;
+ extern Atom winActionStick;
+ extern Atom winActionMinimize;
+ extern Atom winActionMaximizeHorz;
+ extern Atom winActionMaximizeVert;
+ extern Atom winActionFullscreen;
+ extern Atom winActionClose;
+ extern Atom winActionShade;
+ extern Atom winActionChangeDesktop;
+ extern Atom winActionAbove;
+ extern Atom winActionBelow;
+
+ extern Atom wmAllowedActions;
+
+ extern Atom wmStrut;
+ extern Atom wmStrutPartial;
+
+ extern Atom wmUserTime;
+
+ extern Atom wmIcon;
+ extern Atom wmIconGeometry;
+
+ extern Atom clientList;
+ extern Atom clientListStacking;
+
+ extern Atom frameExtents;
+ extern Atom frameWindow;
+
+ extern Atom wmState;
+ extern Atom wmChangeState;
+ extern Atom wmProtocols;
+ extern Atom wmClientLeader;
+
+ extern Atom wmDeleteWindow;
+ extern Atom wmTakeFocus;
+ extern Atom wmPing;
+ extern Atom wmSyncRequest;
+
+ extern Atom wmSyncRequestCounter;
+
+ extern Atom closeWindow;
+ extern Atom wmMoveResize;
+ extern Atom moveResizeWindow;
+ extern Atom restackWindow;
+
+ extern Atom showingDesktop;
+
+ extern Atom xBackground[2];
+
+ extern Atom toolkitAction;
+ extern Atom toolkitActionMainMenu;
+ extern Atom toolkitActionRunDialog;
+ extern Atom toolkitActionWindowMenu;
+ extern Atom toolkitActionForceQuitDialog;
+
+ extern Atom mwmHints;
+
+ extern Atom xdndAware;
+ extern Atom xdndEnter;
+ extern Atom xdndLeave;
+ extern Atom xdndPosition;
+ extern Atom xdndStatus;
+ extern Atom xdndDrop;
+
+ extern Atom manager;
+ extern Atom targets;
+ extern Atom multiple;
+ extern Atom timestamp;
+ extern Atom version;
+ extern Atom atomPair;
+
+ extern Atom startupId;
+
+ void init (Display *dpy);
+};
+
+#endif
diff --git a/include/core/timer.h b/include/core/timer.h
new file mode 100644
index 0000000..aff7bc3
--- /dev/null
+++ b/include/core/timer.h
@@ -0,0 +1,42 @@
+#ifndef _TIMER_H
+#define _TIMER_H
+
+#include <boost/function.hpp>
+
+class CompTimer {
+
+ public:
+
+ typedef boost::function<bool ()> CallBack;
+
+ CompTimer ();
+ ~CompTimer ();
+
+ bool active ();
+ unsigned int minTime ();
+ unsigned int maxTime ();
+ unsigned int minLeft ();
+ unsigned int maxLeft ();
+
+ void setTimes (unsigned int min, unsigned int max = 0);
+ void setCallback (CallBack callback);
+
+ void start ();
+ void start (unsigned int min, unsigned int max = 0);
+ void start (CallBack callback,
+ unsigned int min, unsigned int max = 0);
+ void stop ();
+
+ friend class CompScreen;
+ friend class PrivateScreen;
+
+ private:
+ bool mActive;
+ unsigned int mMinTime;
+ unsigned int mMaxTime;
+ int mMinLeft;
+ int mMaxLeft;
+ CallBack mCallBack;
+};
+
+#endif
diff --git a/metadata/core.xml.in b/metadata/core.xml.in
index 61c0947..ef4488e 100644
--- a/metadata/core.xml.in
+++ b/metadata/core.xml.in
@@ -2,7 +2,7 @@
<core>
<_short>General Options</_short>
<_long>General compiz options</_long>
- <display>
+ <options>
<option name="active_plugins" type="list">
<_short>Active Plugins</_short>
<_long>List of currently active plugins</_long>
@@ -304,8 +304,6 @@
<min>1000</min>
<max>30000</max>
</option>
- </display>
- <screen>
<option name="hsize" type="int">
<_short>Horizontal Virtual Size</_short>
<_long>Screen size multiplier for horizontal virtual size</_long>
@@ -392,6 +390,6 @@
<_long>Focus prevention windows</_long>
<default>any</default>
</option>
- </screen>
+ </options>
</core>
</compiz>
diff --git a/src/Makefile.am b/src/Makefile.am
index 715647d..5c405c8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,7 +12,10 @@ bin_PROGRAMS = compiz
compiz_LDADD = @COMPIZ_LIBS@ @GL_LIBS@ -lm
compiz_LDFLAGS = -export-dynamic
compiz_SOURCES = \
- display.cpp \
+ atoms.cpp \
+ timer.cpp \
+ main.cpp \
+ actions.cpp \
screen.cpp \
window.cpp \
metadata.cpp \
@@ -20,9 +23,7 @@ compiz_SOURCES = \
option.cpp \
string.cpp \
match.cpp \
- main.cpp \
object.cpp \
- core.cpp \
event.cpp \
plugin.cpp \
session.cpp \
diff --git a/src/action.cpp b/src/action.cpp
index e456bda..2415c38 100644
--- a/src/action.cpp
+++ b/src/action.cpp
@@ -32,7 +32,6 @@
#include <compoption.h>
#include <compaction.h>
#include <compscreen.h>
-#include <compdisplay.h>
#include <privateaction.h>
struct _Modifier {
@@ -70,8 +69,7 @@ struct _Edge {
};
static CompString
-modifiersToString (CompDisplay *d,
- unsigned int modMask)
+modifiersToString (unsigned int modMask)
{
CompString binding = "";
@@ -85,8 +83,7 @@ modifiersToString (CompDisplay *d,
}
static unsigned int
-stringToModifiers (CompDisplay *d,
- CompString str)
+stringToModifiers (CompString str)
{
unsigned int mods = 0;
@@ -100,8 +97,7 @@ stringToModifiers (CompDisplay *d,
}
static unsigned int
-bindingStringToEdgeMask (CompDisplay *d,
- CompString str)
+bindingStringToEdgeMask (CompString str)
{
unsigned int edgeMask = 0;
@@ -113,8 +109,7 @@ bindingStringToEdgeMask (CompDisplay *d,
}
static CompString
-edgeMaskToBindingString (CompDisplay *d,
- unsigned int edgeMask)
+edgeMaskToBindingString (unsigned int edgeMask)
{
CompString binding = "";
int i;
@@ -151,14 +146,17 @@ CompAction::KeyBinding::keycode ()
}
bool
-CompAction::KeyBinding::fromString (CompDisplay *d, const CompString str)
+CompAction::KeyBinding::fromString (const CompString str)
{
CompString sStr;
unsigned int mods;
size_t pos;
KeySym keysym;
- mods = stringToModifiers (d, str);
+ if (!screen)
+ return false;
+
+ mods = stringToModifiers (str);
pos = str.rfind ('>');
if (pos != std::string::npos)
@@ -186,7 +184,7 @@ CompAction::KeyBinding::fromString (CompDisplay *d, const CompString str)
{
KeyCode keycode;
- keycode = XKeysymToKeycode (d->dpy (), keysym);
+ keycode = XKeysymToKeycode (screen->dpy (), keysym);
if (keycode)
{
mKeycode = keycode;
@@ -208,18 +206,21 @@ CompAction::KeyBinding::fromString (CompDisplay *d, const CompString str)
}
CompString
-CompAction::KeyBinding::toString (CompDisplay *d)
+CompAction::KeyBinding::toString ()
{
CompString binding = "";
- binding = modifiersToString (d, mModifiers);
+ if (!screen)
+ return "";
+
+ binding = modifiersToString (mModifiers);
if (mKeycode != 0)
{
KeySym keysym;
char *keyname;
- keysym = XKeycodeToKeysym (d->dpy (), mKeycode, 0);
+ keysym = XKeycodeToKeysym (screen->dpy (), mKeycode, 0);
keyname = XKeysymToString (keysym);
if (keyname)
@@ -260,12 +261,12 @@ CompAction::ButtonBinding::button ()
}
bool
-CompAction::ButtonBinding::fromString (CompDisplay *d, const CompString str)
+CompAction::ButtonBinding::fromString (const CompString str)
{
unsigned int mods;
size_t pos;
- mods = stringToModifiers (d, str);
+ mods = stringToModifiers (str);
pos = str.rfind ('>');
if (pos != std::string::npos)
@@ -292,14 +293,14 @@ CompAction::ButtonBinding::fromString (CompDisplay *d, const CompString str)
}
CompString
-CompAction::ButtonBinding::toString (CompDisplay *d)
+CompAction::ButtonBinding::toString ()
{
CompString binding;
if (!mModifiers && !mButton)
return "";
- binding = modifiersToString (d, mModifiers);
+ binding = modifiersToString (mModifiers);
binding += compPrintf ("Button%d", mButton);
return binding;
@@ -441,20 +442,20 @@ CompAction::operator= (const CompAction &action)
}
void
-CompAction::keyFromString (CompDisplay *d, const CompString str)
+CompAction::keyFromString (const CompString str)
{
- if (priv->key.fromString (d, str))
+ if (priv->key.fromString (str))
priv->type = CompAction::BindingTypeKey;
else
priv->type = CompAction::BindingTypeNone;
}
void
-CompAction::buttonFromString (CompDisplay *d, const CompString str)
+CompAction::buttonFromString (const CompString str)
{
- if (priv->button.fromString (d, str))
+ if (priv->button.fromString (str))
{
- priv->edgeMask = bindingStringToEdgeMask (d, str);
+ priv->edgeMask = bindingStringToEdgeMask (str);
if (priv->edgeMask)
priv->type = CompAction::BindingTypeEdgeButton;
else
@@ -496,11 +497,11 @@ CompAction::edgeMaskFromString (const CompString str)
}
CompString
-CompAction::keyToString (CompDisplay *d)
+CompAction::keyToString ()
{
CompString binding;
- binding = priv->key.toString (d);
+ binding = priv->key.toString ();
if (binding.size () == 0)
return "Disabled";
@@ -508,12 +509,12 @@ CompAction::keyToString (CompDisplay *d)
}
CompString
-CompAction::buttonToString (CompDisplay *d)
+CompAction::buttonToString ()
{
CompString binding = "", edge = "";
- binding = modifiersToString (d, priv->button.modifiers ());
- binding += edgeMaskToBindingString (d, priv->edgeMask);
+ binding = modifiersToString (priv->button.modifiers ());
+ binding += edgeMaskToBindingString (priv->edgeMask);
binding += compPrintf ("Button%d", priv->button.button ());
diff --git a/src/actions.cpp b/src/actions.cpp
new file mode 100644
index 0000000..c4d12e9
--- /dev/null
+++ b/src/actions.cpp
@@ -0,0 +1,353 @@
+#include <compscreen.h>
+#include <compwindow.h>
+#include <core/atoms.h>
+#include "privatescreen.h"
+#include "privatewindow.h"
+
+bool
+CompScreen::closeWin (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+ unsigned int time;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+ time = CompOption::getIntOptionNamed (options, "time", CurrentTime);
+
+ w = screen->findTopLevelWindow (xid);
+ if (w && (w->priv->actions & CompWindowActionCloseMask))
+ w->close (time);
+
+ return true;
+}
+
+bool
+CompScreen::mainMenu (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ unsigned int time;
+
+ time = CompOption::getIntOptionNamed (options, "time", CurrentTime);
+
+ if (screen->priv->grabs.empty ())
+ screen->toolkitAction (Atoms::toolkitActionMainMenu, time,
+ screen->priv->root, 0, 0, 0);
+
+ return true;
+}
+
+bool
+CompScreen::runDialog (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ unsigned int time;
+
+ time = CompOption::getIntOptionNamed (options, "time", CurrentTime);
+
+ if (screen->priv->grabs.empty ())
+ screen->toolkitAction (Atoms::toolkitActionRunDialog, time,
+ screen->priv->root , 0, 0, 0);
+
+ return true;
+}
+
+bool
+CompScreen::unmaximizeWin (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+
+ w = screen->findTopLevelWindow (xid);
+ if (w)
+ w->maximize (0);
+
+ return true;
+}
+
+bool
+CompScreen::minimizeWin (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+
+ w = screen->findTopLevelWindow (xid);
+ if (w && (w->actions () & CompWindowActionMinimizeMask))
+ w->minimize ();
+
+ return true;
+}
+
+bool
+CompScreen::maximizeWin (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+
+ w = screen->findTopLevelWindow (xid);
+ if (w)
+ w->maximize (MAXIMIZE_STATE);
+
+ return true;
+}
+
+bool
+CompScreen::maximizeWinHorizontally (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+
+ w = screen->findTopLevelWindow (xid);
+ if (w)
+ w->maximize (w->state () | CompWindowStateMaximizedHorzMask);
+
+ return true;
+}
+
+bool
+CompScreen::maximizeWinVertically (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+
+ w = screen->findTopLevelWindow (xid);
+ if (w)
+ w->maximize (w->state () | CompWindowStateMaximizedVertMask);
+
+ return true;
+}
+
+bool
+CompScreen::showDesktop (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ if (screen->priv->showingDesktopMask == 0)
+ screen->enterShowDesktopMode ();
+ else
+ screen->leaveShowDesktopMode (NULL);
+
+ return true;
+}
+
+bool
+CompScreen::raiseWin (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+
+ w = screen->findTopLevelWindow (xid);
+ if (w)
+ w->raise ();
+
+ return true;
+}
+
+bool
+CompScreen::lowerWin (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+
+ w = screen->findTopLevelWindow (xid);
+ if (w)
+ w->lower ();
+
+ return true;
+}
+
+bool
+CompScreen::runCommandDispatch (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ int index = -1;
+ int i = COMP_OPTION_RUN_COMMAND0_KEY;
+
+ while (i <= COMP_OPTION_RUN_COMMAND11_KEY)
+ {
+ if (action == &screen->priv->opt[i].value ().action ())
+ {
+ index = i - COMP_OPTION_RUN_COMMAND0_KEY +
+ COMP_OPTION_COMMAND0;
+ break;
+ }
+
+ i++;
+ }
+
+ if (index > 0)
+ screen->runCommand (screen->priv->opt[index].value ().s ());
+
+ return true;
+}
+
+bool
+CompScreen::runCommandScreenshot (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ screen->runCommand (
+ screen->priv->opt[COMP_OPTION_SCREENSHOT].value ().s ());
+
+ return true;
+}
+
+bool
+CompScreen::runCommandWindowScreenshot (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ screen->runCommand (
+ screen->priv->opt[COMP_OPTION_WINDOW_SCREENSHOT].value ().s ());
+
+ return true;
+}
+
+bool
+CompScreen::runCommandTerminal (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ screen->runCommand (
+ screen->priv->opt[COMP_OPTION_TERMINAL].value ().s ());
+
+ return true;
+}
+
+bool
+CompScreen::windowMenu (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+
+ w = screen->findTopLevelWindow (xid);
+ if (w && screen->priv->grabs.empty ())
+ {
+ int x, y, button;
+ Time time;
+
+ time = CompOption::getIntOptionNamed (options, "time", CurrentTime);
+ button = CompOption::getIntOptionNamed (options, "button", 0);
+ x = CompOption::getIntOptionNamed (options, "x",
+ w->geometry ().x ());
+ y = CompOption::getIntOptionNamed (options, "y",
+ w->geometry ().y ());
+
+ screen->toolkitAction (Atoms::toolkitActionWindowMenu,
+ time, w->id (), button, x, y);
+ }
+
+ return true;
+}
+
+bool
+CompScreen::toggleWinMaximized (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+
+ w = screen->findTopLevelWindow (xid);
+ if (w)
+ {
+ if ((w->priv->state & MAXIMIZE_STATE) == MAXIMIZE_STATE)
+ w->maximize (0);
+ else
+ w->maximize (MAXIMIZE_STATE);
+ }
+
+ return true;
+}
+
+bool
+CompScreen::toggleWinMaximizedHorizontally (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+
+ w = screen->findTopLevelWindow (xid);
+ if (w)
+ w->maximize (w->priv->state ^ CompWindowStateMaximizedHorzMask);
+
+ return true;
+}
+
+bool
+CompScreen::toggleWinMaximizedVertically (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+
+ w = screen->findTopLevelWindow (xid);
+ if (w)
+ w->maximize (w->priv->state ^ CompWindowStateMaximizedVertMask);
+
+ return true;
+}
+
+bool
+CompScreen::shadeWin (CompAction *action,
+ CompAction::State state,
+ CompOption::Vector &options)
+{
+ CompWindow *w;
+ Window xid;
+
+ xid = CompOption::getIntOptionNamed (options, "window");
+
+ w = screen->findTopLevelWindow (xid);
+ if (w && (w->priv->actions & CompWindowActionShadeMask))
+ {
+ w->priv->state ^= CompWindowStateShadedMask;
+ w->updateAttributes (CompStackingUpdateModeNone);
+ }
+
+ return true;
+}
diff --git a/src/atoms.cpp b/src/atoms.cpp
new file mode 100644
index 0000000..3d52ad5
--- /dev/null
+++ b/src/atoms.cpp
@@ -0,0 +1,299 @@
+
+#include <core/atoms.h>
+
+namespace Atoms {
+ Atom supported;
+ Atom supportingWmCheck;
+
+ Atom utf8String;
+
+ Atom wmName;
+
+ Atom winType;
+ Atom winTypeDesktop;
+ Atom winTypeDock;
+ Atom winTypeToolbar;
+ Atom winTypeMenu;
+ Atom winTypeUtil;
+ Atom winTypeSplash;
+ Atom winTypeDialog;
+ Atom winTypeNormal;
+ Atom winTypeDropdownMenu;
+ Atom winTypePopupMenu;
+ Atom winTypeTooltip;
+ Atom winTypeNotification;
+ Atom winTypeCombo;
+ Atom winTypeDnd;
+
+ Atom winOpacity;
+ Atom winBrightness;
+ Atom winSaturation;
+ Atom winActive;
+ Atom winDesktop;
+
+ Atom workarea;
+
+ Atom desktopViewport;
+ Atom desktopGeometry;
+ Atom currentDesktop;
+ Atom numberOfDesktops;
+
+ Atom winState;
+ Atom winStateModal;
+ Atom winStateSticky;
+ Atom winStateMaximizedVert;
+ Atom winStateMaximizedHorz;
+ Atom winStateShaded;
+ Atom winStateSkipTaskbar;
+ Atom winStateSkipPager;
+ Atom winStateHidden;
+ Atom winStateFullscreen;
+ Atom winStateAbove;
+ Atom winStateBelow;
+ Atom winStateDemandsAttention;
+ Atom winStateDisplayModal;
+
+ Atom winActionMove;
+ Atom winActionResize;
+ Atom winActionStick;
+ Atom winActionMinimize;
+ Atom winActionMaximizeHorz;
+ Atom winActionMaximizeVert;
+ Atom winActionFullscreen;
+ Atom winActionClose;
+ Atom winActionShade;
+ Atom winActionChangeDesktop;
+ Atom winActionAbove;
+ Atom winActionBelow;
+
+ Atom wmAllowedActions;
+
+ Atom wmStrut;
+ Atom wmStrutPartial;
+
+ Atom wmUserTime;
+
+ Atom wmIcon;
+ Atom wmIconGeometry;
+
+ Atom clientList;
+ Atom clientListStacking;
+
+ Atom frameExtents;
+ Atom frameWindow;
+
+ Atom wmState;
+ Atom wmChangeState;
+ Atom wmProtocols;
+ Atom wmClientLeader;
+
+ Atom wmDeleteWindow;
+ Atom wmTakeFocus;
+ Atom wmPing;
+ Atom wmSyncRequest;
+
+ Atom wmSyncRequestCounter;
+
+ Atom closeWindow;
+ Atom wmMoveResize;
+ Atom moveResizeWindow;
+ Atom restackWindow;
+
+ Atom showingDesktop;
+
+ Atom xBackground[2];
+
+ Atom toolkitAction;
+ Atom toolkitActionMainMenu;
+ Atom toolkitActionRunDialog;
+ Atom toolkitActionWindowMenu;
+ Atom toolkitActionForceQuitDialog;
+
+ Atom mwmHints;
+
+ Atom xdndAware;
+ Atom xdndEnter;
+ Atom xdndLeave;
+ Atom xdndPosition;
+ Atom xdndStatus;
+ Atom xdndDrop;
+
+ Atom manager;
+ Atom targets;
+ Atom multiple;
+ Atom timestamp;
+ Atom version;
+ Atom atomPair;
+
+ Atom startupId;
+
+ void init (Display *dpy)
+ {
+ supported = XInternAtom (dpy, "_NET_SUPPORTED", 0);
+ supportingWmCheck = XInternAtom (dpy, "_NET_SUPPORTING_WM_CHECK", 0);
+
+ utf8String = XInternAtom (dpy, "UTF8_STRING", 0);
+
+ wmName = XInternAtom (dpy, "_NET_WM_NAME", 0);
+
+ winType = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE", 0);
+ winTypeDesktop = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DESKTOP",
+ 0);
+ winTypeDock = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DOCK", 0);
+ winTypeToolbar = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_TOOLBAR",
+ 0);
+ winTypeMenu = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_MENU", 0);
+ winTypeUtil = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_UTILITY",
+ 0);
+ winTypeSplash = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_SPLASH", 0);
+ winTypeDialog = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DIALOG", 0);
+ winTypeNormal = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_NORMAL", 0);
+
+ winTypeDropdownMenu =
+ XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", 0);
+ winTypePopupMenu =
+ XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_POPUP_MENU", 0);
+ winTypeTooltip =
+ XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_TOOLTIP", 0);
+ winTypeNotification =
+ XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_NOTIFICATION", 0);
+ winTypeCombo =
+ XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_COMBO", 0);
+ winTypeDnd =
+ XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DND", 0);
+
+ winOpacity = XInternAtom (dpy, "_NET_WM_WINDOW_OPACITY", 0);
+ winBrightness = XInternAtom (dpy, "_NET_WM_WINDOW_BRIGHTNESS", 0);
+ winSaturation = XInternAtom (dpy, "_NET_WM_WINDOW_SATURATION", 0);
+
+ winActive = XInternAtom (dpy, "_NET_ACTIVE_WINDOW", 0);
+ winDesktop = XInternAtom (dpy, "_NET_WM_DESKTOP", 0);
+ workarea = XInternAtom (dpy, "_NET_WORKAREA", 0);
+
+ desktopViewport = XInternAtom (dpy, "_NET_DESKTOP_VIEWPORT", 0);
+ desktopGeometry = XInternAtom (dpy, "_NET_DESKTOP_GEOMETRY", 0);
+ currentDesktop = XInternAtom (dpy, "_NET_CURRENT_DESKTOP", 0);
+ numberOfDesktops = XInternAtom (dpy, "_NET_NUMBER_OF_DESKTOPS", 0);
+
+ winState = XInternAtom (dpy, "_NET_WM_STATE", 0);
+ winStateModal =
+ XInternAtom (dpy, "_NET_WM_STATE_MODAL", 0);
+ winStateSticky =
+ XInternAtom (dpy, "_NET_WM_STATE_STICKY", 0);
+ winStateMaximizedVert =
+ XInternAtom (dpy, "_NET_WM_STATE_MAXIMIZED_VERT", 0);
+ winStateMaximizedHorz =
+ XInternAtom (dpy, "_NET_WM_STATE_MAXIMIZED_HORZ", 0);
+ winStateShaded =
+ XInternAtom (dpy, "_NET_WM_STATE_SHADED", 0);
+ winStateSkipTaskbar =
+ XInternAtom (dpy, "_NET_WM_STATE_SKIP_TASKBAR", 0);
+ winStateSkipPager =
+ XInternAtom (dpy, "_NET_WM_STATE_SKIP_PAGER", 0);
+ winStateHidden =
+ XInternAtom (dpy, "_NET_WM_STATE_HIDDEN", 0);
+ winStateFullscreen =
+ XInternAtom (dpy, "_NET_WM_STATE_FULLSCREEN", 0);
+ winStateAbove =
+ XInternAtom (dpy, "_NET_WM_STATE_ABOVE", 0);
+ winStateBelow =
+ XInternAtom (dpy, "_NET_WM_STATE_BELOW", 0);
+ winStateDemandsAttention =
+ XInternAtom (dpy, "_NET_WM_STATE_DEMANDS_ATTENTION", 0);
+ winStateDisplayModal =
+ XInternAtom (dpy, "_NET_WM_STATE_DISPLAY_MODAL", 0);
+
+ winActionMove = XInternAtom (dpy, "_NET_WM_ACTION_MOVE", 0);
+ winActionResize =
+ XInternAtom (dpy, "_NET_WM_ACTION_RESIZE", 0);
+ winActionStick =
+ XInternAtom (dpy, "_NET_WM_ACTION_STICK", 0);
+ winActionMinimize =
+ XInternAtom (dpy, "_NET_WM_ACTION_MINIMIZE", 0);
+ winActionMaximizeHorz =
+ XInternAtom (dpy, "_NET_WM_ACTION_MAXIMIZE_HORZ", 0);
+ winActionMaximizeVert =
+ XInternAtom (dpy, "_NET_WM_ACTION_MAXIMIZE_VERT", 0);
+ winActionFullscreen =
+ XInternAtom (dpy, "_NET_WM_ACTION_FULLSCREEN", 0);
+ winActionClose =
+ XInternAtom (dpy, "_NET_WM_ACTION_CLOSE", 0);
+ winActionShade =
+ XInternAtom (dpy, "_NET_WM_ACTION_SHADE", 0);
+ winActionChangeDesktop =
+ XInternAtom (dpy, "_NET_WM_ACTION_CHANGE_DESKTOP", 0);
+ winActionAbove =
+ XInternAtom (dpy, "_NET_WM_ACTION_ABOVE", 0);
+ winActionBelow =
+ XInternAtom (dpy, "_NET_WM_ACTION_BELOW", 0);
+
+ wmAllowedActions = XInternAtom (dpy, "_NET_WM_ALLOWED_ACTIONS", 0);
+
+ wmStrut = XInternAtom (dpy, "_NET_WM_STRUT", 0);
+ wmStrutPartial = XInternAtom (dpy, "_NET_WM_STRUT_PARTIAL", 0);
+
+ wmUserTime = XInternAtom (dpy, "_NET_WM_USER_TIME", 0);
+
+ wmIcon = XInternAtom (dpy,"_NET_WM_ICON", 0);
+ wmIconGeometry = XInternAtom (dpy, "_NET_WM_ICON_GEOMETRY", 0);
+
+ clientList = XInternAtom (dpy, "_NET_CLIENT_LIST", 0);
+ clientListStacking =
+ XInternAtom (dpy, "_NET_CLIENT_LIST_STACKING", 0);
+
+ frameExtents = XInternAtom (dpy, "_NET_FRAME_EXTENTS", 0);
+ frameWindow = XInternAtom (dpy, "_NET_FRAME_WINDOW", 0);
+
+ wmState = XInternAtom (dpy, "WM_STATE", 0);
+ wmChangeState = XInternAtom (dpy, "WM_CHANGE_STATE", 0);
+ wmProtocols = XInternAtom (dpy, "WM_PROTOCOLS", 0);
+ wmClientLeader = XInternAtom (dpy, "WM_CLIENT_LEADER", 0);
+
+ wmDeleteWindow = XInternAtom (dpy, "WM_DELETE_WINDOW", 0);
+ wmTakeFocus = XInternAtom (dpy, "WM_TAKE_FOCUS", 0);
+ wmPing = XInternAtom (dpy, "_NET_WM_PING", 0);
+ wmSyncRequest = XInternAtom (dpy, "_NET_WM_SYNC_REQUEST", 0);
+
+ wmSyncRequestCounter =
+ XInternAtom (dpy, "_NET_WM_SYNC_REQUEST_COUNTER", 0);
+
+ closeWindow = XInternAtom (dpy, "_NET_CLOSE_WINDOW", 0);
+ wmMoveResize = XInternAtom (dpy, "_NET_WM_MOVERESIZE", 0);
+ moveResizeWindow = XInternAtom (dpy, "_NET_MOVERESIZE_WINDOW", 0);
+ restackWindow = XInternAtom (dpy, "_NET_RESTACK_WINDOW", 0);
+
+ showingDesktop = XInternAtom (dpy, "_NET_SHOWING_DESKTOP", 0);
+
+ xBackground[0] = XInternAtom (dpy, "_XSETROOT_ID", 0);
+ xBackground[1] = XInternAtom (dpy, "_XROOTPMAP_ID", 0);
+
+ toolkitAction =
+ XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION", 0);
+ toolkitActionMainMenu =
+ XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_MAIN_MENU", 0);
+ toolkitActionRunDialog =
+ XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_RUN_DIALOG", 0);
+ toolkitActionWindowMenu =
+ XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_WINDOW_MENU", 0);
+ toolkitActionForceQuitDialog =
+ XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_FORCE_QUIT_DIALOG", 0);
+
+ mwmHints = XInternAtom (dpy, "_MOTIF_WM_HINTS", 0);
+
+ xdndAware = XInternAtom (dpy, "XdndAware", 0);
+ xdndEnter = XInternAtom (dpy, "XdndEnter", 0);
+ xdndLeave = XInternAtom (dpy, "XdndLeave", 0);
+ xdndPosition = XInternAtom (dpy, "XdndPosition", 0);
+ xdndStatus = XInternAtom (dpy, "XdndStatus", 0);
+ xdndDrop = XInternAtom (dpy, "XdndDrop", 0);
+
+ manager = XInternAtom (dpy, "MANAGER", 0);
+ targets = XInternAtom (dpy, "TARGETS", 0);
+ multiple = XInternAtom (dpy, "MULTIPLE", 0);
+ timestamp = XInternAtom (dpy, "TIMESTAMP", 0);
+ version = XInternAtom (dpy, "VERSION", 0);
+ atomPair = XInternAtom (dpy, "ATOM_PAIR", 0);
+
+ startupId = XInternAtom (dpy, "_NET_STARTUP_ID", 0);
+ }
+};
diff --git a/src/core.cpp b/src/core.cpp
deleted file mode 100644
index ccd14f1..0000000
--- a/src/core.cpp
+++ /dev/null
@@ -1,681 +0,0 @@
-/*
- * Copyright © 2007 Novell, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Novell, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * Novell, Inc. makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: David Reveman <davidr@novell.com>
- */
-
-#include <string.h>
-#include <sys/poll.h>
-#include <sys/time.h>
-#include <assert.h>
-#include <algorithm>
-
-#include <boost/foreach.hpp>
-#define foreach BOOST_FOREACH
-
-#include <compiz-core.h>
-#include <compplugin.h>
-#include <compdisplay.h>
-#include "privatecore.h"
-
-CompCore *core;
-
-CompObject::indices corePrivateIndices (0);
-
-int
-CompCore::allocPrivateIndex ()
-{
- return CompObject::allocatePrivateIndex (COMP_OBJECT_TYPE_CORE,
- &corePrivateIndices);
-}
-
-void
-CompCore::freePrivateIndex (int index)
-{
- CompObject::freePrivateIndex (COMP_OBJECT_TYPE_CORE,
- &corePrivateIndices, index);
-}
-
-#define TIMEVALDIFF(tv1, tv2) \
- ((tv1)->tv_sec == (tv2)->tv_sec || (tv1)->tv_usec >= (tv2)->tv_usec) ? \
- ((((tv1)->tv_sec - (tv2)->tv_sec) * 1000000) + \
- ((tv1)->tv_usec - (tv2)->tv_usec)) / 1000 : \
- ((((tv1)->tv_sec - 1 - (tv2)->tv_sec) * 1000000) + \
- (1000000 + (tv1)->tv_usec - (tv2)->tv_usec)) / 1000
-
-CompCore::CompCore () :
- CompObject (COMP_OBJECT_TYPE_CORE, "core")
-{
- priv = new PrivateCore (this);
- assert (priv);
-}
-
-bool
-CompCore::init ()
-{
- CompPlugin *corePlugin = CompPlugin::load ("core");
- if (!corePlugin)
- {
- compLogMessage (0, "core", CompLogLevelFatal,
- "Couldn't load core plugin");
- return false;
- }
-
- if (!CompPlugin::push (corePlugin))
- {
- compLogMessage (0, "core", CompLogLevelFatal,
- "Couldn't activate core plugin");
- return false;
- }
-
- CompPrivate p;
- p.uval = CORE_ABIVERSION;
- storeValue ("core_ABI", p);
-
- return true;
-}
-
-CompCore::~CompCore ()
-{
- CompPlugin *p;
-
- while (!priv->displays.empty ())
- removeDisplay (priv->displays.front ());
-
- if (priv->watchPollFds)
- free (priv->watchPollFds);
-
- while ((p = CompPlugin::pop ()))
- CompPlugin::unload (p);
-
- delete priv;
-}
-
-CompString
-CompCore::objectName ()
-{
- return CompString ("");
-}
-
-
-CompDisplayList &
-CompCore::displays()
-{
- return priv->displays;
-}
-
-bool
-CompCore::addDisplay (const char *name)
-{
- CompDisplay *d = new CompDisplay();
-
- if (!d)
- return false;
-
- priv->displays.push_back (d);
-
- if (!d->init (name))
- {
- priv->displays.pop_back ();
- delete d;
- return false;
- }
- return true;
-}
-
-void
-CompCore::removeDisplay (CompDisplay *d)
-{
- CompDisplayList::iterator it;
- it = std::find (priv->displays.begin (), priv->displays.end (), d);
- priv->displays.erase (it);
-
- delete d;
-}
-
-void
-CompCore::eventLoop ()
-{
- struct timeval tv;
- CompCore::Timer *t;
- int time;
-
- foreach (CompDisplay *d, priv->displays)
- d->setWatchFdHandle (addWatchFd (ConnectionNumber (d->dpy()),
- POLLIN, NULL));
-
- for (;;)
- {
- if (restartSignal || shutDown)
- break;
-
- foreach (CompDisplay *d, priv->displays)
- d->processEvents ();
-
- if (!priv->timers.empty())
- {
- gettimeofday (&tv, 0);
- priv->handleTimers (&tv);
-
- if (priv->timers.front()->mMinLeft > 0)
- {
- std::list<CompCore::Timer *>::iterator it = priv->timers.begin();
-
- t = (*it);
- time = t->mMaxLeft;
- while (it != priv->timers.end())
- {
- t = (*it);
- if (t->mMinLeft <= time)
- break;
- if (t->mMaxLeft < time)
- time = t->mMaxLeft;
- it++;
- }
- priv->doPoll (time);
- gettimeofday (&tv, 0);
- priv->handleTimers (&tv);
- }
- }
- else
- {
- priv->doPoll (-1);
- }
- }
-
- foreach (CompDisplay *d, priv->displays)
- removeWatchFd (d->getWatchFdHandle());
-}
-
-
-
-CompFileWatchHandle
-CompCore::addFileWatch (const char *path,
- int mask,
- FileWatchCallBack callBack)
-{
- CompFileWatch *fileWatch = new CompFileWatch();
- if (!fileWatch)
- return 0;
-
- fileWatch->path = strdup (path);
- fileWatch->mask = mask;
- fileWatch->callBack = callBack;
- fileWatch->handle = priv->lastFileWatchHandle++;
-
- if (priv->lastFileWatchHandle == MAXSHORT)
- priv->lastFileWatchHandle = 1;
-
- priv->fileWatch.push_front(fileWatch);
-
- fileWatchAdded (fileWatch);
-
- return fileWatch->handle;
-}
-
-void
-CompCore::removeFileWatch (CompFileWatchHandle handle)
-{
- std::list<CompFileWatch *>::iterator it;
- CompFileWatch *w;
-
- for (it = priv->fileWatch.begin(); it != priv->fileWatch.end(); it++)
- if ((*it)->handle == handle)
- break;
-
- if (it == priv->fileWatch.end())
- return;
-
- w = (*it);
- priv->fileWatch.erase (it);
-
- fileWatchRemoved (w);
-
- delete w;
-}
-
-void
-PrivateCore::addTimer (CompCore::Timer *timer)
-{
- std::list<CompCore::Timer *>::iterator it;
-
- it = std::find (timers.begin (), timers.end (), timer);
-
- if (it != timers.end ())
- return;
-
- for (it = timers.begin(); it != timers.end(); it++)
- {
- if ((int) timer->mMinTime < (*it)->mMinLeft)
- break;
- }
-
- timer->mMinLeft = timer->mMinTime;
- timer->mMaxLeft = timer->mMaxTime;
-
- timers.insert (it, timer);
-}
-
-void
-PrivateCore::removeTimer (CompCore::Timer *timer)
-{
- std::list<CompCore::Timer *>::iterator it;
-
- it = std::find (timers.begin (), timers.end (), timer);
-
- if (it == timers.end ())
- return;
-
- timers.erase (it);
-}
-
-CompWatchFdHandle
-CompCore::addWatchFd (int fd,
- short int events,
- FdWatchCallBack callBack)
-{
- CompWatchFd *watchFd = new CompWatchFd();
-
- if (!watchFd)
- return 0;
-
- watchFd->fd = fd;
- watchFd->callBack = callBack;
- watchFd->handle = priv->lastWatchFdHandle++;
-
- if (priv->lastWatchFdHandle == MAXSHORT)
- priv->lastWatchFdHandle = 1;
-
- priv->watchFds.push_front (watchFd);
-
- priv->nWatchFds++;
-
- priv->watchPollFds = (struct pollfd *) realloc (priv->watchPollFds,
- priv->nWatchFds * sizeof (struct pollfd));
-
- priv->watchPollFds[priv->nWatchFds - 1].fd = fd;
- priv->watchPollFds[priv->nWatchFds - 1].events = events;
-
- return watchFd->handle;
-}
-
-void
-CompCore::removeWatchFd (CompWatchFdHandle handle)
-{
- std::list<CompWatchFd *>::iterator it;
- CompWatchFd *w;
- int i;
-
- for (it = priv->watchFds.begin(), i = priv->nWatchFds - 1;
- it != priv->watchFds.end(); it++, i--)
- if ((*it)->handle == handle)
- break;
-
- if (it == priv->watchFds.end())
- return;
-
- w = (*it);
- priv->watchFds.erase (it);
-
- priv->nWatchFds--;
-
- if (i < priv->nWatchFds)
- memmove (&priv->watchPollFds[i], &priv->watchPollFds[i + 1],
- (priv->nWatchFds - i) * sizeof (struct pollfd));
-
- delete w;
-}
-
-void
-CompCore::storeValue (CompString key, CompPrivate value)
-{
- std::map<CompString,CompPrivate>::iterator it;
- it = priv->valueMap.find (key);
- if (it != priv->valueMap.end ())
- {
- it->second = value;
- }
- else
- {
- priv->valueMap.insert (std::pair<CompString,CompPrivate> (key, value));
- }
-}
-
-bool
-CompCore::hasValue (CompString key)
-{
- return (priv->valueMap.find (key) != priv->valueMap.end ());
-}
-
-CompPrivate
-CompCore::getValue (CompString key)
-{
- CompPrivate p;
-
- std::map<CompString,CompPrivate>::iterator it;
- it = priv->valueMap.find (key);
-
- if (it != priv->valueMap.end ())
- {
- return it->second;
- }
- else
- {
- p.uval = 0;
- return p;
- }
-}
-
-void
-CompCore::eraseValue (CompString key)
-{
- std::map<CompString,CompPrivate>::iterator it;
- it = priv->valueMap.find (key);
-
- if (it != priv->valueMap.end ())
- {
- priv->valueMap.erase (key);
- }
-}
-
-short int
-PrivateCore::watchFdEvents (CompWatchFdHandle handle)
-{
- std::list<CompWatchFd *>::iterator it;
- int i;
-
- for (it = watchFds.begin(), i = nWatchFds - 1; it != watchFds.end();
- it++, i--)
- if ((*it)->handle == handle)
- return watchPollFds[i].revents;
-
- return 0;
-}
-
-int
-PrivateCore::doPoll (int timeout)
-{
- int rv;
-
- rv = poll (watchPollFds, nWatchFds, timeout);
- if (rv)
- {
- std::list<CompWatchFd *>::iterator it;
- int i;
-
- for (it = watchFds.begin(), i = nWatchFds - 1; it != watchFds.end();
- it++, i--)
- if (watchPollFds[i].revents != 0 && (*it)->callBack)
- (*it)->callBack ();
- }
-
- return rv;
-}
-
-void
-PrivateCore::handleTimers (struct timeval *tv)
-{
- CompCore::Timer *t;
- int timeDiff;
- std::list<CompCore::Timer *>::iterator it;
-
- timeDiff = TIMEVALDIFF (tv, &lastTimeout);
-
- /* handle clock rollback */
- if (timeDiff < 0)
- timeDiff = 0;
-
- for (it = timers.begin(); it != timers.end(); it++)
- {
- t = (*it);
- t->mMinLeft -= timeDiff;
- t->mMaxLeft -= timeDiff;
- }
-
- while (timers.begin() != timers.end() &&
- (*timers.begin())->mMinLeft <= 0)
- {
- t = (*timers.begin());
- timers.pop_front();
-
- t->mActive = false;
- if (t->mCallBack ())
- {
- addTimer (t);
- t->mActive = true;
- }
- }
-
- lastTimeout = *tv;
-}
-
-
-void
-CompCore::fileWatchAdded (CompFileWatch *watch)
- WRAPABLE_HND_FUNC(0, fileWatchAdded, watch)
-
-void
-CompCore::fileWatchRemoved (CompFileWatch *watch)
- WRAPABLE_HND_FUNC(1, fileWatchRemoved, watch)
-
-bool
-CompCore::initPluginForObject (CompPlugin *plugin, CompObject *object)
-{
- WRAPABLE_HND_FUNC_RETURN(2, bool, initPluginForObject, plugin, object)
- return true;
-}
-
-void
-CompCore::finiPluginForObject (CompPlugin *plugin, CompObject *object)
- WRAPABLE_HND_FUNC(3, finiPluginForObject, plugin, object)
-
-
-bool
-CompCore::setOptionForPlugin (CompObject *object,
- const char *plugin,
- const char *name,
- CompOption::Value &value)
-{
- WRAPABLE_HND_FUNC_RETURN(4, bool, setOptionForPlugin,
- object, plugin, name, value)
-
- CompPlugin *p = CompPlugin::find (plugin);
- if (p)
- return p->vTable->setObjectOption (object, name, value);
-
- return false;
-}
-
-void
-CompCore::objectAdd (CompObject *parent, CompObject *object)
- WRAPABLE_HND_FUNC(5, objectAdd, parent, object)
-
-
-void
-CompCore::objectRemove (CompObject *parent, CompObject *object)
- WRAPABLE_HND_FUNC(6, objectRemove, parent, object)
-
-void
-CompCore::sessionEvent (CompSession::Event event,
- CompOption::Vector &arguments)
- WRAPABLE_HND_FUNC(7, sessionEvent, event, arguments)
-
-void
-CoreInterface::fileWatchAdded (CompFileWatch *watch)
- WRAPABLE_DEF (fileWatchAdded, watch)
-
-void
-CoreInterface::fileWatchRemoved (CompFileWatch *watch)
- WRAPABLE_DEF (fileWatchRemoved, watch)
-
-bool
-CoreInterface::initPluginForObject (CompPlugin *plugin, CompObject *object)
- WRAPABLE_DEF (initPluginForObject, plugin, object)
-
-void
-CoreInterface::finiPluginForObject (CompPlugin *plugin, CompObject *object)
- WRAPABLE_DEF (finiPluginForObject, plugin, object)
-
-
-bool
-CoreInterface::setOptionForPlugin (CompObject *object,
- const char *plugin,
- const char *name,
- CompOption::Value &value)
- WRAPABLE_DEF (setOptionForPlugin, object, plugin, name, value)
-
-void
-CoreInterface::objectAdd (CompObject *parent, CompObject *object)
- WRAPABLE_DEF (objectAdd, parent, object)
-
-void
-CoreInterface::objectRemove (CompObject *parent, CompObject *object)
- WRAPABLE_DEF (objectRemove, parent, object)
-
-void
-CoreInterface::sessionEvent (CompSession::Event event,
- CompOption::Vector &arguments)
- WRAPABLE_DEF (sessionEvent, event, arguments)
-
-
-PrivateCore::PrivateCore (CompCore *core) :
- core (core),
- displays (),
- fileWatch (0),
- lastFileWatchHandle (1),
- timers (0),
- watchFds (0),
- lastWatchFdHandle (1),
- watchPollFds (0),
- nWatchFds (0),
- valueMap ()
-{
- gettimeofday (&lastTimeout, 0);
-}
-
-PrivateCore::~PrivateCore ()
-{
-}
-
-CompCore::Timer::Timer () :
- mActive (false),
- mMinTime (0),
- mMaxTime (0),
- mMinLeft (0),
- mMaxLeft (0),
- mCallBack (NULL)
-{
-}
-
-CompCore::Timer::~Timer ()
-{
- if (mActive)
- core->priv->removeTimer (this);
-}
-
-void
-CompCore::Timer::setTimes (unsigned int min, unsigned int max)
-{
- bool wasActive = mActive;
- if (mActive)
- stop ();
- mMinTime = min;
- mMaxTime = (min <= max)? max : min;
-
- if (wasActive)
- start ();
-}
-
-void
-CompCore::Timer::setCallback (CompCore::Timer::CallBack callback)
-{
- bool wasActive = mActive;
- if (mActive)
- stop ();
- mCallBack = callback;
-
- if (wasActive)
- start ();
-}
-
-void
-CompCore::Timer::start ()
-{
- stop ();
- mActive = true;
- core->priv->addTimer (this);
-}
-
-void
-CompCore::Timer::start (unsigned int min, unsigned int max)
-{
- stop ();
- setTimes (min, max);
- start ();
-}
-
-void
-CompCore::Timer::start (CompCore::Timer::CallBack callback,
- unsigned int min, unsigned int max)
-{
- stop ();
- setTimes (min, max);
- setCallback (callback);
- start ();
-}
-
-void
-CompCore::Timer::stop ()
-{
- mActive = false;
- core->priv->removeTimer (this);
-}
-
-unsigned int
-CompCore::Timer::minTime ()
-{
- return mMinTime;
-}
-
-unsigned int
-CompCore::Timer::maxTime ()
-{
- return mMaxTime;
-}
-
-unsigned int
-CompCore::Timer::minLeft ()
-{
- return (mMinLeft < 0)? 0 : mMinLeft;
-}
-
-unsigned int
-CompCore::Timer::maxLeft ()
-{
- return (mMaxLeft < 0)? 0 : mMaxLeft;
-}
-
-bool
-CompCore::Timer::active ()
-{
- return mActive;
-}
diff --git a/src/display.cpp b/src/display.cpp
deleted file mode 100644
index fa55655..0000000
--- a/src/display.cpp
+++ /dev/null
@@ -1,2396 +0,0 @@
-/*
- * Copyright © 2005 Novell, Inc.
- *
- * Permission to use, copy, modify, distribute, and sell this software
- * and its documentation for any purpose is hereby granted without
- * fee, provided that the above copyright notice appear in all copies
- * and that both that copyright notice and this permission notice
- * appear in supporting documentation, and that the name of
- * Novell, Inc. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior permission.
- * Novell, Inc. makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without express or
- * implied warranty.
- *
- * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
- * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- *
- * Author: David Reveman <davidr@novell.com>
- */
-
-#ifdef HAVE_CONFIG_H
-# include "../config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/poll.h>
-#include <assert.h>
-
-#include <boost/foreach.hpp>
-#define foreach BOOST_FOREACH
-
-#define XK_MISCELLANY
-#include <X11/keysymdef.h>
-
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <X11/Xproto.h>
-#include <X11/extensions/Xrandr.h>
-#include <X11/extensions/shape.h>
-
-#include <boost/bind.hpp>
-
-#include "privatecore.h"
-#include "privatedisplay.h"
-#include "privatescreen.h"
-#include "privatewindow.h"
-
-static unsigned int virtualModMask[] = {
- CompAltMask, CompMetaMask, CompSuperMask, CompHyperMask,
- CompModeSwitchMask, CompNumLockMask, CompScrollLockMask
-};
-
-bool inHandleEvent = false;
-
-CompScreen *targetScreen = NULL;
-CompOutput *targetOutput;
-
-int lastPointerX = 0;
-int lastPointerY = 0;
-int pointerX = 0;
-int pointerY = 0;
-
-#define MwmHintsFunctions (1L << 0)
-#define MwmHintsDecorations (1L << 1)
-#define PropMotifWmHintElements 3
-
-typedef struct {
- unsigned long flags;
- unsigned long functions;
- unsigned long decorations;
-} MwmHints;
-
-#define NUM_OPTIONS(d) (sizeof ((d)->priv->opt) / sizeof (CompOption))
-
-
-CompObject::indices displayPrivateIndices (0);
-
-int
-CompDisplay::allocPrivateIndex ()
-{
- return CompObject::allocatePrivateIndex (COMP_OBJECT_TYPE_DISPLAY,
- &displayPrivateIndices);
-}
-
-void
-CompDisplay::freePrivateIndex (int index)
-{
- CompObject::freePrivateIndex (COMP_OBJECT_TYPE_DISPLAY,
- &displayPrivateIndices, index);
-}
-
-bool
-CompWindow::closeWin (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompWindow *w;
- Window xid;
- unsigned int time;
-
- xid = CompOption::getIntOptionNamed (options, "window");
- time = CompOption::getIntOptionNamed (options, "time", CurrentTime);
-
- w = d->findTopLevelWindow (xid);
- if (w && (w->priv->actions & CompWindowActionCloseMask))
- w->close (time);
-
- return true;
-}
-
-bool
-CompScreen::mainMenu (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompScreen *s;
- Window xid;
- unsigned int time;
-
- xid = CompOption::getIntOptionNamed (options, "root");
- time = CompOption::getIntOptionNamed (options, "time", CurrentTime);
-
- s = d->findScreen (xid);
- if (s && s->priv->grabs.empty ())
- s->toolkitAction (s->display ()->atoms().toolkitActionMainMenu, time,
- s->priv->root, 0, 0, 0);
-
- return true;
-}
-
-bool
-CompScreen::runDialog (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompScreen *s;
- Window xid;
- unsigned int time;
-
- xid = CompOption::getIntOptionNamed (options, "root");
- time = CompOption::getIntOptionNamed (options, "time", CurrentTime);
-
- s = d->findScreen (xid);
- if (s && s->priv->grabs.empty ())
- s->toolkitAction (s->display ()->atoms().toolkitActionRunDialog, time,
- s->priv->root , 0, 0, 0);
-
- return true;
-}
-
-bool
-CompWindow::unmaximizeAction (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompWindow *w;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "window");
-
- w = d->findTopLevelWindow (xid);
- if (w)
- w->maximize (0);
-
- return true;
-}
-
-bool
-CompWindow::minimizeAction (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompWindow *w;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "window");
-
- w = d->findTopLevelWindow (xid);
- if (w && (w->actions () & CompWindowActionMinimizeMask))
- w->minimize ();
-
- return true;
-}
-
-bool
-CompWindow::maximizeAction (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompWindow *w;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "window");
-
- w = d->findTopLevelWindow (xid);
- if (w)
- w->maximize (MAXIMIZE_STATE);
-
- return true;
-}
-
-bool
-CompWindow::maximizeHorizontally (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompWindow *w;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "window");
-
- w = d->findTopLevelWindow (xid);
- if (w)
- w->maximize (w->state () | CompWindowStateMaximizedHorzMask);
-
- return true;
-}
-
-bool
-CompWindow::maximizeVertically (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompWindow *w;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "window");
-
- w = d->findTopLevelWindow (xid);
- if (w)
- w->maximize (w->state () | CompWindowStateMaximizedVertMask);
-
- return true;
-}
-
-bool
-CompScreen::showDesktop (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompScreen *s;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "root");
-
- s = d->findScreen (xid);
- if (s)
- {
- if (s->priv->showingDesktopMask == 0)
- s->enterShowDesktopMode ();
- else
- s->leaveShowDesktopMode (NULL);
- }
-
- return true;
-}
-
-bool
-CompWindow::raiseInitiate (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompWindow *w;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "window");
-
- w = d->findTopLevelWindow (xid);
- if (w)
- w->raise ();
-
- return true;
-}
-
-bool
-CompWindow::lowerInitiate (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompWindow *w;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "window");
-
- w = d->findTopLevelWindow (xid);
- if (w)
- w->lower ();
-
- return true;
-}
-
-bool
-CompDisplay::runCommandDispatch (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompScreen *s;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "root");
-
- s = d->findScreen (xid);
- if (s)
- {
- int index = -1;
- int i = COMP_DISPLAY_OPTION_RUN_COMMAND0_KEY;
-
- while (i <= COMP_DISPLAY_OPTION_RUN_COMMAND11_KEY)
- {
- if (action == &d->priv->opt[i].value ().action ())
- {
- index = i - COMP_DISPLAY_OPTION_RUN_COMMAND0_KEY +
- COMP_DISPLAY_OPTION_COMMAND0;
- break;
- }
-
- i++;
- }
-
- if (index > 0)
- s->runCommand (d->priv->opt[index].value ().s ());
- }
-
- return true;
-}
-
-bool
-CompDisplay::runCommandScreenshot (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompScreen *s;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "root");
-
- s = d->findScreen (xid);
- if (s)
- s->runCommand (
- d->priv->opt[COMP_DISPLAY_OPTION_SCREENSHOT].value ().s ());
-
- return true;
-}
-
-bool
-CompDisplay::runCommandWindowScreenshot (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompScreen *s;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "root");
-
- s = d->findScreen (xid);
- if (s)
- s->runCommand (
- d->priv->opt[COMP_DISPLAY_OPTION_WINDOW_SCREENSHOT].value ().s ());
-
- return true;
-}
-
-bool
-CompDisplay::runCommandTerminal (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompScreen *s;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "root");
-
- s = d->findScreen (xid);
- if (s)
- s->runCommand (
- d->priv->opt[COMP_DISPLAY_OPTION_TERMINAL].value ().s ());
-
- return true;
-}
-
-bool
-CompScreen::windowMenu (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompWindow *w;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "window");
-
- w = d->findTopLevelWindow (xid);
- if (w && w->screen ()->priv->grabs.empty ())
- {
- int x, y, button;
- Time time;
-
- time = CompOption::getIntOptionNamed (options, "time", CurrentTime);
- button = CompOption::getIntOptionNamed (options, "button", 0);
- x = CompOption::getIntOptionNamed (options, "x",
- w->geometry ().x ());
- y = CompOption::getIntOptionNamed (options, "y",
- w->geometry ().y ());
-
- w->screen ()->toolkitAction (
- w->screen ()->display ()->atoms().toolkitActionWindowMenu,
- time, w->id (), button, x, y);
- }
-
- return true;
-}
-
-bool
-CompWindow::toggleMaximized (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompWindow *w;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "window");
-
- w = d->findTopLevelWindow (xid);
- if (w)
- {
- if ((w->priv->state & MAXIMIZE_STATE) == MAXIMIZE_STATE)
- w->maximize (0);
- else
- w->maximize (MAXIMIZE_STATE);
- }
-
- return true;
-}
-
-bool
-CompWindow::toggleMaximizedHorizontally (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompWindow *w;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "window");
-
- w = d->findTopLevelWindow (xid);
- if (w)
- w->maximize (w->priv->state ^ CompWindowStateMaximizedHorzMask);
-
- return true;
-}
-
-bool
-CompWindow::toggleMaximizedVertically (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompWindow *w;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "window");
-
- w = d->findTopLevelWindow (xid);
- if (w)
- w->maximize (w->priv->state ^ CompWindowStateMaximizedVertMask);
-
- return true;
-}
-
-bool
-CompWindow::shade (CompDisplay *d,
- CompAction *action,
- CompAction::State state,
- CompOption::Vector &options)
-{
- CompWindow *w;
- Window xid;
-
- xid = CompOption::getIntOptionNamed (options, "window");
-
- w = d->findTopLevelWindow (xid);
- if (w && (w->priv->actions & CompWindowActionShadeMask))
- {
- w->priv->state ^= CompWindowStateShadedMask;
- w->updateAttributes (CompStackingUpdateModeNone);
- }
-
- return true;
-}
-
-const CompMetadata::OptionInfo coreDisplayOptionInfo[COMP_DISPLAY_OPTION_NUM] = {
- { "active_plugins", "list", "<type>string</type>", 0, 0 },
- { "click_to_focus", "bool", 0, 0, 0 },
- { "autoraise", "bool", 0, 0, 0 },
- { "autoraise_delay", "int", 0, 0, 0 },
- { "close_window_key", "key", 0, CompWindow::closeWin, 0 },
- { "close_window_button", "button", 0, CompWindow::closeWin, 0 },
- { "main_menu_key", "key", 0, CompScreen::mainMenu, 0 },
- { "run_key", "key", 0, CompScreen::runDialog, 0 },
- { "command0", "string", 0, 0, 0 },
- { "command1", "string", 0, 0, 0 },
- { "command2", "string", 0, 0, 0 },
- { "command3", "string", 0, 0, 0 },
- { "command4", "string", 0, 0, 0 },
- { "command5", "string", 0, 0, 0 },
- { "command6", "string", 0, 0, 0 },
- { "command7", "string", 0, 0, 0 },
- { "command8", "string", 0, 0, 0 },
- { "command9", "string", 0, 0, 0 },
- { "command10", "string", 0, 0, 0 },
- { "command11", "string", 0, 0, 0 },
- { "run_command0_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
- { "run_command1_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
- { "run_command2_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
- { "run_command3_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
- { "run_command4_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
- { "run_command5_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
- { "run_command6_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
- { "run_command7_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
- { "run_command8_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
- { "run_command9_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
- { "run_command10_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
- { "run_command11_key", "key", 0, CompDisplay::runCommandDispatch, 0 },
- { "raise_window_key", "key", 0, CompWindow::raiseInitiate, 0 },
- { "raise_window_button", "button", 0, CompWindow::raiseInitiate, 0 },
- { "lower_window_key", "key", 0, CompWindow::lowerInitiate, 0 },
- { "lower_window_button", "button", 0, CompWindow::lowerInitiate, 0 },
- { "unmaximize_window_key", "key", 0, CompWindow::unmaximizeAction, 0 },
- { "minimize_window_key", "key", 0, CompWindow::minimizeAction, 0 },
- { "minimize_window_button", "button", 0, CompWindow::minimizeAction, 0 },
- { "maximize_window_key", "key", 0, CompWindow::maximizeAction, 0 },
- { "maximize_window_horizontally_key", "key", 0,
- CompWindow::maximizeHorizontally, 0 },
- { "maximize_window_vertically_key", "key", 0,
- CompWindow::maximizeVertically, 0 },
- { "command_screenshot", "string", 0, 0, 0 },
- { "run_command_screenshot_key", "key", 0,
- CompDisplay::runCommandScreenshot, 0 },
- { "command_window_screenshot", "string", 0, 0, 0 },
- { "run_command_window_screenshot_key", "key", 0,
- CompDisplay::runCommandWindowScreenshot, 0 },
- { "window_menu_button", "button", 0, CompScreen::windowMenu, 0 },
- { "window_menu_key", "key", 0, CompScreen::windowMenu, 0 },
- { "show_desktop_key", "key", 0, CompScreen::showDesktop, 0 },
- { "show_desktop_edge", "edge", 0, CompScreen::showDesktop, 0 },
- { "raise_on_click", "bool", 0, 0, 0 },
- { "audible_bell", "bool", 0, 0, 0 },
- { "toggle_window_maximized_key", "key", 0,
- CompWindow::toggleMaximized, 0 },
- { "toggle_window_maximized_button", "button", 0,
- CompWindow::toggleMaximized, 0 },
- { "toggle_window_maximized_horizontally_key", "key", 0,
- CompWindow::toggleMaximizedHorizontally, 0 },
- { "toggle_window_maximized_vertically_key", "key", 0,
- CompWindow::toggleMaximizedVertically, 0 },
- { "hide_skip_taskbar_windows", "bool", 0, 0, 0 },
- { "toggle_window_shaded_key", "key", 0, CompWindow::shade, 0 },
- { "ignore_hints_when_maximized", "bool", 0, 0, 0 },
- { "command_terminal", "string", 0, 0, 0 },
- { "run_command_terminal_key", "key", 0,
- CompDisplay::runCommandTerminal, 0 },
- { "ping_delay", "int", "<min>1000</min>", 0, 0 },
- { "edge_delay", "int", "<min>0</min>", 0, 0 }
-};
-
-CompOption::Vector &
-CompDisplay::getDisplayOptions (CompObject *object)
-{
- CompDisplay *display = dynamic_cast <CompDisplay *> (object);
- if (display)
- return display->priv->opt;
- return noOptions;
-}
-
-bool
-CompDisplay::setDisplayOption (CompObject *object,
- const char *name,
- CompOption::Value &value)
-{
- CompDisplay *display = dynamic_cast <CompDisplay *> (object);
- if (display)
- return display->setOption (name, value);
- return false;
-}
-
-
-static const int maskTable[] = {
- ShiftMask, LockMask, ControlMask, Mod1Mask,
- Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
-};
-static const int maskTableSize = sizeof (maskTable) / sizeof (int);
-
-static int errors = 0;
-
-static int
-errorHandler (Display *dpy,
- XErrorEvent *e)
-{
-
-#ifdef DEBUG
- char str[128];
-#endif
-
- errors++;
-
-#ifdef DEBUG
- XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "", str, 128);
- fprintf (stderr, "%s", str);
-
- XGetErrorText (dpy, e->error_code, str, 128);
- fprintf (stderr, ": %s\n ", str);
-
- XGetErrorDatabaseText (dpy, "XlibMessage", "MajorCode", "%d", str, 128);
- fprintf (stderr, str, e->request_code);
-
- sprintf (str, "%d", e->request_code);
- XGetErrorDatabaseText (dpy, "XRequest", str, "", str, 128);
- if (strcmp (str, ""))
- fprintf (stderr, " (%s)", str);
- fprintf (stderr, "\n ");
-
- XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "%d", str, 128);
- fprintf (stderr, str, e->minor_code);
- fprintf (stderr, "\n ");
-
- XGetErrorDatabaseText (dpy, "XlibMessage", "ResourceID", "%d", str, 128);
- fprintf (stderr, str, e->resourceid);
- fprintf (stderr, "\n");
-
- /* abort (); */
-#endif
-
- return 0;
-}
-
-int
-CompDisplay::checkForError (Display *dpy)
-{
- int e;
-
- XSync (dpy, FALSE);
-
- e = errors;
- errors = 0;
-
- return e;
-}
-
-/* add actions that should be automatically added as no screens
- existed when they were initialized. */
-void
-CompDisplay::addScreenActions (CompScreen *s)
-{
- foreach (CompOption &o, priv->opt)
- {
- if (!o.isAction ())
- continue;
-
- if (o.value ().action ().state () & CompAction::StateAutoGrab)
- s->addAction (&o.value ().action ());
- }
-}
-
-CompDisplay::CompDisplay () :
- CompObject (COMP_OBJECT_TYPE_DISPLAY, "display", &displayPrivateIndices)
-{
- priv = new PrivateDisplay (this);
- assert (priv);
-}
-
-
-CompDisplay::~CompDisplay ()
-{
- while (!priv->screens.empty ())
- removeScreen (priv->screens.front ());
-
- removeFromParent ();
-
- CompPlugin::objectFiniPlugins (this);
-
- if (priv->snDisplay)
- sn_display_unref (priv->snDisplay);
-
- XSync (priv->dpy, False);
- XCloseDisplay (priv->dpy);
-
- if (priv->modMap)
- XFreeModifiermap (priv->modMap);
-
- delete priv;
-}
-
-bool
-CompDisplay::init (const char *name)
-{
- Window focus;
- int revertTo, i;
- int xkbOpcode;
- int firstScreen, lastScreen;
-
- CompOption::Value::Vector vList;
-
- vList.push_back ("core");
-
- priv->plugin.set (CompOption::TypeString, vList);
-
- priv->dpy = XOpenDisplay (name);
- if (!priv->dpy)
- {
- compLogMessage (this, "core", CompLogLevelFatal,
- "Couldn't open display %s", XDisplayName (name));
- return false;
- }
-
-// priv->connection = XGetXCBConnection (priv->dpy);
-
- if (!coreMetadata->initDisplayOptions (this, coreDisplayOptionInfo,
- COMP_DISPLAY_OPTION_NUM, priv->opt))
- return true;
-
- snprintf (priv->displayString, 255, "DISPLAY=%s",
- DisplayString (priv->dpy));
-
-#ifdef DEBUG
- XSynchronize (priv->dpy, TRUE);
-#endif
-
- priv->initAtoms ();
-
- XSetErrorHandler (errorHandler);
-
- updateModifierMappings ();
-
- priv->snDisplay = sn_display_new (priv->dpy, NULL, NULL);
- if (!priv->snDisplay)
- return true;
-
- priv->lastPing = 1;
-
- if (!XSyncQueryExtension (priv->dpy, &priv->syncEvent, &priv->syncError))
- {
- compLogMessage (this, "core", CompLogLevelFatal,
- "No sync extension");
- return false;
- }
-
- priv->randrExtension = XRRQueryExtension (priv->dpy, &priv->randrEvent,
- &priv->randrError);
-
- priv->shapeExtension = XShapeQueryExtension (priv->dpy, &priv->shapeEvent,
- &priv->shapeError);
-
- priv->xkbExtension = XkbQueryExtension (priv->dpy, &xkbOpcode,
- &priv->xkbEvent, &priv->xkbError,
- NULL, NULL);
- if (priv->xkbExtension)
- {
- XkbSelectEvents (priv->dpy,
- XkbUseCoreKbd,
- XkbBellNotifyMask | XkbStateNotifyMask,
- XkbAllEventsMask);
- }
- else
- {
- compLogMessage (this, "core", CompLogLevelFatal,
- "No XKB extension");
-
- priv->xkbEvent = priv->xkbError = -1;
- }
-
- priv->xineramaExtension = XineramaQueryExtension (priv->dpy,
- &priv->xineramaEvent,
- &priv->xineramaError);
-
-
- updateScreenInfo();
-
- priv->escapeKeyCode =
- XKeysymToKeycode (priv->dpy, XStringToKeysym ("Escape"));
- priv->returnKeyCode =
- XKeysymToKeycode (priv->dpy, XStringToKeysym ("Return"));
-
- /* TODO: bailout properly when objectInitPlugins fails */
- assert (CompPlugin::objectInitPlugins (this));
-
- core->addChild (this);
-
- if (onlyCurrentScreen)
- {
- firstScreen = DefaultScreen (priv->dpy);
- lastScreen = DefaultScreen (priv->dpy);
- }
- else
- {
- firstScreen = 0;
- lastScreen = ScreenCount (priv->dpy) - 1;
- }
-
- for (i = firstScreen; i <= lastScreen; i++)
- {
- addScreen (i);
- }
-
- if (priv->screens.empty ())
- {
- compLogMessage (this, "core", CompLogLevelFatal,
- "No manageable screens found on display %s",
- XDisplayName (name));
- return false;
- }
-
- priv->setAudibleBell (
- priv->opt[COMP_DISPLAY_OPTION_AUDIBLE_BELL].value ().b ());
-
- XGetInputFocus (priv->dpy, &focus, &revertTo);
-
- /* move input focus to root window so that we get a FocusIn event when
- moving it to the default window */
- XSetInputFocus (priv->dpy, priv->screens.front ()->root (),
- RevertToPointerRoot, CurrentTime);
-
- if (focus == None || focus == PointerRoot)
- {
- priv->screens.front ()->focusDefaultWindow ();
- }
- else
- {
- CompWindow *w;
-
- w = findWindow (focus);
- if (w)
- {
- w->moveInputFocusTo ();
- }
- else
- priv->screens.front ()->focusDefaultWindow ();
- }
-
- priv->pingTimer.start (
- boost::bind(&PrivateDisplay::handlePingTimeout, priv),
- priv->opt[COMP_DISPLAY_OPTION_PING_DELAY].value ().i (),
- priv->opt[COMP_DISPLAY_OPTION_PING_DELAY].value ().i () + 500);
-
- return true;
-}
-
-CompString
-CompDisplay::objectName ()
-{
- return CompString ("");
-}
-
-CompDisplay::Atoms
-CompDisplay::atoms ()
-{
- return priv->atoms;
-}
-
-Display *
-CompDisplay::dpy ()
-{
- return priv->dpy;
-}
-
-CompScreenList &
-CompDisplay::screens ()
-{
- return priv->screens;
-}
-
-CompOption *
-CompDisplay::getOption (const char *name)
-{
- CompOption *o = CompOption::findOption (priv->opt, name);
- return o;
-}
-
-std::vector<XineramaScreenInfo> &
-CompDisplay::screenInfo ()
-{
- return priv->screenInfo;
-}
-
-bool
-CompDisplay::XRandr ()
-{
- return priv->randrExtension;
-}
-
-int
-CompDisplay::randrEvent ()
-{
- return priv->randrEvent;
-}
-
-bool
-CompDisplay::XShape ()
-{
- return priv->shapeExtension;
-}
-
-int
-CompDisplay::shapeEvent ()
-{
- return priv->shapeEvent;
-}
-
-int
-CompDisplay::syncEvent ()
-{
- return priv->syncEvent;
-}
-
-
-SnDisplay *
-CompDisplay::snDisplay ()
-{
- return priv->snDisplay;
-}
-
-Window
-CompDisplay::below ()
-{
- return priv->below;
-}
-
-Window
-CompDisplay::activeWindow ()
-{
- return priv->activeWindow;
-}
-
-Window
-CompDisplay::autoRaiseWindow ()
-{
- return priv->autoRaiseWindow;
-}
-
-XModifierKeymap *
-CompDisplay::modMap ()
-{
- return priv->modMap;
-}
-
-unsigned int
-CompDisplay::ignoredModMask ()
-{
- return priv->ignoredModMask;
-}
-
-const char *
-CompDisplay::displayString ()
-{
- return priv->displayString;
-}
-
-unsigned int
-CompDisplay::lastPing ()
-{
- return priv->lastPing;
-}
-
-CompWatchFdHandle
-CompDisplay::getWatchFdHandle ()
-{
- return priv->watchFdHandle;
-}
-
-void
-CompDisplay::setWatchFdHandle (CompWatchFdHandle handle)
-{
- priv->watchFdHandle = handle;
-}
-
-void
-CompDisplay::updateScreenInfo ()
-{
- if (priv->xineramaExtension)
- {
- int nInfo;
- XineramaScreenInfo *info = XineramaQueryScreens (priv->dpy, &nInfo);
-
- priv->screenInfo = std::vector<XineramaScreenInfo> (info, info + nInfo);
-
- if (info)
- XFree (info);
- }
-}
-
-bool
-CompDisplay::addScreen (int screenNum)
-{
- CompScreen *s;
- Window rootDummy, childDummy;
- int x, y, dummy;
- unsigned int uDummy;
-
- s = new CompScreen ();
- if (!s)
- return false;
-
- priv->screens.push_back (s);
-
- if (!s->init (this, screenNum))
- {
- compLogMessage (this, "core", CompLogLevelError,
- "Failed to manage screen: %d", screenNum);
-
- priv->screens.pop_back ();
- }
-
- if (XQueryPointer (priv->dpy, XRootWindow (priv->dpy, screenNum),
- &rootDummy, &childDummy,
- &x, &y, &dummy, &dummy, &uDummy))
- {
- lastPointerX = pointerX = x;
- lastPointerY = pointerY = y;
- }
- return true;
-}
-
-void
-CompDisplay::removeScreen (CompScreen *s)
-{
- CompScreenList::iterator it =
- std::find (priv->screens.begin (), priv->screens.end (), s);
-
- priv->screens.erase (it);
-
- delete s;
-}
-
-void
-PrivateDisplay::setAudibleBell (bool audible)
-{
- if (xkbExtension)
- XkbChangeEnabledControls (dpy,
- XkbUseCoreKbd,
- XkbAudibleBellMask,
- audible ? XkbAudibleBellMask : 0);
-}
-
-bool
-PrivateDisplay::handlePingTimeout ()
-{
- XEvent ev;
- int ping = lastPing + 1;
-
- ev.type = ClientMessage;
- ev.xclient.window = 0;
- ev.xclient.message_type = atoms.wmProtocols;
- ev.xclient.format = 32;
- ev.xclient.data.l[0] = atoms.wmPing;
- ev.xclient.data.l[1] = ping;
- ev.xclient.data.l[2] = 0;
- ev.xclient.data.l[3] = 0;
- ev.xclient.data.l[4] = 0;
-
- foreach (CompScreen *s, screens)
- {
- foreach (CompWindow *w, s->windows ())
- {
- if (w->handlePingTimeout (lastPing))
- {
- ev.xclient.window = w->id ();
- ev.xclient.data.l[2] = w->id ();
-
- XSendEvent (dpy, w->id (), false, NoEventMask, &ev);
- }
- }
- }
-
- lastPing = ping;
-
- return true;
-}
-
-bool
-CompDisplay::setOption (const char *name,
- CompOption::Value &value)
-{
- CompOption *o;
- unsigned int index;
-
- o = CompOption::findOption (priv->opt, name, &index);
- if (!o)
- return false;
-
- switch (index) {
- case COMP_DISPLAY_OPTION_ACTIVE_PLUGINS:
- if (o->set (value))
- {
- priv->dirtyPluginList = true;
- return true;
- }
- break;
- case COMP_DISPLAY_OPTION_PING_DELAY:
- if (o->set (value))
- {
- priv->pingTimer.setTimes (o->value ().i (), o->value ().i () + 500);
- return true;
- }
- break;
- case COMP_DISPLAY_OPTION_AUDIBLE_BELL:
- if (o->set (value))
- {
- priv->setAudibleBell (o->value ().b ());
- return true;
- }
- break;
- default:
- if (CompOption::setDisplayOption (this, *o, value))
- return true;
- break;
- }
-
- return false;
-}
-
-void
-CompDisplay::updateModifierMappings ()
-{
- unsigned int modMask[CompModNum];
- int i, minKeycode, maxKeycode, keysymsPerKeycode = 0;
- KeySym* key;
-
- for (i = 0; i < CompModNum; i++)
- modMask[i] = 0;
-
- XDisplayKeycodes (priv->dpy, &minKeycode, &maxKeycode);
- key = XGetKeyboardMapping (priv->dpy,
- minKeycode, (maxKeycode - minKeycode + 1),
- &keysymsPerKeycode);
-
- if (priv->modMap)
- XFreeModifiermap (priv->modMap);
-
- priv->modMap = XGetModifierMapping (priv->dpy);
- if (priv->modMap && priv->modMap->max_keypermod > 0)
- {
- KeySym keysym;
- int index, size, mask;
-
- size = maskTableSize * priv->modMap->max_keypermod;
-
- for (i = 0; i < size; i++)
- {
- if (!priv->modMap->modifiermap[i])
- continue;
-
- index = 0;
- do
- {
- keysym = XKeycodeToKeysym (priv->dpy,
- priv->modMap->modifiermap[i],
- index++);
- } while (!keysym && index < keysymsPerKeycode);
-
- if (keysym)
- {
- mask = maskTable[i / priv->modMap->max_keypermod];
-
- if (keysym == XK_Alt_L ||
- keysym == XK_Alt_R)
- {
- modMask[CompModAlt] |= mask;
- }
- else if (keysym == XK_Meta_L ||
- keysym == XK_Meta_R)
- {
- modMask[CompModMeta] |= mask;
- }
- else if (keysym == XK_Super_L ||
- keysym == XK_Super_R)
- {
- modMask[CompModSuper] |= mask;
- }
- else if (keysym == XK_Hyper_L ||
- keysym == XK_Hyper_R)
- {
- modMask[CompModHyper] |= mask;
- }
- else if (keysym == XK_Mode_switch)
- {
- modMask[CompModModeSwitch] |= mask;
- }
- else if (keysym == XK_Scroll_Lock)
- {
- modMask[CompModScrollLock] |= mask;
- }
- else if (keysym == XK_Num_Lock)
- {
- modMask[CompModNumLock] |= mask;
- }
- }
- }
-
- for (i = 0; i < CompModNum; i++)
- {
- if (!modMask[i])
- modMask[i] = CompNoMask;
- }
-
- if (memcmp (modMask, priv->modMask, sizeof (modMask)))
- {
- memcpy (priv->modMask, modMask, sizeof (modMask));
-
- priv->ignoredModMask = LockMask |
- (modMask[CompModNumLock] & ~CompNoMask) |
- (modMask[CompModScrollLock] & ~CompNoMask);
-
- foreach (CompScreen *s, priv->screens)
- s->updatePassiveGrabs ();
- }
- }
-
- if (key)
- XFree (key);
-}
-
-unsigned int
-CompDisplay::virtualToRealModMask (unsigned int modMask)
-{
- int i;
-
- for (i = 0; i < CompModNum; i++)
- {
- if (modMask & virtualModMask[i])
- {
- modMask &= ~virtualModMask[i];
- modMask |= priv->modMask[i];
- }
- }
-
- return modMask;
-}
-
-unsigned int
-CompDisplay::keycodeToModifiers (int keycode)
-{
- unsigned int mods = 0;
- int mod, k;
-
- for (mod = 0; mod < maskTableSize; mod++)
- {
- for (k = 0; k < priv->modMap->max_keypermod; k++)
- {
- if (priv->modMap->modifiermap[mod *
- priv->modMap->max_keypermod + k] == keycode)
- mods |= maskTable[mod];
- }
- }
-
- return mods;
-}
-
-void
-CompDisplay::processEvents ()
-{
- XEvent event;
-
- /* remove destroyed windows */
- foreach (CompScreen *s, priv->screens)
- s->removeDestroyed ();
-
- if (priv->dirtyPluginList)
- priv->updatePlugins ();
-
- while (XPending (priv->dpy))
- {
- XNextEvent (priv->dpy, &event);
-
- switch (event.type) {
- case ButtonPress:
- case ButtonRelease:
- pointerX = event.xbutton.x_root;
- pointerY = event.xbutton.y_root;
- break;
- case KeyPress:
- case KeyRelease:
- pointerX = event.xkey.x_root;
- pointerY = event.xkey.y_root;
- break;
- case MotionNotify:
- pointerX = event.xmotion.x_root;
- pointerY = event.xmotion.y_root;
- break;
- case EnterNotify:
- case LeaveNotify:
- pointerX = event.xcrossing.x_root;
- pointerY = event.xcrossing.y_root;
- break;
- case ClientMessage:
- if (event.xclient.message_type == priv->atoms.xdndPosition)
- {
- pointerX = event.xclient.data.l[2] >> 16;
- pointerY = event.xclient.data.l[2] & 0xffff;
- }
- default:
- break;
- }
-
- sn_display_process_event (priv->snDisplay, &event);
-
- inHandleEvent = true;
- handleEvent (&event);
- inHandleEvent = false;
-
- lastPointerX = pointerX;
- lastPointerY = pointerY;
- }
-}
-
-void
-PrivateDisplay::updatePlugins ()
-{
- CompOption *o;
- CompPlugin *p;
- unsigned int nPop, i, j;
- CompPlugin::List pop;
-
- dirtyPluginList = false;
-
- o = &opt[COMP_DISPLAY_OPTION_ACTIVE_PLUGINS];
-
- /* The old plugin list always begins with the core plugin. To make sure
- we don't unnecessarily unload plugins if the new plugin list does not
- contain the core plugin, we have to use an offset */
-
- if (o->value ().list ().size () > 0 &&
- o->value ().list ()[0]. s (). compare ("core"))
- i = 0;
- else
- i = 1;
-
- /* j is initialized to 1 to make sure we never pop the core plugin */
- for (j = 1; j < plugin.list ().size () &&
- i < o->value ().list ().size (); i++, j++)
- {
- if (plugin.list ()[j].s ().compare (o->value ().list ()[i].s ()))
- break;
- }
-
- nPop = plugin.list ().size () - j;
-
- for (j = 0; j < nPop; j++)
- {
- pop.push_back (CompPlugin::pop ());
- plugin.list ().pop_back ();
- }
-
- for (; i < o->value ().list ().size (); i++)
- {
- p = NULL;
- foreach (CompPlugin *pp, pop)
- {
- if (o->value ().list ()[i]. s ().compare (pp->vTable->name ()) == 0)
- {
- if (CompPlugin::push (pp))
- {
- p = pp;
- pop.erase (std::find (pop.begin (), pop.end (), pp));
- break;
- }
- }
- }
-
- if (p == 0)
- {
- p = CompPlugin::load (o->value ().list ()[i].s ().c_str ());
- if (p)
- {
- if (!CompPlugin::push (p))
- {
- CompPlugin::unload (p);
- p = 0;
- }
- }
- }
-
- if (p)
- {
- plugin.list ().push_back (p->vTable->name ());
- }
- }
-
- foreach (CompPlugin *pp, pop)
- {
- CompPlugin::unload (pp);
- }
-
- core->setOptionForPlugin (display, "core", o->name ().c_str (), plugin);
-}
-
-CompScreen *
-CompDisplay::findScreen (Window root)
-{
- foreach (CompScreen *s, priv->screens)
- {
- if (s->root () == root)
- return s;
- }
-
- return 0;
-}
-
-CompWindow *
-CompDisplay::findWindow (Window id)
-{
- CompWindow *w;
-
- foreach (CompScreen *s, priv->screens)
- {
- w = s->findWindow (id);
- if (w)
- return w;
- }
-
- return 0;
-}
-
-CompWindow *
-CompDisplay::findTopLevelWindow (Window id, bool override_redirect)
-{
- CompWindow *w;
-
- foreach (CompScreen *s, priv->screens)
- {
- w = s->findTopLevelWindow (id, override_redirect);
- if (w)
- return w;
- }
-
- return 0;
-}
-
-static CompScreen *
-findScreenForSelection (CompDisplay *display,
- Window owner,
- Atom selection)
-{
- foreach (CompScreen *s, display->screens ())
- {
- if (s->selectionWindow () == owner && s->selectionAtom () == selection)
- return s;
- }
-
- return NULL;
-}
-
-/* from fvwm2, Copyright Matthias Clasen, Dominik Vogt */
-static bool
-convertProperty (CompDisplay *display,
- CompScreen *screen,
- Window w,
- Atom target,
- Atom property)
-{
-
-#define N_TARGETS 4
-
- Atom conversionTargets[N_TARGETS];
- long icccmVersion[] = { 2, 0 };
- Time time = screen->selectionTimestamp ();
-
- conversionTargets[0] = display->atoms().targets;
- conversionTargets[1] = display->atoms().multiple;
- conversionTargets[2] = display->atoms().timestamp;
- conversionTargets[3] = display->atoms().version;
-
- if (target == display->atoms().targets)
- XChangeProperty (display->dpy(), w, property,
- XA_ATOM, 32, PropModeReplace,
- (unsigned char *) conversionTargets, N_TARGETS);
- else if (target == display->atoms().timestamp)
- XChangeProperty (display->dpy(), w, property,
- XA_INTEGER, 32, PropModeReplace,
- (unsigned char *) &time, 1);
- else if (target == display->atoms().version)
- XChangeProperty (display->dpy(), w, property,
- XA_INTEGER, 32, PropModeReplace,
- (unsigned char *) icccmVersion, 2);
- else
- return false;
-
- /* Be sure the PropertyNotify has arrived so we
- * can send SelectionNotify
- */
- XSync (display->dpy (), FALSE);
-
- return true;
-}
-
-/* from fvwm2, Copyright Matthias Clasen, Dominik Vogt */
-void
-PrivateDisplay::handleSelectionRequest (XEvent *event)
-{
- XSelectionEvent reply;
- CompScreen *screen;
-
- screen = findScreenForSelection (display,
- event->xselectionrequest.owner,
- event->xselectionrequest.selection);
- if (!screen)
- return;
-
- reply.type = SelectionNotify;
- reply.display = dpy;
- reply.requestor = event->xselectionrequest.requestor;
- reply.selection = event->xselectionrequest.selection;
- reply.target = event->xselectionrequest.target;
- reply.property = None;
- reply.time = event->xselectionrequest.time;
-
- if (event->xselectionrequest.target == atoms.multiple)
- {
- if (event->xselectionrequest.property != None)
- {
- Atom type, *adata;
- int i, format;
- unsigned long num, rest;
- unsigned char *data;
-
- if (XGetWindowProperty (dpy,
- event->xselectionrequest.requestor,
- event->xselectionrequest.property,
- 0, 256, FALSE,
- atoms.atomPair,
- &type, &format, &num, &rest,
- &data) != Success)
- return;
-
- /* FIXME: to be 100% correct, should deal with rest > 0,
- * but since we have 4 possible targets, we will hardly ever
- * meet multiple requests with a length > 8
- */
- adata = (Atom *) data;
- i = 0;
- while (i < (int) num)
- {
- if (!convertProperty (display, screen,
- event->xselectionrequest.requestor,
- adata[i], adata[i + 1]))
- adata[i + 1] = None;
-
- i += 2;
- }
-
- XChangeProperty (dpy,
- event->xselectionrequest.requestor,
- event->xselectionrequest.property,
- atoms.atomPair,
- 32, PropModeReplace, data, num);
- }
- }
- else
- {
- if (event->xselectionrequest.property == None)
- event->xselectionrequest.property = event->xselectionrequest.target;
-
- if (convertProperty (display, screen,
- event->xselectionrequest.requestor,
- event->xselectionrequest.target,
- event->xselectionrequest.property))
- reply.property = event->xselectionrequest.property;
- }
-
- XSendEvent (dpy,
- event->xselectionrequest.requestor,
- FALSE, 0L, (XEvent *) &reply);
-}
-
-void
-PrivateDisplay::handleSelectionClear (XEvent *event)
-{
- /* We need to unmanage the screen on which we lost the selection */
- CompScreen *screen;
-
- screen = findScreenForSelection (display,
- event->xselectionclear.window,
- event->xselectionclear.selection);
-
- if (screen)
- shutDown = TRUE;
-}
-
-
-#define HOME_IMAGEDIR ".compiz/images"
-
-bool
-CompDisplay::readImageFromFile (const char *name,
- int *width,
- int *height,
- void **data)
-{
- Bool status;
- int stride;
-
- status = fileToImage (NULL, name, width, height, &stride, data);
- if (!status)
- {
- char *home;
-
- home = getenv ("HOME");
- if (home)
- {
- char *path;
-
- path = (char *) malloc (strlen (home) + strlen (HOME_IMAGEDIR) + 2);
- if (path)
- {
- sprintf (path, "%s/%s", home, HOME_IMAGEDIR);
- status = fileToImage (path, name, width, height, &stride, data);
-
- free (path);
-
- if (status)
- return TRUE;
- }
- }
-
- status = fileToImage (IMAGEDIR, name, width, height, &stride, data);
- }
-
- return status;
-}
-
-bool
-CompDisplay::writeImageToFile (const char *path,
- const char *name,
- const char *format,
- int width,
- int height,
- void *data)
-{
- return imageToFile (path, name, format, width, height, width * 4, data);
-}
-
-Window
-CompDisplay::getActiveWindow (Window root)
-{
- Atom actual;
- int result, format;
- unsigned long n, left;
- unsigned char *data;
- Window w = None;
-
- result = XGetWindowProperty (priv->dpy, root,
- priv->atoms.winActive, 0L, 1L, FALSE,
- XA_WINDOW, &actual, &format,
- &n, &left, &data);
-
- if (result == Success && n && data)
- {
- memcpy (&w, data, sizeof (Window));
- XFree (data);
- }
-
- return w;
-}
-
-void
-PrivateDisplay::initAtoms ()
-{
- atoms.supported = XInternAtom (dpy, "_NET_SUPPORTED", 0);
- atoms.supportingWmCheck = XInternAtom (dpy, "_NET_SUPPORTING_WM_CHECK", 0);
-
- atoms.utf8String = XInternAtom (dpy, "UTF8_STRING", 0);
-
- atoms.wmName = XInternAtom (dpy, "_NET_WM_NAME", 0);
-
- atoms.winType = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE", 0);
- atoms.winTypeDesktop = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DESKTOP",
- 0);
- atoms.winTypeDock = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DOCK", 0);
- atoms.winTypeToolbar = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_TOOLBAR",
- 0);
- atoms.winTypeMenu = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_MENU", 0);
- atoms.winTypeUtil = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_UTILITY",
- 0);
- atoms.winTypeSplash = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_SPLASH", 0);
- atoms.winTypeDialog = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DIALOG", 0);
- atoms.winTypeNormal = XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_NORMAL", 0);
-
- atoms.winTypeDropdownMenu =
- XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", 0);
- atoms.winTypePopupMenu =
- XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_POPUP_MENU", 0);
- atoms.winTypeTooltip =
- XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_TOOLTIP", 0);
- atoms.winTypeNotification =
- XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_NOTIFICATION", 0);
- atoms.winTypeCombo =
- XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_COMBO", 0);
- atoms.winTypeDnd =
- XInternAtom (dpy, "_NET_WM_WINDOW_TYPE_DND", 0);
-
- atoms.winOpacity = XInternAtom (dpy, "_NET_WM_WINDOW_OPACITY", 0);
- atoms.winBrightness = XInternAtom (dpy, "_NET_WM_WINDOW_BRIGHTNESS", 0);
- atoms.winSaturation = XInternAtom (dpy, "_NET_WM_WINDOW_SATURATION", 0);
-
- atoms.winActive = XInternAtom (dpy, "_NET_ACTIVE_WINDOW", 0);
- atoms.winDesktop = XInternAtom (dpy, "_NET_WM_DESKTOP", 0);
- atoms.workarea = XInternAtom (dpy, "_NET_WORKAREA", 0);
-
- atoms.desktopViewport = XInternAtom (dpy, "_NET_DESKTOP_VIEWPORT", 0);
- atoms.desktopGeometry = XInternAtom (dpy, "_NET_DESKTOP_GEOMETRY", 0);
- atoms.currentDesktop = XInternAtom (dpy, "_NET_CURRENT_DESKTOP", 0);
- atoms.numberOfDesktops = XInternAtom (dpy, "_NET_NUMBER_OF_DESKTOPS", 0);
-
- atoms.winState = XInternAtom (dpy, "_NET_WM_STATE", 0);
- atoms.winStateModal =
- XInternAtom (dpy, "_NET_WM_STATE_MODAL", 0);
- atoms.winStateSticky =
- XInternAtom (dpy, "_NET_WM_STATE_STICKY", 0);
- atoms.winStateMaximizedVert =
- XInternAtom (dpy, "_NET_WM_STATE_MAXIMIZED_VERT", 0);
- atoms.winStateMaximizedHorz =
- XInternAtom (dpy, "_NET_WM_STATE_MAXIMIZED_HORZ", 0);
- atoms.winStateShaded =
- XInternAtom (dpy, "_NET_WM_STATE_SHADED", 0);
- atoms.winStateSkipTaskbar =
- XInternAtom (dpy, "_NET_WM_STATE_SKIP_TASKBAR", 0);
- atoms.winStateSkipPager =
- XInternAtom (dpy, "_NET_WM_STATE_SKIP_PAGER", 0);
- atoms.winStateHidden =
- XInternAtom (dpy, "_NET_WM_STATE_HIDDEN", 0);
- atoms.winStateFullscreen =
- XInternAtom (dpy, "_NET_WM_STATE_FULLSCREEN", 0);
- atoms.winStateAbove =
- XInternAtom (dpy, "_NET_WM_STATE_ABOVE", 0);
- atoms.winStateBelow =
- XInternAtom (dpy, "_NET_WM_STATE_BELOW", 0);
- atoms.winStateDemandsAttention =
- XInternAtom (dpy, "_NET_WM_STATE_DEMANDS_ATTENTION", 0);
- atoms.winStateDisplayModal =
- XInternAtom (dpy, "_NET_WM_STATE_DISPLAY_MODAL", 0);
-
- atoms.winActionMove = XInternAtom (dpy, "_NET_WM_ACTION_MOVE", 0);
- atoms.winActionResize =
- XInternAtom (dpy, "_NET_WM_ACTION_RESIZE", 0);
- atoms.winActionStick =
- XInternAtom (dpy, "_NET_WM_ACTION_STICK", 0);
- atoms.winActionMinimize =
- XInternAtom (dpy, "_NET_WM_ACTION_MINIMIZE", 0);
- atoms.winActionMaximizeHorz =
- XInternAtom (dpy, "_NET_WM_ACTION_MAXIMIZE_HORZ", 0);
- atoms.winActionMaximizeVert =
- XInternAtom (dpy, "_NET_WM_ACTION_MAXIMIZE_VERT", 0);
- atoms.winActionFullscreen =
- XInternAtom (dpy, "_NET_WM_ACTION_FULLSCREEN", 0);
- atoms.winActionClose =
- XInternAtom (dpy, "_NET_WM_ACTION_CLOSE", 0);
- atoms.winActionShade =
- XInternAtom (dpy, "_NET_WM_ACTION_SHADE", 0);
- atoms.winActionChangeDesktop =
- XInternAtom (dpy, "_NET_WM_ACTION_CHANGE_DESKTOP", 0);
- atoms.winActionAbove =
- XInternAtom (dpy, "_NET_WM_ACTION_ABOVE", 0);
- atoms.winActionBelow =
- XInternAtom (dpy, "_NET_WM_ACTION_BELOW", 0);
-
- atoms.wmAllowedActions = XInternAtom (dpy, "_NET_WM_ALLOWED_ACTIONS", 0);
-
- atoms.wmStrut = XInternAtom (dpy, "_NET_WM_STRUT", 0);
- atoms.wmStrutPartial = XInternAtom (dpy, "_NET_WM_STRUT_PARTIAL", 0);
-
- atoms.wmUserTime = XInternAtom (dpy, "_NET_WM_USER_TIME", 0);
-
- atoms.wmIcon = XInternAtom (dpy,"_NET_WM_ICON", 0);
- atoms.wmIconGeometry = XInternAtom (dpy, "_NET_WM_ICON_GEOMETRY", 0);
-
- atoms.clientList = XInternAtom (dpy, "_NET_CLIENT_LIST", 0);
- atoms.clientListStacking =
- XInternAtom (dpy, "_NET_CLIENT_LIST_STACKING", 0);
-
- atoms.frameExtents = XInternAtom (dpy, "_NET_FRAME_EXTENTS", 0);
- atoms.frameWindow = XInternAtom (dpy, "_NET_FRAME_WINDOW", 0);
-
- atoms.wmState = XInternAtom (dpy, "WM_STATE", 0);
- atoms.wmChangeState = XInternAtom (dpy, "WM_CHANGE_STATE", 0);
- atoms.wmProtocols = XInternAtom (dpy, "WM_PROTOCOLS", 0);
- atoms.wmClientLeader = XInternAtom (dpy, "WM_CLIENT_LEADER", 0);
-
- atoms.wmDeleteWindow = XInternAtom (dpy, "WM_DELETE_WINDOW", 0);
- atoms.wmTakeFocus = XInternAtom (dpy, "WM_TAKE_FOCUS", 0);
- atoms.wmPing = XInternAtom (dpy, "_NET_WM_PING", 0);
- atoms.wmSyncRequest = XInternAtom (dpy, "_NET_WM_SYNC_REQUEST", 0);
-
- atoms.wmSyncRequestCounter =
- XInternAtom (dpy, "_NET_WM_SYNC_REQUEST_COUNTER", 0);
-
- atoms.closeWindow = XInternAtom (dpy, "_NET_CLOSE_WINDOW", 0);
- atoms.wmMoveResize = XInternAtom (dpy, "_NET_WM_MOVERESIZE", 0);
- atoms.moveResizeWindow = XInternAtom (dpy, "_NET_MOVERESIZE_WINDOW", 0);
- atoms.restackWindow = XInternAtom (dpy, "_NET_RESTACK_WINDOW", 0);
-
- atoms.showingDesktop = XInternAtom (dpy, "_NET_SHOWING_DESKTOP", 0);
-
- atoms.xBackground[0] = XInternAtom (dpy, "_XSETROOT_ID", 0);
- atoms.xBackground[1] = XInternAtom (dpy, "_XROOTPMAP_ID", 0);
-
- atoms.toolkitAction =
- XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION", 0);
- atoms.toolkitActionMainMenu =
- XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_MAIN_MENU", 0);
- atoms.toolkitActionRunDialog =
- XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_RUN_DIALOG", 0);
- atoms.toolkitActionWindowMenu =
- XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_WINDOW_MENU", 0);
- atoms.toolkitActionForceQuitDialog =
- XInternAtom (dpy, "_COMPIZ_TOOLKIT_ACTION_FORCE_QUIT_DIALOG", 0);
-
- atoms.mwmHints = XInternAtom (dpy, "_MOTIF_WM_HINTS", 0);
-
- atoms.xdndAware = XInternAtom (dpy, "XdndAware", 0);
- atoms.xdndEnter = XInternAtom (dpy, "XdndEnter", 0);
- atoms.xdndLeave = XInternAtom (dpy, "XdndLeave", 0);
- atoms.xdndPosition = XInternAtom (dpy, "XdndPosition", 0);
- atoms.xdndStatus = XInternAtom (dpy, "XdndStatus", 0);
- atoms.xdndDrop = XInternAtom (dpy, "XdndDrop", 0);
-
- atoms.manager = XInternAtom (dpy, "MANAGER", 0);
- atoms.targets = XInternAtom (dpy, "TARGETS", 0);
- atoms.multiple = XInternAtom (dpy, "MULTIPLE", 0);
- atoms.timestamp = XInternAtom (dpy, "TIMESTAMP", 0);
- atoms.version = XInternAtom (dpy, "VERSION", 0);
- atoms.atomPair = XInternAtom (dpy, "ATOM_PAIR", 0);
-
- atoms.startupId = XInternAtom (dpy, "_NET_STARTUP_ID", 0);
-}
-
-bool
-CompDisplay::fileToImage (const char *path,
- const char *name,
- int *width,
- int *height,
- int *stride,
- void **data)
-{
- WRAPABLE_HND_FUNC_RETURN(2, bool, fileToImage, path, name, width, height,
- stride, data)
- return false;
-}
-
-bool
-CompDisplay::imageToFile (const char *path,
- const char *name,
- const char *format,
- int width,
- int height,
- int stride,
- void *data)
-{
- WRAPABLE_HND_FUNC_RETURN(3, bool, imageToFile, path, name, format, width,
- height, stride, data)
- return false;
-}
-
-void
-CompDisplay::logMessage (const char *componentName,
- CompLogLevel level,
- const char *message)
-{
- WRAPABLE_HND_FUNC(7, logMessage, componentName, level, message)
- compLogMessage (NULL, componentName, level, message);
-}
-
-const char *
-logLevelToString (CompLogLevel level)
-{
- switch (level) {
- case CompLogLevelFatal:
- return "Fatal";
- case CompLogLevelError:
- return "Error";
- case CompLogLevelWarn:
- return "Warn";
- case CompLogLevelInfo:
- return "Info";
- case CompLogLevelDebug:
- return "Debug";
- default:
- break;
- }
-
- return "Unknown";
-}
-
-static void
-logMessage (const char *componentName,
- CompLogLevel level,
- const char *message)
-{
- fprintf (stderr, "%s (%s) - %s: %s\n",
- programName, componentName,
- logLevelToString (level), message);
-}
-
-void
-compLogMessage (CompDisplay *d,
- const char *componentName,
- CompLogLevel level,
- const char *format,
- ...)
-{
- va_list args;
- char message[2048];
-
- va_start (args, format);
-
- vsnprintf (message, 2048, format, args);
-
- if (d)
- d->logMessage (componentName, level, message);
- else
- logMessage (componentName, level, message);
-
- va_end (args);
-}
-
-int
-CompDisplay::getWmState (Window id)
-{
- Atom actual;
- int result, format;
- unsigned long n, left;
- unsigned char *data;
- unsigned long state = NormalState;
-
- result = XGetWindowProperty (priv->dpy, id,
- priv->atoms.wmState, 0L, 2L, FALSE,
- priv->atoms.wmState, &actual, &format,
- &n, &left, &data);
-
- if (result == Success && n && data)
- {
- memcpy (&state, data, sizeof (unsigned long));
- XFree ((void *) data);
- }
-
- return state;
-}
-
-void
-CompDisplay::setWmState (int state, Window id)
-{
- unsigned long data[2];
-
- data[0] = state;
- data[1] = None;
-
- XChangeProperty (priv->dpy, id,
- priv->atoms.wmState, priv->atoms.wmState,
- 32, PropModeReplace, (unsigned char *) data, 2);
-}
-
-unsigned int
-CompDisplay::windowStateMask (Atom state)
-{
- if (state == priv->atoms.winStateModal)
- return CompWindowStateModalMask;
- else if (state == priv->atoms.winStateSticky)
- return CompWindowStateStickyMask;
- else if (state == priv->atoms.winStateMaximizedVert)
- return CompWindowStateMaximizedVertMask;
- else if (state == priv->atoms.winStateMaximizedHorz)
- return CompWindowStateMaximizedHorzMask;
- else if (state == priv->atoms.winStateShaded)
- return CompWindowStateShadedMask;
- else if (state == priv->atoms.winStateSkipTaskbar)
- return CompWindowStateSkipTaskbarMask;
- else if (state == priv->atoms.winStateSkipPager)
- return CompWindowStateSkipPagerMask;
- else if (state == priv->atoms.winStateHidden)
- return CompWindowStateHiddenMask;
- else if (state == priv->atoms.winStateFullscreen)
- return CompWindowStateFullscreenMask;
- else if (state == priv->atoms.winStateAbove)
- return CompWindowStateAboveMask;
- else if (state == priv->atoms.winStateBelow)
- return CompWindowStateBelowMask;
- else if (state == priv->atoms.winStateDemandsAttention)
- return CompWindowStateDemandsAttentionMask;
- else if (state == priv->atoms.winStateDisplayModal)
- return CompWindowStateDisplayModalMask;
-
- return 0;
-}
-
-unsigned int
-CompDisplay::windowStateFromString (const char *str)
-{
- if (strcasecmp (str, "modal") == 0)
- return CompWindowStateModalMask;
- else if (strcasecmp (str, "sticky") == 0)
- return CompWindowStateStickyMask;
- else if (strcasecmp (str, "maxvert") == 0)
- return CompWindowStateMaximizedVertMask;
- else if (strcasecmp (str, "maxhorz") == 0)
- return CompWindowStateMaximizedHorzMask;
- else if (strcasecmp (str, "shaded") == 0)
- return CompWindowStateShadedMask;
- else if (strcasecmp (str, "skiptaskbar") == 0)
- return CompWindowStateSkipTaskbarMask;
- else if (strcasecmp (str, "skippager") == 0)
- return CompWindowStateSkipPagerMask;
- else if (strcasecmp (str, "hidden") == 0)
- return CompWindowStateHiddenMask;
- else if (strcasecmp (str, "fullscreen") == 0)
- return CompWindowStateFullscreenMask;
- else if (strcasecmp (str, "above") == 0)
- return CompWindowStateAboveMask;
- else if (strcasecmp (str, "below") == 0)
- return CompWindowStateBelowMask;
- else if (strcasecmp (str, "demandsattention") == 0)
- return CompWindowStateDemandsAttentionMask;
-
- return 0;
-}
-
-unsigned int
-CompDisplay::getWindowState (Window id)
-{
- Atom actual;
- int result, format;
- unsigned long n, left;
- unsigned char *data;
- unsigned int state = 0;
-
- result = XGetWindowProperty (priv->dpy, id,
- priv->atoms.winState,
- 0L, 1024L, FALSE, XA_ATOM, &actual, &format,
- &n, &left, &data);
-
- if (result == Success && data)
- {
- Atom *a = (Atom *) data;
-
- while (n--)
- state |= windowStateMask (*a++);
-
- XFree ((void *) data);
- }
-
- return state;
-}
-
-void
-CompDisplay::setWindowState (unsigned int state,
- Window id)
-{
- Atom data[32];
- int i = 0;
-
- if (state & CompWindowStateModalMask)
- data[i++] = priv->atoms.winStateModal;
- if (state & CompWindowStateStickyMask)
- data[i++] = priv->atoms.winStateSticky;
- if (state & CompWindowStateMaximizedVertMask)
- data[i++] = priv->atoms.winStateMaximizedVert;
- if (state & CompWindowStateMaximizedHorzMask)
- data[i++] = priv->atoms.winStateMaximizedHorz;
- if (state & CompWindowStateShadedMask)
- data[i++] = priv->atoms.winStateShaded;
- if (state & CompWindowStateSkipTaskbarMask)
- data[i++] = priv->atoms.winStateSkipTaskbar;
- if (state & CompWindowStateSkipPagerMask)
- data[i++] = priv->atoms.winStateSkipPager;
- if (state & CompWindowStateHiddenMask)
- data[i++] = priv->atoms.winStateHidden;
- if (state & CompWindowStateFullscreenMask)
- data[i++] = priv->atoms.winStateFullscreen;
- if (state & CompWindowStateAboveMask)
- data[i++] = priv->atoms.winStateAbove;
- if (state & CompWindowStateBelowMask)
- data[i++] = priv->atoms.winStateBelow;
- if (state & CompWindowStateDemandsAttentionMask)
- data[i++] = priv->atoms.winStateDemandsAttention;
- if (state & CompWindowStateDisplayModalMask)
- data[i++] = priv->atoms.winStateDisplayModal;
-
- XChangeProperty (priv->dpy, id, priv->atoms.winState,
- XA_ATOM, 32, PropModeReplace,
- (unsigned char *) data, i);
-}
-
-unsigned int
-CompDisplay::getWindowType (Window id)
-{
- Atom actual;
- int result, format;
- unsigned long n, left;
- unsigned char *data;
-
- result = XGetWindowProperty (priv->dpy , id,
- priv->atoms.winType,
- 0L, 1L, FALSE, XA_ATOM, &actual, &format,
- &n, &left, &data);
-
- if (result == Success && n && data)
- {
- Atom a;
-
- memcpy (&a, data, sizeof (Atom));
- XFree ((void *) data);
-
- if (a == priv->atoms.winTypeNormal)
- return CompWindowTypeNormalMask;
- else if (a == priv->atoms.winTypeMenu)
- return CompWindowTypeMenuMask;
- else if (a == priv->atoms.winTypeDesktop)
- return CompWindowTypeDesktopMask;
- else if (a == priv->atoms.winTypeDock)
- return CompWindowTypeDockMask;
- else if (a == priv->atoms.winTypeToolbar)
- return CompWindowTypeToolbarMask;
- else if (a == priv->atoms.winTypeUtil)
- return CompWindowTypeUtilMask;
- else if (a == priv->atoms.winTypeSplash)
- return CompWindowTypeSplashMask;
- else if (a == priv->atoms.winTypeDialog)
- return CompWindowTypeDialogMask;
- else if (a == priv->atoms.winTypeDropdownMenu)
- return CompWindowTypeDropdownMenuMask;
- else if (a == priv->atoms.winTypePopupMenu)
- return CompWindowTypePopupMenuMask;
- else if (a == priv->atoms.winTypeTooltip)
- return CompWindowTypeTooltipMask;
- else if (a == priv->atoms.winTypeNotification)
- return CompWindowTypeNotificationMask;
- else if (a == priv->atoms.winTypeCombo)
- return CompWindowTypeComboMask;
- else if (a == priv->atoms.winTypeDnd)
- return CompWindowTypeDndMask;
- }
-
- return CompWindowTypeUnknownMask;
-}
-
-void
-CompDisplay::getMwmHints (Window id,
- unsigned int *func,
- unsigned int *decor)
-{
- Atom actual;
- int result, format;
- unsigned long n, left;
- unsigned char *data;
-
- *func = MwmFuncAll;
- *decor = MwmDecorAll;
-
- result = XGetWindowProperty (priv->dpy, id,
- priv->atoms.mwmHints,
- 0L, 20L, FALSE, priv->atoms.mwmHints,
- &actual, &format, &n, &left, &data);
-
- if (result == Success && n && data)
- {
- MwmHints *mwmHints = (MwmHints *) data;
-
- if (n >= PropMotifWmHintElements)
- {
- if (mwmHints->flags & MwmHintsDecorations)
- *decor = mwmHints->decorations;
-
- if (mwmHints->flags & MwmHintsFunctions)
- *func = mwmHints->functions;
- }
-
- XFree (data);
- }
-}
-
-unsigned int
-CompDisplay::getProtocols (Window id)
-{
- Atom *protocol;
- int count;
- unsigned int protocols = 0;
-
- if (XGetWMProtocols (priv->dpy, id, &protocol, &count))
- {
- int i;
-
- for (i = 0; i < count; i++)
- {
- if (protocol[i] == priv->atoms.wmDeleteWindow)
- protocols |= CompWindowProtocolDeleteMask;
- else if (protocol[i] == priv->atoms.wmTakeFocus)
- protocols |= CompWindowProtocolTakeFocusMask;
- else if (protocol[i] == priv->atoms.wmPing)
- protocols |= CompWindowProtocolPingMask;
- else if (protocol[i] == priv->atoms.wmSyncRequest)
- protocols |= CompWindowProtocolSyncRequestMask;
- }
-
- XFree (protocol);
- }
-
- return protocols;
-}
-
-unsigned int
-CompDisplay::getWindowProp (Window id,
- Atom property,
- unsigned int defaultValue)
-{
- Atom actual;
- int result, format;
- unsigned long n, left;
- unsigned char *data;
-
- result = XGetWindowProperty (priv->dpy, id, property,
- 0L, 1L, FALSE, XA_CARDINAL, &actual, &format,
- &n, &left, &data);
-
- if (result == Success && n && data)
- {
- unsigned long value;
-
- memcpy (&value, data, sizeof (unsigned long));
-
- XFree (data);
-
- return (unsigned int) value;
- }
-
- return defaultValue;
-}
-
-void
-CompDisplay::setWindowProp (Window id,
- Atom property,
- unsigned int value)
-{
- unsigned long data = value;
-
- XChangeProperty (priv->dpy, id, property,
- XA_CARDINAL, 32, PropModeReplace,
- (unsigned char *) &data, 1);
-}
-
-bool
-CompDisplay::readWindowProp32 (Window id,
- Atom property,
- unsigned short *returnValue)
-{
- Atom actual;
- int result, format;
- unsigned long n, left;
- unsigned char *data;
-
- result = XGetWindowProperty (priv->dpy, id, property,
- 0L, 1L, FALSE, XA_CARDINAL, &actual, &format,
- &n, &left, &data);
-
- if (result == Success && n && data)
- {
- CARD32 value;
-
- memcpy (&value, data, sizeof (CARD32));
-
- XFree (data);
-
- *returnValue = value >> 16;
-
- return true;
- }
-
- return false;
-}
-
-unsigned short
-CompDisplay::getWindowProp32 (Window id,
- Atom property,
- unsigned short defaultValue)
-{
- unsigned short result;
-
- if (readWindowProp32 (id, property, &result))
- return result;
-
- return defaultValue;
-}
-
-void
-CompDisplay::setWindowProp32 (Window id,
- Atom property,
- unsigned short value)
-{
- CARD32 value32;
-
- value32 = value << 16 | value;
-
- XChangeProperty (priv->dpy, id, property,
- XA_CARDINAL, 32, PropModeReplace,
- (unsigned char *) &value32, 1);
-}
-
-void
-DisplayInterface::handleEvent (XEvent *event)
- WRAPABLE_DEF (handleEvent, event)
-
-void
-DisplayInterface::handleCompizEvent (const char *plugin,
- const char *event,
- CompOption::Vector &options)
- WRAPABLE_DEF (handleCompizEvent, plugin, event, options)
-
-bool
-DisplayInterface::fileToImage (const char *path,
- const char *name,
- int *width,
- int *height,
- int *stride,
- void **data)
- WRAPABLE_DEF (fileToImage, path, name, width, height, stride, data)
-
-bool
-DisplayInterface::imageToFile (const char *path,
- const char *name,
- const char *format,
- int width,
- int height,
- int stride,
- void *data)
- WRAPABLE_DEF (imageToFile, path, name, format, width, height, stride, data)
-
-CompMatch::Expression *
-DisplayInterface::matchInitExp (const CompString value)
- WRAPABLE_DEF (matchInitExp, value)
-
-void
-DisplayInterface::matchExpHandlerChanged ()
- WRAPABLE_DEF (matchExpHandlerChanged)
-
-void
-DisplayInterface::matchPropertyChanged (CompWindow *window)
- WRAPABLE_DEF (matchPropertyChanged, window)
-
-void
-DisplayInterface::logMessage (const char *componentName,
- CompLogLevel level,
- const char *message)
- WRAPABLE_DEF (logMessage, componentName, level, message)
-
-PrivateDisplay::PrivateDisplay (CompDisplay *display) :
- display (display),
- screens (),
- watchFdHandle (0),
- screenInfo (0),
- activeWindow (0),
- below (None),
- modMap (0),
- ignoredModMask (LockMask),
- opt (COMP_DISPLAY_OPTION_NUM),
- autoRaiseTimer (),
- autoRaiseWindow (0),
- edgeDelayTimer (),
- plugin (),
- dirtyPluginList (true)
-{
- for (int i = 0; i < CompModNum; i++)
- modMask[i] = CompNoMask;
-}
-
-PrivateDisplay::~PrivateDisplay ()
-{
- CompOption::finiDisplayOptions (display, opt);
-}
diff --git a/src/event.cpp b/src/event.cpp
index ff456e1..6a6a7b3 100644
--- a/src/event.cpp
+++ b/src/event.cpp
@@ -37,7 +37,7 @@
#include <X11/extensions/Xfixes.h>
#include <compiz-core.h>
-#include "privatedisplay.h"
+#include <core/atoms.h>
#include "privatescreen.h"
#include "privatewindow.h"
@@ -70,14 +70,14 @@ CompWindow::handleSyncAlarm ()
static bool
-autoRaiseTimeout (CompDisplay *display)
+autoRaiseTimeout (CompScreen *screen)
{
- CompWindow *w = display->findWindow (display->activeWindow ());
+ CompWindow *w = screen->findWindow (screen->activeWindow ());
- if (display->autoRaiseWindow () == display->activeWindow () ||
- (w && (display->autoRaiseWindow () == w->transientFor ())))
+ if (screen->autoRaiseWindow () == screen->activeWindow () ||
+ (w && (screen->autoRaiseWindow () == w->transientFor ())))
{
- w = display->findWindow (display->autoRaiseWindow ());
+ w = screen->findWindow (screen->autoRaiseWindow ());
if (w)
w->updateAttributes (CompStackingUpdateModeNormal);
}
@@ -140,9 +140,9 @@ isTerminateBinding (CompOption &option,
}
bool
-PrivateDisplay::triggerButtonPressBindings (CompOption::Vector &options,
- XEvent *event,
- CompOption::Vector &arguments)
+PrivateScreen::triggerButtonPressBindings (CompOption::Vector &options,
+ XEvent *event,
+ CompOption::Vector &arguments)
{
CompAction::State state = CompAction::StateInitButton;
CompAction *action;
@@ -152,25 +152,23 @@ PrivateDisplay::triggerButtonPressBindings (CompOption::Vector &options,
if (edgeWindow)
{
- CompScreen *s;
unsigned int i;
- s = display->findScreen (event->xbutton.root);
- if (!s)
+ if (event->xbutton.root != root);
return false;
if (event->xbutton.window != edgeWindow)
{
- if (!s->hasGrab () || event->xbutton.window != s->root ())
+ if (grabs.empty () || event->xbutton.window != root)
return false;
}
for (i = 0; i < SCREEN_EDGE_NUM; i++)
{
- if (edgeWindow == s->screenEdge (i).id)
+ if (edgeWindow == screenEdge[i].id)
{
edge = 1 << i;
- arguments[1].value ().set ((int) display->activeWindow ());
+ arguments[1].value ().set ((int) activeWindow);
break;
}
}
@@ -183,12 +181,11 @@ PrivateDisplay::triggerButtonPressBindings (CompOption::Vector &options,
{
if (action->button ().button () == (int) event->xbutton.button)
{
- bindMods = display->virtualToRealModMask (
+ bindMods = screen->virtualToRealModMask (
action->button ().modifiers ());
if ((bindMods & modMask) == (event->xbutton.state & modMask))
- if (action->initiate () (display, action, state,
- arguments))
+ if (action->initiate () (action, state, arguments))
return true;
}
}
@@ -202,12 +199,12 @@ PrivateDisplay::triggerButtonPressBindings (CompOption::Vector &options,
(int) event->xbutton.button) &&
(action->edgeMask () & edge))
{
- bindMods = display->virtualToRealModMask (
+ bindMods = screen->virtualToRealModMask (
action->button ().modifiers ());
if ((bindMods & modMask) ==
(event->xbutton.state & modMask))
- if (action->initiate () (display, action, state |
+ if (action->initiate () (action, state |
CompAction::StateInitEdge,
arguments))
return true;
@@ -220,9 +217,9 @@ PrivateDisplay::triggerButtonPressBindings (CompOption::Vector &options,
}
bool
-PrivateDisplay::triggerButtonReleaseBindings (CompOption::Vector &options,
- XEvent *event,
- CompOption::Vector &arguments)
+PrivateScreen::triggerButtonReleaseBindings (CompOption::Vector &options,
+ XEvent *event,
+ CompOption::Vector &arguments)
{
CompAction::State state = CompAction::StateTermButton;
CompAction::BindingType type = CompAction::BindingTypeButton |
@@ -235,8 +232,7 @@ PrivateDisplay::triggerButtonReleaseBindings (CompOption::Vector &options,
{
if (action->button ().button () == (int) event->xbutton.button)
{
- if (action->terminate () (display, action, state,
- arguments))
+ if (action->terminate () (action, state, arguments))
return true;
}
}
@@ -246,9 +242,9 @@ PrivateDisplay::triggerButtonReleaseBindings (CompOption::Vector &options,
}
bool
-PrivateDisplay::triggerKeyPressBindings (CompOption::Vector &options,
- XEvent *event,
- CompOption::Vector &arguments)
+PrivateScreen::triggerKeyPressBindings (CompOption::Vector &options,
+ XEvent *event,
+ CompOption::Vector &arguments)
{
CompAction::State state = 0;
CompAction *action;
@@ -267,8 +263,7 @@ PrivateDisplay::triggerKeyPressBindings (CompOption::Vector &options,
if (o.isAction ())
{
if (!o.value ().action ().terminate ().empty ())
- o.value ().action ().terminate () (display,
- &o.value ().action (),
+ o.value ().action ().terminate () (&o.value ().action (),
state, noOptions);
}
}
@@ -283,21 +278,19 @@ PrivateDisplay::triggerKeyPressBindings (CompOption::Vector &options,
if (isInitiateBinding (option, CompAction::BindingTypeKey,
state, &action))
{
- bindMods = display->virtualToRealModMask (
+ bindMods = screen->virtualToRealModMask (
action->key ().modifiers ());
if (action->key ().keycode () == (int) event->xkey.keycode)
{
if ((bindMods & modMask) == (event->xkey.state & modMask))
- if (action->initiate () (display, action, state,
- arguments))
+ if (action->initiate () (action, state, arguments))
return true;
}
else if (!xkbEvent && action->key ().keycode () == 0)
{
if (bindMods == (event->xkey.state & modMask))
- if (action->initiate () (display, action, state,
- arguments))
+ if (action->initiate () (action, state, arguments))
return true;
}
}
@@ -307,9 +300,9 @@ PrivateDisplay::triggerKeyPressBindings (CompOption::Vector &options,
}
bool
-PrivateDisplay::triggerKeyReleaseBindings (CompOption::Vector &options,
- XEvent *event,
- CompOption::Vector &arguments)
+PrivateScreen::triggerKeyReleaseBindings (CompOption::Vector &options,
+ XEvent *event,
+ CompOption::Vector &arguments)
{
if (!xkbEvent)
{
@@ -319,7 +312,7 @@ PrivateDisplay::triggerKeyReleaseBindings (CompOption::Vector &options,
unsigned int bindMods;
unsigned int mods;
- mods = display->keycodeToModifiers (event->xkey.keycode);
+ mods = screen->keycodeToModifiers (event->xkey.keycode);
if (mods == 0)
return false;
@@ -329,12 +322,11 @@ PrivateDisplay::triggerKeyReleaseBindings (CompOption::Vector &options,
state, &action))
{
bindMods =
- display->virtualToRealModMask (action->key ().modifiers ());
+ screen->virtualToRealModMask (action->key ().modifiers ());
if ((mods & modMask & bindMods) != bindMods)
{
- if (action->terminate () (display, action, state,
- arguments))
+ if (action->terminate () (action, state, arguments))
return true;
}
}
@@ -345,9 +337,9 @@ PrivateDisplay::triggerKeyReleaseBindings (CompOption::Vector &options,
}
bool
-PrivateDisplay::triggerStateNotifyBindings (CompOption::Vector &options,
- XkbStateNotifyEvent *event,
- CompOption::Vector &arguments)
+PrivateScreen::triggerStateNotifyBindings (CompOption::Vector &options,
+ XkbStateNotifyEvent *event,
+ CompOption::Vector &arguments)
{
CompAction::State state;
CompAction *action;
@@ -365,13 +357,12 @@ PrivateDisplay::triggerStateNotifyBindings (CompOption::Vector &options,
{
if (action->key ().keycode () == 0)
{
- bindMods = display->virtualToRealModMask (
+ bindMods = screen->virtualToRealModMask (
action->key ().modifiers ());
if ((event->mods & modMask & bindMods) == bindMods)
{
- if (action->initiate () (display, action, state,
- arguments))
+ if (action->initiate () (action, state, arguments))
return true;
}
}
@@ -388,12 +379,11 @@ PrivateDisplay::triggerStateNotifyBindings (CompOption::Vector &options,
state, &action))
{
bindMods =
- display->virtualToRealModMask (action->key ().modifiers ());
+ screen->virtualToRealModMask (action->key ().modifiers ());
if ((event->mods & modMask & bindMods) != bindMods)
{
- if (action->terminate () (display, action, state,
- arguments))
+ if (action->terminate () (action, state, arguments))
return true;
}
}
@@ -427,8 +417,7 @@ isBellAction (CompOption &option,
}
static bool
-triggerBellNotifyBindings (CompDisplay *d,
- CompOption::Vector &options,
+triggerBellNotifyBindings (CompOption::Vector &options,
CompOption::Vector &arguments)
{
CompAction::State state = CompAction::StateInitBell;
@@ -438,7 +427,7 @@ triggerBellNotifyBindings (CompDisplay *d,
{
if (isBellAction (option, state, &action))
{
- if (action->initiate () (d, action, state, arguments))
+ if (action->initiate () (action, state, arguments))
return true;
}
}
@@ -517,8 +506,7 @@ isEdgeLeaveAction (CompOption &option,
}
static bool
-triggerEdgeEnterBindings (CompDisplay *d,
- CompOption::Vector &options,
+triggerEdgeEnterBindings (CompOption::Vector &options,
CompAction::State state,
CompAction::State delayState,
unsigned int edge,
@@ -530,7 +518,7 @@ triggerEdgeEnterBindings (CompDisplay *d,
{
if (isEdgeEnterAction (option, state, delayState, edge, &action))
{
- if (action->initiate () (d, action, state, arguments))
+ if (action->initiate () (action, state, arguments))
return true;
}
}
@@ -539,8 +527,7 @@ triggerEdgeEnterBindings (CompDisplay *d,
}
static bool
-triggerEdgeLeaveBindings (CompDisplay *d,
- CompOption::Vector &options,
+triggerEdgeLeaveBindings (CompOption::Vector &options,
CompAction::State state,
unsigned int edge,
CompOption::Vector &arguments)
@@ -551,7 +538,7 @@ triggerEdgeLeaveBindings (CompDisplay *d,
{
if (isEdgeLeaveAction (option, state, edge, &action))
{
- if (action->terminate () (d, action, state, arguments))
+ if (action->terminate () (action, state, arguments))
return true;
}
}
@@ -560,16 +547,15 @@ triggerEdgeLeaveBindings (CompDisplay *d,
}
static bool
-triggerAllEdgeEnterBindings (CompDisplay *d,
- CompAction::State state,
+triggerAllEdgeEnterBindings (CompAction::State state,
CompAction::State delayState,
unsigned int edge,
CompOption::Vector &arguments)
{
foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
- CompOption::Vector &options = p->vTable->getObjectOptions (d);
- if (triggerEdgeEnterBindings (d, options, state, delayState, edge,
+ CompOption::Vector &options = p->vTable->getObjectOptions (screen);
+ if (triggerEdgeEnterBindings (options, state, delayState, edge,
arguments))
{
return true;
@@ -579,10 +565,9 @@ triggerAllEdgeEnterBindings (CompDisplay *d,
}
static bool
-delayedEdgeTimeout (CompDisplay *d, CompDelayedEdgeSettings *settings)
+delayedEdgeTimeout (CompDelayedEdgeSettings *settings)
{
- triggerAllEdgeEnterBindings (d,
- settings->state,
+ triggerAllEdgeEnterBindings (settings->state,
~CompAction::StateNoEdgeDelay,
settings->edge,
settings->options);
@@ -591,13 +576,13 @@ delayedEdgeTimeout (CompDisplay *d, CompDelayedEdgeSettings *settings)
}
bool
-PrivateDisplay::triggerEdgeEnter (unsigned int edge,
- CompAction::State state,
- CompOption::Vector &arguments)
+PrivateScreen::triggerEdgeEnter (unsigned int edge,
+ CompAction::State state,
+ CompOption::Vector &arguments)
{
int delay;
- delay = opt[COMP_DISPLAY_OPTION_EDGE_DELAY].value ().i ();
+ delay = opt[COMP_OPTION_EDGE_DELAY].value ().i ();
if (delay > 0)
{
@@ -607,18 +592,16 @@ PrivateDisplay::triggerEdgeEnter (unsigned int edge,
edgeDelaySettings.options = arguments;
edgeDelayTimer.start (
- boost::bind (delayedEdgeTimeout, display, &edgeDelaySettings),
+ boost::bind (delayedEdgeTimeout, &edgeDelaySettings),
delay, (unsigned int)((float) delay * 1.2));
delayState = CompAction::StateNoEdgeDelay;
- if (triggerAllEdgeEnterBindings (display, state, delayState,
- edge, arguments))
+ if (triggerAllEdgeEnterBindings (state, delayState, edge, arguments))
return true;
}
else
{
- if (triggerAllEdgeEnterBindings (display, state, 0, edge,
- arguments))
+ if (triggerAllEdgeEnterBindings (state, 0, edge, arguments))
return true;
}
@@ -626,9 +609,8 @@ PrivateDisplay::triggerEdgeEnter (unsigned int edge,
}
bool
-PrivateDisplay::handleActionEvent (XEvent *event)
+PrivateScreen::handleActionEvent (XEvent *event)
{
- CompObject *obj = display;
CompOption::Vector o (0);
o.push_back (CompOption ("event_window", CompOption::TypeInt));
@@ -655,7 +637,7 @@ PrivateDisplay::handleActionEvent (XEvent *event)
foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
- CompOption::Vector &options = p->vTable->getObjectOptions (obj);
+ CompOption::Vector &options = p->vTable->getObjectOptions (screen);
if (triggerButtonPressBindings (options, event, o))
return true;
}
@@ -676,7 +658,7 @@ PrivateDisplay::handleActionEvent (XEvent *event)
foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
- CompOption::Vector &options = p->vTable->getObjectOptions (obj);
+ CompOption::Vector &options = p->vTable->getObjectOptions (screen);
if (triggerButtonReleaseBindings (options, event, o))
return true;
}
@@ -697,7 +679,7 @@ PrivateDisplay::handleActionEvent (XEvent *event)
foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
- CompOption::Vector &options = p->vTable->getObjectOptions (obj);
+ CompOption::Vector &options = p->vTable->getObjectOptions (screen);
if (triggerKeyPressBindings (options, event, o))
return true;
}
@@ -718,7 +700,7 @@ PrivateDisplay::handleActionEvent (XEvent *event)
foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
- CompOption::Vector &options = p->vTable->getObjectOptions (obj);
+ CompOption::Vector &options = p->vTable->getObjectOptions (screen);
if (triggerKeyReleaseBindings (options, event, o))
return true;
}
@@ -728,12 +710,10 @@ PrivateDisplay::handleActionEvent (XEvent *event)
event->xcrossing.mode != NotifyUngrab &&
event->xcrossing.detail != NotifyInferior)
{
- CompScreen *s;
unsigned int edge, i;
CompAction::State state;
- s = display->findScreen (event->xcrossing.root);
- if (!s)
+ if (event->xcrossing.root != root)
return false;
if (edgeDelayTimer.active ())
@@ -746,7 +726,7 @@ PrivateDisplay::handleActionEvent (XEvent *event)
for (i = 0; i < SCREEN_EDGE_NUM; i++)
{
- if (edgeWindow == s->screenEdge (i).id)
+ if (edgeWindow == screenEdge[i].id)
{
edge = 1 << i;
break;
@@ -768,9 +748,8 @@ PrivateDisplay::handleActionEvent (XEvent *event)
foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
CompOption::Vector &options =
- p->vTable->getObjectOptions (obj);
- if (triggerEdgeLeaveBindings (display, options,
- state, edge, o))
+ p->vTable->getObjectOptions (screen);
+ if (triggerEdgeLeaveBindings (options, state, edge, o))
return true;
}
}
@@ -779,7 +758,7 @@ PrivateDisplay::handleActionEvent (XEvent *event)
for (i = 0; i < SCREEN_EDGE_NUM; i++)
{
- if (event->xcrossing.window == s->screenEdge (i).id)
+ if (event->xcrossing.window == screenEdge[i].id)
{
edge = 1 << i;
break;
@@ -808,32 +787,29 @@ PrivateDisplay::handleActionEvent (XEvent *event)
}
break;
case ClientMessage:
- if (event->xclient.message_type == atoms.xdndEnter)
+ if (event->xclient.message_type == Atoms::xdndEnter)
{
xdndWindow = event->xclient.window;
}
- else if (event->xclient.message_type == atoms.xdndLeave)
+ else if (event->xclient.message_type == Atoms::xdndLeave)
{
unsigned int edge = 0;
CompAction::State state;
- Window root = None;
if (!xdndWindow)
{
CompWindow *w;
- w = display->findWindow (event->xclient.window);
+ w = screen->findWindow (event->xclient.window);
if (w)
{
- CompScreen *s = w->screen ();
unsigned int i;
for (i = 0; i < SCREEN_EDGE_NUM; i++)
{
- if (event->xclient.window == s->screenEdge (i).id)
+ if (event->xclient.window == screenEdge[i].id)
{
edge = 1 << i;
- root = s->root ();
break;
}
}
@@ -854,35 +830,31 @@ PrivateDisplay::handleActionEvent (XEvent *event)
foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
CompOption::Vector &options =
- p->vTable->getObjectOptions (obj);
- if (triggerEdgeLeaveBindings (display, options,
- state, edge, o))
+ p->vTable->getObjectOptions (screen);
+ if (triggerEdgeLeaveBindings (options, state, edge, o))
return true;
}
}
}
- else if (event->xclient.message_type == atoms.xdndPosition)
+ else if (event->xclient.message_type == Atoms::xdndPosition)
{
unsigned int edge = 0;
CompAction::State state;
- Window root = None;
if (xdndWindow == event->xclient.window)
{
CompWindow *w;
- w = display->findWindow (event->xclient.window);
+ w = screen->findWindow (event->xclient.window);
if (w)
{
- CompScreen *s = w->screen ();
unsigned int i;
for (i = 0; i < SCREEN_EDGE_NUM; i++)
{
- if (xdndWindow == s->screenEdge (i).id)
+ if (xdndWindow == screenEdge[i].id)
{
edge = 1 << i;
- root = s->root ();
break;
}
}
@@ -928,7 +900,7 @@ PrivateDisplay::handleActionEvent (XEvent *event)
foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
CompOption::Vector &options =
- p->vTable->getObjectOptions (obj);
+ p->vTable->getObjectOptions (screen);
if (triggerStateNotifyBindings (options, stateEvent, o))
return true;
}
@@ -946,8 +918,8 @@ PrivateDisplay::handleActionEvent (XEvent *event)
foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
CompOption::Vector &options =
- p->vTable->getObjectOptions (obj);
- if (triggerBellNotifyBindings (display, options, o))
+ p->vTable->getObjectOptions (screen);
+ if (triggerBellNotifyBindings (options, o))
return true;
}
}
@@ -959,45 +931,40 @@ PrivateDisplay::handleActionEvent (XEvent *event)
}
void
-CompDisplay::handleCompizEvent (const char *plugin,
- const char *event,
- CompOption::Vector &options)
- WRAPABLE_HND_FUNC(1, handleCompizEvent, plugin, event, options)
+CompScreen::handleCompizEvent (const char *plugin,
+ const char *event,
+ CompOption::Vector &options)
+ WRAPABLE_HND_FUNC(9, handleCompizEvent, plugin, event, options)
void
-CompDisplay::handleEvent (XEvent *event)
+CompScreen::handleEvent (XEvent *event)
{
- WRAPABLE_HND_FUNC(0, handleEvent, event)
+ WRAPABLE_HND_FUNC(8, handleEvent, event)
- CompScreen *s;
CompWindow *w;
switch (event->type) {
case ButtonPress:
- s = findScreen (event->xbutton.root);
- if (s)
- s->setCurrentOutput (
- s->outputDeviceForPoint (event->xbutton.x_root,
- event->xbutton.y_root));
+ if (event->xbutton.root == priv->root)
+ setCurrentOutput (outputDeviceForPoint (event->xbutton.x_root,
+ event->xbutton.y_root));
break;
case MotionNotify:
- s = findScreen (event->xmotion.root);
- if (s)
- s->setCurrentOutput (
- s->outputDeviceForPoint (event->xmotion.x_root,
- event->xmotion.y_root));
+ if (event->xmotion.root == priv->root)
+ setCurrentOutput (outputDeviceForPoint (event->xmotion.x_root,
+ event->xmotion.y_root));
break;
case KeyPress:
w = findWindow (priv->activeWindow);
if (w)
- w->screen ()->setCurrentOutput (w->outputDevice ());
+ setCurrentOutput (w->outputDevice ());
default:
break;
}
if (priv->handleActionEvent (event))
{
- if (!priv->screens.front ()->hasGrab ())
+ if (priv->grabs.empty ())
XAllowEvents (priv->dpy, AsyncPointer, event->xbutton.time);
return;
@@ -1026,20 +993,19 @@ CompDisplay::handleEvent (XEvent *event)
}
else
{
- s = findScreen (event->xconfigure.window);
- if (s)
- s->configure (&event->xconfigure);
+ if (event->xconfigure.window == priv->root)
+ configure (&event->xconfigure);
}
}
break;
case CreateNotify:
- s = findScreen (event->xcreatewindow.parent);
w = findTopLevelWindow (event->xcreatewindow.window, true);
- if (s && (!w || w->frame () != event->xcreatewindow.window))
+ if (event->xcreatewindow.parent == priv->root &&
+ (!w || w->frame () != event->xcreatewindow.window))
{
- new CompWindow (s, event->xcreatewindow.window,
- s->getTopWindow ());
+ new CompWindow (screen, event->xcreatewindow.window,
+ getTopWindow ());
}
break;
case DestroyNotify:
@@ -1104,12 +1070,11 @@ CompDisplay::handleEvent (XEvent *event)
break;
case ReparentNotify:
w = findWindow (event->xreparent.window);
- s = findScreen (event->xreparent.parent);
- if (s && !w)
+ if (!w)
{
- new CompWindow (s, event->xreparent.window, s->getTopWindow ());
+ new CompWindow (this, event->xreparent.window, getTopWindow ());
}
- else if (w && !s && event->xreparent.parent != w->wrapper ())
+ else if (w && event->xreparent.parent != w->wrapper ())
{
/* This is the only case where a window is removed but not
destroyed. We must remove our event mask and all passive
@@ -1129,18 +1094,16 @@ CompDisplay::handleEvent (XEvent *event)
w->circulate (&event->xcirculate);
break;
case ButtonPress:
- s = findScreen (event->xbutton.root);
- if (s)
+ if (event->xbutton.root == priv->root)
{
if (event->xbutton.button == Button1 ||
event->xbutton.button == Button2 ||
event->xbutton.button == Button3)
{
- w = s->findTopLevelWindow (event->xbutton.window);
+ w = findTopLevelWindow (event->xbutton.window);
if (w)
{
- if (priv->opt[COMP_DISPLAY_OPTION_RAISE_ON_CLICK].
- value ().b ())
+ if (priv->opt[COMP_OPTION_RAISE_ON_CLICK].value ().b ())
w->updateAttributes (
CompStackingUpdateModeAboveFullscreen);
@@ -1150,12 +1113,12 @@ CompDisplay::handleEvent (XEvent *event)
}
}
- if (!s->hasGrab ())
+ if (priv->grabs.empty ())
XAllowEvents (priv->dpy, ReplayPointer, event->xbutton.time);
}
break;
case PropertyNotify:
- if (event->xproperty.atom == priv->atoms.winType)
+ if (event->xproperty.atom == Atoms::winType)
{
w = findWindow (event->xproperty.window);
if (w)
@@ -1189,7 +1152,7 @@ CompDisplay::handleEvent (XEvent *event)
}
}
}
- else if (event->xproperty.atom == priv->atoms.winState)
+ else if (event->xproperty.atom == Atoms::winState)
{
w = findWindow (event->xproperty.window);
if (w && !w->managed ())
@@ -1234,20 +1197,20 @@ CompDisplay::handleEvent (XEvent *event)
w->recalcActions ();
}
}
- else if (event->xproperty.atom == priv->atoms.wmClientLeader)
+ else if (event->xproperty.atom == Atoms::wmClientLeader)
{
w = findWindow (event->xproperty.window);
if (w)
w->clientLeader () = w->getClientLeader ();
}
- else if (event->xproperty.atom == priv->atoms.wmIconGeometry)
+ else if (event->xproperty.atom == Atoms::wmIconGeometry)
{
w = findWindow (event->xproperty.window);
if (w)
w->updateIconGeometry ();
}
- else if (event->xproperty.atom == priv->atoms.wmStrut ||
- event->xproperty.atom == priv->atoms.wmStrutPartial)
+ else if (event->xproperty.atom == Atoms::wmStrut ||
+ event->xproperty.atom == Atoms::wmStrutPartial)
{
w = findWindow (event->xproperty.window);
if (w)
@@ -1256,25 +1219,25 @@ CompDisplay::handleEvent (XEvent *event)
w->screen ()->updateWorkarea ();
}
}
- else if (event->xproperty.atom == priv->atoms.mwmHints)
+ else if (event->xproperty.atom == Atoms::mwmHints)
{
w = findWindow (event->xproperty.window);
if (w)
w->updateMwmHints ();
}
- else if (event->xproperty.atom == priv->atoms.wmProtocols)
+ else if (event->xproperty.atom == Atoms::wmProtocols)
{
w = findWindow (event->xproperty.window);
if (w)
w->protocols () = getProtocols (w->id ());
}
- else if (event->xproperty.atom == priv->atoms.wmIcon)
+ else if (event->xproperty.atom == Atoms::wmIcon)
{
w = findWindow (event->xproperty.window);
if (w)
w->freeIcons ();
}
- else if (event->xproperty.atom == priv->atoms.startupId)
+ else if (event->xproperty.atom == Atoms::startupId)
{
w = findWindow (event->xproperty.window);
if (w)
@@ -1290,7 +1253,7 @@ CompDisplay::handleEvent (XEvent *event)
case MotionNotify:
break;
case ClientMessage:
- if (event->xclient.message_type == priv->atoms.winActive)
+ if (event->xclient.message_type == Atoms::winActive)
{
w = findWindow (event->xclient.window);
if (w)
@@ -1304,7 +1267,7 @@ CompDisplay::handleEvent (XEvent *event)
}
}
}
- else if (event->xclient.message_type == priv->atoms.winState)
+ else if (event->xclient.message_type == Atoms::winState)
{
w = findWindow (event->xclient.window);
if (w)
@@ -1365,40 +1328,39 @@ CompDisplay::handleEvent (XEvent *event)
}
}
}
- else if (event->xclient.message_type == priv->atoms.wmProtocols)
+ else if (event->xclient.message_type == Atoms::wmProtocols)
{
- if ((unsigned long) event->xclient.data.l[0] == priv->atoms.wmPing)
+ if ((unsigned long) event->xclient.data.l[0] == Atoms::wmPing)
{
w = findWindow (event->xclient.data.l[2]);
if (w)
w->handlePing (priv->lastPing);
}
}
- else if (event->xclient.message_type == priv->atoms.closeWindow)
+ else if (event->xclient.message_type == Atoms::closeWindow)
{
w = findWindow (event->xclient.window);
if (w)
w->close (event->xclient.data.l[0]);
}
- else if (event->xclient.message_type == priv->atoms.desktopGeometry)
+ else if (event->xclient.message_type == Atoms::desktopGeometry)
{
- s = findScreen (event->xclient.window);
- if (s)
+ if (event->xclient.window == priv->root)
{
CompOption::Value value;
value.set ((int) (event->xclient.data.l[0] /
- s->size ().width ()));
+ priv->size.width ()));
- core->setOptionForPlugin (s, "core", "hsize", value);
+ setOptionForPlugin (this, "core", "hsize", value);
value.set ((int) (event->xclient.data.l[1] /
- s->size ().height ()));
+ priv->size.height ()));
- core->setOptionForPlugin (s, "core", "vsize", value);
+ setOptionForPlugin (this, "core", "vsize", value);
}
}
- else if (event->xclient.message_type == priv->atoms.moveResizeWindow)
+ else if (event->xclient.message_type == Atoms::moveResizeWindow)
{
w = findWindow (event->xclient.window);
if (w)
@@ -1438,7 +1400,7 @@ CompDisplay::handleEvent (XEvent *event)
w->moveResize (&xwc, xwcm, gravity);
}
}
- else if (event->xclient.message_type == priv->atoms.restackWindow)
+ else if (event->xclient.message_type == Atoms::restackWindow)
{
w = findWindow (event->xclient.window);
if (w)
@@ -1466,7 +1428,7 @@ CompDisplay::handleEvent (XEvent *event)
}
}
}
- else if (event->xclient.message_type == priv->atoms.wmChangeState)
+ else if (event->xclient.message_type == Atoms::wmChangeState)
{
w = findWindow (event->xclient.window);
if (w)
@@ -1480,40 +1442,34 @@ CompDisplay::handleEvent (XEvent *event)
w->unminimize ();
}
}
- else if (event->xclient.message_type == priv->atoms.showingDesktop)
+ else if (event->xclient.message_type == Atoms::showingDesktop)
{
- foreach (s, priv->screens)
+ if (event->xclient.window == priv->root ||
+ event->xclient.window == None)
{
- if (event->xclient.window == s->root () ||
- event->xclient.window == None)
- {
- if (event->xclient.data.l[0])
- s->enterShowDesktopMode ();
- else
- s->leaveShowDesktopMode (NULL);
- }
+ if (event->xclient.data.l[0])
+ enterShowDesktopMode ();
+ else
+ leaveShowDesktopMode (NULL);
}
}
- else if (event->xclient.message_type == priv->atoms.numberOfDesktops)
+ else if (event->xclient.message_type == Atoms::numberOfDesktops)
{
- s = findScreen (event->xclient.window);
- if (s)
+ if (event->xclient.window == priv->root)
{
CompOption::Value value;
value.set ((int) event->xclient.data.l[0]);
- core->setOptionForPlugin (s, "core", "number_of_desktops",
- value);
+ setOptionForPlugin (this, "core", "number_of_desktops", value);
}
}
- else if (event->xclient.message_type == priv->atoms.currentDesktop)
+ else if (event->xclient.message_type == Atoms::currentDesktop)
{
- s = findScreen (event->xclient.window);
- if (s)
- s->setCurrentDesktop (event->xclient.data.l[0]);
+ if (event->xclient.window == priv->root)
+ setCurrentDesktop (event->xclient.data.l[0]);
}
- else if (event->xclient.message_type == priv->atoms.winDesktop)
+ else if (event->xclient.message_type == Atoms::winDesktop)
{
w = findWindow (event->xclient.window);
if (w)
@@ -1544,7 +1500,7 @@ CompDisplay::handleEvent (XEvent *event)
if (doMapProcessing)
w->processMap ();
- setWindowProp (w->id (), priv->atoms.winDesktop, w->desktop ());
+ setWindowProp (w->id (), Atoms::winDesktop, w->desktop ());
}
else
{
@@ -1646,7 +1602,7 @@ CompDisplay::handleEvent (XEvent *event)
w->screen ()->addToCurrentActiveWindowHistory (w->id ());
XChangeProperty (priv->dpy , w->screen ()->root (),
- priv->atoms.winActive,
+ Atoms::winActive,
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) &priv->activeWindow, 1);
}
@@ -1657,7 +1613,7 @@ CompDisplay::handleEvent (XEvent *event)
}
break;
case EnterNotify:
- if (!priv->screens.front ()->hasGrab () &&
+ if (priv->grabs.empty () &&
event->xcrossing.mode != NotifyGrab &&
event->xcrossing.mode != NotifyUngrab &&
event->xcrossing.detail != NotifyInferior)
@@ -1665,14 +1621,13 @@ CompDisplay::handleEvent (XEvent *event)
Bool raise;
int delay;
- raise = priv->opt[COMP_DISPLAY_OPTION_AUTORAISE].value ().b ();
+ raise = priv->opt[COMP_OPTION_AUTORAISE].value ().b ();
delay =
- priv->opt[COMP_DISPLAY_OPTION_AUTORAISE_DELAY].value ().i ();
+ priv->opt[COMP_OPTION_AUTORAISE_DELAY].value ().i ();
- s = findScreen (event->xcrossing.root);
- if (s)
+ if (event->xcrossing.root == priv->root)
{
- w = s->findTopLevelWindow (event->xcrossing.window);
+ w = findTopLevelWindow (event->xcrossing.window);
}
else
w = NULL;
@@ -1681,8 +1636,7 @@ CompDisplay::handleEvent (XEvent *event)
{
priv->below = w->id ();
- if (!priv->opt[COMP_DISPLAY_OPTION_CLICK_TO_FOCUS].
- value ().b ())
+ if (!priv->opt[COMP_OPTION_CLICK_TO_FOCUS].value ().b ())
{
if (priv->autoRaiseTimer.active () &&
priv->autoRaiseWindow != w->id ())
@@ -1741,15 +1695,13 @@ CompDisplay::handleEvent (XEvent *event)
sa = (XSyncAlarmNotifyEvent *) event;
- foreach (s, priv->screens)
+
+ foreach (w, priv->windows)
{
- foreach (w, s->windows ())
+ if (w->syncAlarm () == sa->alarm)
{
- if (w->syncAlarm () == sa->alarm)
- {
- w->handleSyncAlarm ();
- return;
- }
+ w->handleSyncAlarm ();
+ return;
}
}
}
diff --git a/src/main.cpp b/src/main.cpp
index cb7c675..806ff40 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -37,9 +37,7 @@
#include <sys/wait.h>
#include <compiz-core.h>
-#include "privatedisplay.h"
#include "privatescreen.h"
-#include "privatecore.h"
char *programName;
char **programArgv;
@@ -60,7 +58,6 @@ bool indirectRendering = false;
bool strictBinding = true;
bool noDetection = false;
bool useDesktopHints = true;
-bool onlyCurrentScreen = false;
bool useCow = true;
@@ -79,7 +76,6 @@ usage (void)
"[--sm-client-id ID] "
"[--no-detection]\n "
"[--ignore-desktop-hints] "
- "[--only-current-screen]"
" [--use-root-window]\n "
"[--version] "
"[--help] "
@@ -122,15 +118,15 @@ readCoreXmlCallback (void *context,
unsigned int offset = ctx->offset;
unsigned int i, j;
- i = CompMetadata::readXmlChunk ("<compiz><core><display>", &offset, buffer,
+ i = CompMetadata::readXmlChunk ("<compiz><core><options>", &offset, buffer,
length);
- for (j = 0; j < COMP_DISPLAY_OPTION_NUM; j++)
+ for (j = 0; j < COMP_OPTION_NUM; j++)
{
- CompMetadata::OptionInfo info = coreDisplayOptionInfo[j];
+ CompMetadata::OptionInfo info = coreOptionInfo[j];
switch (j) {
- case COMP_DISPLAY_OPTION_ACTIVE_PLUGINS:
+ case COMP_OPTION_ACTIVE_PLUGINS:
if (ctx->pluginData)
info.data = ctx->pluginData;
break;
@@ -142,7 +138,7 @@ readCoreXmlCallback (void *context,
buffer + i, length - i);
}
- i += CompMetadata::readXmlChunk ("</display></core></compiz>", &offset,
+ i += CompMetadata::readXmlChunk ("</options></core></compiz>", &offset,
buffer + i, length - 1);
if (!offset && length > (int)i)
@@ -218,10 +214,6 @@ main (int argc, char **argv)
{
useDesktopHints = FALSE;
}
- else if (!strcmp (argv[i], "--only-current-screen"))
- {
- onlyCurrentScreen = TRUE;
- }
else if (!strcmp (argv[i], "--use-root-window"))
{
useCow = FALSE;
@@ -250,7 +242,7 @@ main (int argc, char **argv)
}
else if (*argv[i] == '-')
{
- compLogMessage (NULL, "core", CompLogLevelWarn,
+ compLogMessage ("core", CompLogLevelWarn,
"Unknown option '%s'\n", argv[i]);
}
else
@@ -295,26 +287,23 @@ main (int argc, char **argv)
coreMetadata->addFromFile ("core");
- core = new CompCore();
+ screen = new CompScreen();
- if (!core)
+ if (!screen)
return 1;
- if (!core->init ())
+ if (!screen->init (displayName))
return 1;
if (!disableSm)
CompSession::initSession (clientId);
- if (!core->addDisplay (displayName))
- return 1;
-
- core->eventLoop ();
+ screen->eventLoop ();
if (!disableSm)
CompSession::closeSession ();
- delete core;
+ delete screen;
delete coreMetadata;
xmlCleanupParser ();
diff --git a/src/match.cpp b/src/match.cpp
index ca82d18..45c4ef3 100644
--- a/src/match.cpp
+++ b/src/match.cpp
@@ -30,7 +30,6 @@
#define foreach BOOST_FOREACH
#include <compiz-core.h>
-#include "privatedisplay.h"
#include <compscreen.h>
#include <compmatch.h>
@@ -59,7 +58,7 @@ class CoreExp : public CompMatch::Expression {
else if (str.compare (0, 6, "state=") == 0)
{
mType = TypeState;
- priv.uval = CompDisplay::windowStateFromString
+ priv.uval = CompScreen::windowStateFromString
(str.substr (6).c_str ());
}
else if (str.compare (0, 18, "override_redirect=") == 0)
@@ -104,9 +103,9 @@ class CoreExp : public CompMatch::Expression {
};
CompMatch::Expression *
-CompDisplay::matchInitExp (const CompString str)
+CompScreen::matchInitExp (const CompString str)
{
- WRAPABLE_HND_FUNC_RETURN(4, CompMatch::Expression *, matchInitExp, str)
+ WRAPABLE_HND_FUNC_RETURN(12, CompMatch::Expression *, matchInitExp, str)
return new CoreExp (str);
}
@@ -118,16 +117,13 @@ matchUpdateMatchOptions (CompOption::Vector options)
{
switch (option.type ()) {
case CompOption::TypeMatch:
- if (option.value ().match ().display ())
- option.value ().match ().update (
- option.value ().match ().display ());
+ option.value ().match ().update ();
break;
case CompOption::TypeList:
if (option.value ().listType () == CompOption::TypeMatch)
{
foreach (CompOption::Value &value, option.value ().list ())
- if (value.match ().display ())
- value.match ().update (value.match ().display ());
+ value.match ().update ();
}
default:
break;
@@ -136,30 +132,21 @@ matchUpdateMatchOptions (CompOption::Vector options)
}
void
-CompDisplay::matchExpHandlerChanged ()
+CompScreen::matchExpHandlerChanged ()
{
- WRAPABLE_HND_FUNC(5, matchExpHandlerChanged)
+ WRAPABLE_HND_FUNC(13, matchExpHandlerChanged)
foreach (CompPlugin *p, CompPlugin::getPlugins ())
{
CompOption::Vector &options = p->vTable->getObjectOptions (this);
matchUpdateMatchOptions (options);
}
-
- foreach (CompScreen *s, priv->screens)
- {
- foreach (CompPlugin *p, CompPlugin::getPlugins ())
- {
- CompOption::Vector &options = p->vTable->getObjectOptions (s);
- matchUpdateMatchOptions (options);
- }
- }
}
void
-CompDisplay::matchPropertyChanged (CompWindow *w)
+CompScreen::matchPropertyChanged (CompWindow *w)
{
- WRAPABLE_HND_FUNC(6, matchPropertyChanged, w)
+ WRAPABLE_HND_FUNC(14, matchPropertyChanged, w)
}
@@ -435,20 +422,19 @@ matchOpsToString (MatchOp::List &list)
}
static void
-matchUpdateOps (CompDisplay *display,
- MatchOp::List &list)
+matchUpdateOps (MatchOp::List &list)
{
MatchExpOp *exp;
foreach (MatchOp &op, list)
{
switch (op.type ()) {
case MatchOp::TypeGroup:
- matchUpdateOps (display, dynamic_cast <MatchGroupOp &> (op).op);
+ matchUpdateOps (dynamic_cast <MatchGroupOp &> (op).op);
break;
case MatchOp::TypeExp:
exp = dynamic_cast <MatchExpOp *> (&op);
- if (exp)
- exp->e.reset (display->matchInitExp (exp->value));
+ if (exp && screen)
+ exp->e.reset (screen->matchInitExp (exp->value));
break;
default:
break;
@@ -528,8 +514,7 @@ MatchGroupOp::MatchGroupOp () :
}
PrivateMatch::PrivateMatch () :
- op (),
- display (NULL)
+ op ()
{
}
@@ -558,11 +543,10 @@ CompMatch::~CompMatch ()
}
void
-CompMatch::update (CompDisplay *display)
+CompMatch::update ()
{
matchResetOps (priv->op.op);
- matchUpdateOps (display, priv->op.op);
- priv->display = display;
+ matchUpdateOps (priv->op.op);
}
bool
@@ -577,17 +561,10 @@ CompMatch::toString ()
return matchOpsToString (priv->op.op);
}
-CompDisplay *
-CompMatch::display ()
-{
- return priv->display;
-}
-
CompMatch &
CompMatch::operator= (const CompMatch &match)
{
priv->op = match.priv->op;
- priv->display = match.priv->display;
return *this;
}
diff --git a/src/metadata.cpp b/src/metadata.cpp
index 5859e1c..c805c26 100644
--- a/src/metadata.cpp
+++ b/src/metadata.cpp
@@ -35,7 +35,6 @@
#include <compiz.h>
#include <compmetadata.h>
-#include <compdisplay.h>
#include <compscreen.h>
#define HOME_METADATADIR ".compiz/metadata"
@@ -70,10 +69,8 @@ readXmlFile (CompString name,
typedef struct _CompIOCtx {
unsigned int offset;
const char *name;
- const CompMetadata::OptionInfo *displayOInfo;
- unsigned int nDisplayOInfo;
- const CompMetadata::OptionInfo *screenOInfo;
- unsigned int nScreenOInfo;
+ const CompMetadata::OptionInfo *oInfo;
+ unsigned int nOInfo;
} CompIOCtx;
typedef struct _CompXPath {
@@ -98,29 +95,16 @@ readPluginXmlCallback (void *context,
length - i);
i += CompMetadata::readXmlChunk ("\">", &offset, buffer + i, length - i);
- if (ctx->nDisplayOInfo)
+ if (ctx->nOInfo)
{
- i += CompMetadata::readXmlChunk ("<display>", &offset, buffer + i,
+ i += CompMetadata::readXmlChunk ("<options>", &offset, buffer + i,
length - i);
- for (j = 0; j < ctx->nDisplayOInfo; j++)
+ for (j = 0; j < ctx->nOInfo; j++)
i += CompMetadata::readXmlChunkFromOptionInfo (
- &ctx->displayOInfo[j], &offset, buffer + i, length - i);
+ &ctx->oInfo[j], &offset, buffer + i, length - i);
- i += CompMetadata::readXmlChunk ("</display>", &offset, buffer + i,
- length - i);
- }
-
- if (ctx->nScreenOInfo)
- {
- i += CompMetadata::readXmlChunk ("<screen>", &offset, buffer + i,
- length - i);
-
- for (j = 0; j < ctx->nScreenOInfo; j++)
- i += CompMetadata::readXmlChunkFromOptionInfo (
- &ctx->screenOInfo[j], &offset, buffer + i, length - i);
-
- i += CompMetadata::readXmlChunk ("</screen>", &offset, buffer + i,
+ i += CompMetadata::readXmlChunk ("</options>", &offset, buffer + i,
length - i);
}
@@ -354,8 +338,7 @@ initColorValue (CompOption::Value &v,
}
static void
-initActionValue (CompDisplay *d,
- CompOption::Value &v,
+initActionValue (CompOption::Value &v,
CompAction::State state,
xmlDocPtr doc,
xmlNodePtr node)
@@ -365,8 +348,7 @@ initActionValue (CompDisplay *d,
}
static void
-initKeyValue (CompDisplay *d,
- CompOption::Value &v,
+initKeyValue (CompOption::Value &v,
CompAction::State state,
xmlDocPtr doc,
xmlNodePtr node)
@@ -385,7 +367,7 @@ initKeyValue (CompDisplay *d,
char *binding = (char *) value;
if (strcasecmp (binding, "disabled") && *binding)
- action.keyFromString (d, binding);
+ action.keyFromString (binding);
xmlFree (value);
}
@@ -393,15 +375,11 @@ initKeyValue (CompDisplay *d,
v.set (action);
if (state & CompAction::StateAutoGrab)
- {
- foreach (CompScreen *s, d->screens ())
- s->addAction (&v.action ());
- }
+ screen->addAction (&v.action ());
}
static void
-initButtonValue (CompDisplay *d,
- CompOption::Value &v,
+initButtonValue (CompOption::Value &v,
CompAction::State state,
xmlDocPtr doc,
xmlNodePtr node)
@@ -422,7 +400,7 @@ initButtonValue (CompDisplay *d,
char *binding = (char *) value;
if (strcasecmp (binding, "disabled") && *binding)
- action.buttonFromString (d, binding);
+ action.buttonFromString (binding);
xmlFree (value);
}
@@ -430,15 +408,11 @@ initButtonValue (CompDisplay *d,
v.set (action);
if (state & CompAction::StateAutoGrab)
- {
- foreach (CompScreen *s, d->screens ())
- s->addAction (&v.action ());
- }
+ screen->addAction (&v.action ());
}
static void
-initEdgeValue (CompDisplay *d,
- CompOption::Value &v,
+initEdgeValue (CompOption::Value &v,
CompAction::State state,
xmlDocPtr doc,
xmlNodePtr node)
@@ -473,15 +447,11 @@ initEdgeValue (CompDisplay *d,
v.set (action);
if (state & CompAction::StateAutoGrab)
- {
- foreach (CompScreen *s, d->screens ())
- s->addAction (&v.action ());
- }
+ screen->addAction (&v.action ());
}
static void
-initBellValue (CompDisplay *d,
- CompOption::Value &v,
+initBellValue (CompOption::Value &v,
CompAction::State state,
xmlDocPtr doc,
xmlNodePtr node)
@@ -506,8 +476,7 @@ initBellValue (CompDisplay *d,
}
static void
-initMatchValue (CompDisplay *d,
- CompOption::Value &v,
+initMatchValue (CompOption::Value &v,
bool helper,
xmlDocPtr doc,
xmlNodePtr node)
@@ -527,12 +496,11 @@ initMatchValue (CompDisplay *d,
}
if (!helper)
- v.match ().update (d);
+ v.match ().update ();
}
static void
-initListValue (CompDisplay *d,
- CompOption::Value &v,
+initListValue (CompOption::Value &v,
CompOption::Restriction &r,
CompAction::State state,
bool helper,
@@ -570,22 +538,22 @@ initListValue (CompDisplay *d,
initColorValue (value, doc, child);
break;
case CompOption::TypeAction:
- initActionValue (d, value, state, doc, child);
+ initActionValue (value, state, doc, child);
break;
case CompOption::TypeKey:
- initKeyValue (d, value, state, doc, child);
+ initKeyValue (value, state, doc, child);
break;
case CompOption::TypeButton:
- initButtonValue (d, value, state, doc, child);
+ initButtonValue (value, state, doc, child);
break;
case CompOption::TypeEdge:
- initEdgeValue (d, value, state, doc, child);
+ initEdgeValue (value, state, doc, child);
break;
case CompOption::TypeBell:
- initBellValue (d, value, state, doc, child);
+ initBellValue (value, state, doc, child);
break;
case CompOption::TypeMatch:
- initMatchValue (d, value, helper, doc, child);
+ initMatchValue (value, helper, doc, child);
default:
break;
}
@@ -749,8 +717,7 @@ initActionState (CompMetadata *metadata,
}
static bool
-initOptionFromMetadataPath (CompDisplay *d,
- CompMetadata *metadata,
+initOptionFromMetadataPath (CompMetadata *metadata,
CompOption *option,
const xmlChar *path)
{
@@ -816,33 +783,33 @@ initOptionFromMetadataPath (CompDisplay *d,
break;
case CompOption::TypeAction:
initActionState (metadata, option->type (), &state, (char *) path);
- initActionValue (d, option->value (), state,
+ initActionValue (option->value (), state,
defaultDoc, defaultNode);
break;
case CompOption::TypeKey:
initActionState (metadata, option->type (), &state, (char *) path);
- initKeyValue (d, option->value (), state,
+ initKeyValue (option->value (), state,
defaultDoc, defaultNode);
break;
case CompOption::TypeButton:
initActionState (metadata, option->type (), &state, (char *) path);
- initButtonValue (d, option->value (), state,
+ initButtonValue (option->value (), state,
defaultDoc, defaultNode);
break;
case CompOption::TypeEdge:
initActionState (metadata, option->type (), &state, (char *) path);
- initEdgeValue (d, option->value (), state,
+ initEdgeValue (option->value (), state,
defaultDoc, defaultNode);
break;
case CompOption::TypeBell:
initActionState (metadata, option->type (), &state, (char *) path);
- initBellValue (d, option->value (), state,
+ initBellValue (option->value (), state,
defaultDoc, defaultNode);
break;
case CompOption::TypeMatch:
helper = boolFromMetadataPathElement (metadata, (char *) path,
"helper", false);
- initMatchValue (d, option->value (), helper,
+ initMatchValue (option->value (), helper,
defaultDoc, defaultNode);
break;
case CompOption::TypeList:
@@ -883,8 +850,8 @@ initOptionFromMetadataPath (CompDisplay *d,
break;
}
- initListValue (d, option->value (), option->rest (), state, helper,
- defaultDoc, defaultNode);
+ initListValue (option->value (), option->rest (), state, helper,
+ defaultDoc, defaultNode);
break;
}
@@ -905,23 +872,19 @@ CompMetadata::CompMetadata () :
}
CompMetadata::CompMetadata (CompString plugin,
- const OptionInfo *displayOptionInfo,
- unsigned int nDisplayOptionInfo,
- const OptionInfo *screenOptionInfo,
- unsigned int nScreenOptionInfo) :
+ const OptionInfo *optionInfo,
+ unsigned int nOptionInfo) :
mPath (compPrintf ("plugin[@name=\"%s\"]", plugin.c_str ())),
mDoc (0)
{
- if (nDisplayOptionInfo || nScreenOptionInfo)
+ if (nOptionInfo)
{
CompIOCtx ctx;
ctx.offset = 0;
ctx.name = plugin.c_str ();
- ctx.displayOInfo = displayOptionInfo;
- ctx.nDisplayOInfo = nDisplayOptionInfo;
- ctx.screenOInfo = screenOptionInfo;
- ctx.nScreenOInfo = nScreenOptionInfo;
+ ctx.oInfo = optionInfo;
+ ctx.nOInfo = nOptionInfo;
addFromIO (readPluginXmlCallback, NULL, (void *) &ctx);
}
@@ -968,7 +931,7 @@ CompMetadata::addFromFile (CompString file)
if (!status)
{
- compLogMessage (NULL, "core", CompLogLevelWarn,
+ compLogMessage ("core", CompLogLevelWarn,
"Unable to parse XML metadata from file \"%s%s\"",
file.c_str (), EXTENSION);
@@ -986,7 +949,7 @@ CompMetadata::addFromString (CompString string)
doc = xmlReadMemory (string.c_str (), string.size (), NULL, NULL, 0);
if (!doc)
{
- compLogMessage (NULL, "core", CompLogLevelWarn,
+ compLogMessage ("core", CompLogLevelWarn,
"Unable to parse XML metadata");
return false;
@@ -1007,7 +970,7 @@ CompMetadata::addFromIO (xmlInputReadCallback ioread,
doc = xmlReadIO (ioread, ioclose, ioctx, NULL, NULL, 0);
if (!doc)
{
- compLogMessage (NULL, "core", CompLogLevelWarn,
+ compLogMessage ("core", CompLogLevelWarn,
"Unable to parse XML metadata");
return false;
@@ -1019,73 +982,29 @@ CompMetadata::addFromIO (xmlInputReadCallback ioread,
}
bool
-CompMetadata::initScreenOption (CompScreen *screen,
- CompOption *option,
- CompString name)
-{
- char str[1024];
-
- sprintf (str, "/compiz/%s/screen//option[@name=\"%s\"]",
- mPath.c_str (), name.c_str ());
-
- return initOptionFromMetadataPath (screen->display (), this,
- option, BAD_CAST str);
-}
-
-bool
-CompMetadata::initDisplayOption (CompDisplay *display,
- CompOption *option,
- CompString name)
+CompMetadata::initOption (CompOption *option,
+ CompString name)
{
char str[1024];
- sprintf (str, "/compiz/%s/display//option[@name=\"%s\"]",
+ sprintf (str, "/compiz/%s/options//option[@name=\"%s\"]",
mPath.c_str (), name.c_str ());
- return initOptionFromMetadataPath (display, this, option, BAD_CAST str);
+ return initOptionFromMetadataPath (this, option, BAD_CAST str);
}
bool
-CompMetadata::initScreenOptions (CompScreen *screen,
- const OptionInfo *info,
- unsigned int nOptions,
- CompOption::Vector &opt)
+CompMetadata::initOptions (const OptionInfo *info,
+ unsigned int nOptions,
+ CompOption::Vector &opt)
{
if (opt.size () < nOptions)
opt.resize (nOptions);
for (unsigned int i = 0; i < nOptions; i++)
{
- if (!initScreenOption (screen, &opt[i], info[i].name))
+ if (!initOption (&opt[i], info[i].name))
{
- CompOption::finiScreenOptions (screen, opt);
- return false;
- }
-
- if (info[i].initiate)
- opt[i].value ().action ().setInitiate (info[i].initiate);
-
- if (info[i].terminate)
- opt[i].value ().action ().setTerminate (info[i].terminate);
- }
-
- return true;
-}
-
-bool
-CompMetadata::initDisplayOptions (CompDisplay *display,
- const OptionInfo *info,
- unsigned int nOptions,
- CompOption::Vector &opt)
-{
- if (opt.size () < nOptions)
- opt.resize (nOptions);
-
- for (unsigned int i = 0; i < nOptions; i++)
- {
- if (!initDisplayOption (display, &opt[i], info[i].name))
- {
- CompOption::finiDisplayOptions (display, opt);
return false;
}
@@ -1114,40 +1033,24 @@ CompMetadata::getLongPluginDescription ()
}
CompString
-CompMetadata::getShortScreenOptionDescription (CompOption *option)
+CompMetadata::getShortOptionDescription (CompOption *option)
{
return getStringFromPath (
compPrintf (
- "/compiz/%s/screen//option[@name=\"%s\"]/short/child::text()",
+ "/compiz/%s/options//option[@name=\"%s\"]/short/child::text()",
mPath.c_str (), option->name ().c_str ()));
}
CompString
-CompMetadata::getLongScreenOptionDescription (CompOption *option)
+CompMetadata::getLongOptionDescription (CompOption *option)
{
return getStringFromPath (
compPrintf (
- "/compiz/%s/screen//option[@name=\"%s\"]/long/child::text()",
+ "/compiz/%s/options//option[@name=\"%s\"]/long/child::text()",
mPath.c_str (), option->name ().c_str ()));
}
-CompString
-CompMetadata::getShortDisplayOptionDescription (CompOption *option)
-{
- return getStringFromPath (
- compPrintf (
- "/compiz/%s/display//option[@name=\"%s\"]/short/child::text()",
- mPath.c_str (), option->name ().c_str ()));
-}
-CompString
-CompMetadata::getLongDisplayOptionDescription (CompOption *option)
-{
- return getStringFromPath (
- compPrintf (
- "/compiz/%s/display//option[@name=\"%s\"]/long/child::text()",
- mPath.c_str (), option->name ().c_str ()));
-}
CompString
CompMetadata::getStringFromPath (CompString path)
diff --git a/src/object.cpp b/src/object.cpp
index 7b13679..ca67da9 100644
--- a/src/object.cpp
+++ b/src/object.cpp
@@ -29,7 +29,6 @@
#include <boost/bind.hpp>
#include <compiz-core.h>
-#include <compcore.h>
#include "privateobject.h"
PrivateObject::PrivateObject () :
@@ -98,7 +97,7 @@ CompObject::addChild (CompObject *object)
return;
object->priv->parent = this;
priv->children.push_back (object);
- core->objectAdd (this, object);
+ screen->objectAdd (this, object);
}
void
@@ -115,7 +114,7 @@ CompObject::removeFromParent ()
if (it != priv->parent->priv->children.end ())
{
priv->parent->priv->children.erase (it);
- core->objectRemove (priv->parent, this);
+ screen->objectRemove (priv->parent, this);
}
}
}
@@ -168,7 +167,7 @@ CompObject::allocatePrivateIndex (CompObject::Type type,
iList->resize (i + 1);
iList->at (i) = true;
- resizePrivates (core, type, i + 1);
+ resizePrivates (screen, type, i + 1);
return i;
}
@@ -190,6 +189,6 @@ CompObject::freePrivateIndex (CompObject::Type type,
unsigned int i = iList->size () - 1;
iList->resize (i);
- resizePrivates (core, type, i);
+ resizePrivates (screen, type, i);
}
diff --git a/src/option.cpp b/src/option.cpp
index d100a8c..cc3b1a1 100644
--- a/src/option.cpp
+++ b/src/option.cpp
@@ -500,8 +500,54 @@ CompOption::CompOption (CompString name, CompOption::Type type) :
setName (name, type);
}
+static void
+finiScreenOptionValue (CompScreen *s,
+ CompOption::Value &v,
+ CompOption::Type type)
+{
+ switch (type) {
+ case CompOption::TypeAction:
+ case CompOption::TypeKey:
+ case CompOption::TypeButton:
+ case CompOption::TypeEdge:
+ case CompOption::TypeBell:
+if (v.action ().state () & CompAction::StateAutoGrab)
+ s->removeAction (&v.action ());
+ break;
+ case CompOption::TypeList:
+ foreach (CompOption::Value &val, v.list ())
+ finiScreenOptionValue (s, val, v.listType ());
+ default:
+ break;
+ }
+}
+
+static void
+finiOptionValue (CompOption::Value &v,
+ CompOption::Type type)
+{
+ switch (type) {
+ case CompOption::TypeAction:
+ case CompOption::TypeKey:
+ case CompOption::TypeButton:
+ case CompOption::TypeEdge:
+ case CompOption::TypeBell:
+ if (v.action ().state () & CompAction::StateAutoGrab && screen)
+ {
+ screen->removeAction (&v.action ());
+ }
+ break;
+ case CompOption::TypeList:
+ foreach (CompOption::Value &val, v.list ())
+ finiOptionValue (val, v.listType ());
+ default:
+ break;
+ }
+}
+
CompOption::~CompOption ()
{
+ finiOptionValue (priv->value, priv->type);
delete priv;
}
@@ -751,46 +797,19 @@ CompOption::typeToString (CompOption::Type type)
}
bool
-CompOption::setScreenOption (CompScreen *s,
- CompOption &o,
- CompOption::Value &value)
-{
- return o.set (value);
-}
-
-bool
-CompOption::setDisplayOption (CompDisplay *d,
- CompOption &o,
- CompOption::Value &value)
+CompOption::setOption (CompOption &o,
+ CompOption::Value &value)
{
if (o.isAction () &&
- o.value ().action ().state () & CompAction::StateAutoGrab)
+ o.value ().action ().state () & CompAction::StateAutoGrab && screen)
{
- CompScreen *s = NULL;
-
- foreach (CompScreen *ss, d->screens ())
- if (!ss->addAction (&value.action ()))
- {
- s = ss;
- break;
- }
-
- if (s)
+ if (!screen->addAction (&value.action ()))
{
-
- foreach (CompScreen *ss, d->screens ())
- {
- if (s == ss)
- break;
- ss->removeAction (&value.action ());
- }
-
return false;
}
else
{
- foreach (CompScreen *ss, d->screens ())
- ss->removeAction (&o.value ().action ());
+ screen->removeAction (&o.value ().action ());
}
return o.set (value);
@@ -799,70 +818,6 @@ CompOption::setDisplayOption (CompDisplay *d,
return o.set (value);
}
-static void
-finiScreenOptionValue (CompScreen *s,
- CompOption::Value &v,
- CompOption::Type type)
-{
- switch (type) {
- case CompOption::TypeAction:
- case CompOption::TypeKey:
- case CompOption::TypeButton:
- case CompOption::TypeEdge:
- case CompOption::TypeBell:
- if (v.action ().state () & CompAction::StateAutoGrab)
- s->removeAction (&v.action ());
- break;
- case CompOption::TypeList:
- foreach (CompOption::Value &val, v.list ())
- finiScreenOptionValue (s, val, v.listType ());
- default:
- break;
- }
-}
-
-static void
-finiDisplayOptionValue (CompDisplay *d,
- CompOption::Value &v,
- CompOption::Type type)
-{
- switch (type) {
- case CompOption::TypeAction:
- case CompOption::TypeKey:
- case CompOption::TypeButton:
- case CompOption::TypeEdge:
- case CompOption::TypeBell:
- if (v.action ().state () & CompAction::StateAutoGrab)
- {
- foreach (CompScreen *s, d->screens ())
- s->removeAction (&v.action ());
- }
- break;
- case CompOption::TypeList:
- foreach (CompOption::Value &val, v.list ())
- finiDisplayOptionValue (d, val, v.listType ());
- default:
- break;
- }
-}
-
-
-void
-CompOption::finiScreenOptions (CompScreen *s,
- CompOption::Vector &options)
-{
- foreach (CompOption &o, options)
- finiScreenOptionValue (s, o.value (), o.type ());
-}
-
-void
-CompOption::finiDisplayOptions (CompDisplay *d,
- CompOption::Vector &options)
-{
- foreach (CompOption &o, options)
- finiDisplayOptionValue (d, o.value (), o.type ());
-}
-
PrivateOption::PrivateOption () :
name (""),
type (CompOption::TypeBool),
diff --git a/src/plugin.cpp b/src/plugin.cpp
index 85313b6..60a0d4a 100644
--- a/src/plugin.cpp
+++ b/src/plugin.cpp
@@ -85,9 +85,7 @@ CompOption::Vector &
CorePluginVTable::getObjectOptions (CompObject *object)
{
static GetPluginObjectOptionsProc dispTab[] = {
- (GetPluginObjectOptionsProc) 0, /* GetCoreOptions */
- (GetPluginObjectOptionsProc) CompDisplay::getDisplayOptions,
- (GetPluginObjectOptionsProc) CompScreen::getScreenOptions
+ (GetPluginObjectOptionsProc) CompScreen::getOptions
};
RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab),
@@ -100,9 +98,7 @@ CorePluginVTable::setObjectOption (CompObject *object,
CompOption::Value &value)
{
static SetPluginObjectOptionProc dispTab[] = {
- (SetPluginObjectOptionProc) 0, /* SetCoreOption */
- (SetPluginObjectOptionProc) CompDisplay::setDisplayOption,
- (SetPluginObjectOptionProc) CompScreen::setScreenOption
+ (SetPluginObjectOptionProc) CompScreen::setOption
};
RETURN_DISPATCH (object, dispTab, ARRAY_SIZE (dispTab), false,
@@ -178,8 +174,7 @@ dlloaderLoadPlugin (CompPlugin *p,
error = dlerror ();
if (error)
{
- compLogMessage (NULL, "core", CompLogLevelError,
- "dlsym: %s", error);
+ compLogMessage ("core", CompLogLevelError, "dlsym: %s", error);
getInfo = 0;
}
@@ -189,9 +184,8 @@ dlloaderLoadPlugin (CompPlugin *p,
p->vTable = (*getInfo) ();
if (!p->vTable)
{
- compLogMessage (NULL, "core", CompLogLevelError,
- "Couldn't get vtable from '%s' plugin",
- file);
+ compLogMessage ("core", CompLogLevelError,
+ "Couldn't get vtable from '%s' plugin", file);
dlclose (dlhand);
free (file);
@@ -304,7 +298,7 @@ initObjectTree (CompObject *object,
if (!p->vTable->initObject (object))
{
- compLogMessage (NULL, p->vTable->name (), CompLogLevelError,
+ compLogMessage (p->vTable->name (), CompLogLevelError,
"InitObject failed");
return false;
}
@@ -319,7 +313,7 @@ initObjectTree (CompObject *object,
return false;
}
- if (!core->initPluginForObject (p, object))
+ if (!screen->initPluginForObject (p, object))
{
object->forEachChild (boost::bind (finiObjectTree, _1, &ctx));
p->vTable->finiObject (object);
@@ -348,7 +342,7 @@ finiObjectTree (CompObject *object,
p->vTable->finiObject (object);
- core->finiPluginForObject (p, object);
+ screen->finiPluginForObject (p, object);
return true;
}
@@ -360,7 +354,7 @@ initPlugin (CompPlugin *p)
if (!p->vTable->init ())
{
- compLogMessage (NULL, "core", CompLogLevelError,
+ compLogMessage ("core", CompLogLevelError,
"InitPlugin '%s' failed", p->vTable->name ());
return false;
}
@@ -368,7 +362,7 @@ initPlugin (CompPlugin *p)
ctx.plugin = p;
ctx.object = NULL;
- if (!initObjectTree (core, &ctx))
+ if (!initObjectTree (screen, &ctx))
{
p->vTable->fini ();
return false;
@@ -385,7 +379,7 @@ finiPlugin (CompPlugin *p)
ctx.plugin = p;
ctx.object = NULL;
- finiObjectTree (core, &ctx);
+ finiObjectTree (screen, &ctx);
p->vTable->fini ();
}
@@ -498,7 +492,7 @@ CompPlugin::load (const char *name)
if (status)
return p;
- compLogMessage (NULL, "core", CompLogLevelError,
+ compLogMessage ("core", CompLogLevelError,
"Couldn't load plugin '%s'", name);
return 0;
@@ -514,7 +508,7 @@ CompPlugin::push (CompPlugin *p)
if (!insertRet.second)
{
- compLogMessage (NULL, "core", CompLogLevelWarn,
+ compLogMessage ("core", CompLogLevelWarn,
"Plugin '%s' already active",
p->vTable->name ());
@@ -525,7 +519,7 @@ CompPlugin::push (CompPlugin *p)
if (!initPlugin (p))
{
- compLogMessage (NULL, "core", CompLogLevelError,
+ compLogMessage ("core", CompLogLevelError,
"Couldn't activate plugin '%s'", name);
pluginsMap.erase (name);
@@ -630,10 +624,10 @@ CompPlugin::getPluginABI (const char *name)
s += "_ABI";
- if (!core->hasValue (s))
+ if (!screen->hasValue (s))
return 0;
- return core->getValue (s).uval;
+ return screen->getValue (s).uval;
}
bool
@@ -645,13 +639,13 @@ CompPlugin::checkPluginABI (const char *name,
pluginABI = getPluginABI (name);
if (!pluginABI)
{
- compLogMessage (NULL, "core", CompLogLevelError,
+ compLogMessage ("core", CompLogLevelError,
"Plugin '%s' not loaded.\n", name);
return false;
}
else if (pluginABI != abi)
{
- compLogMessage (NULL, "core", CompLogLevelError,
+ compLogMessage ("core", CompLogLevelError,
"Plugin '%s' has ABI version '%d', expected "
"ABI version '%d'.\n",
name, pluginABI, abi);
diff --git a/src/privatecore.h b/src/privatecore.h
deleted file mode 100644
index ca4984c..0000000
--- a/src/privatecore.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef _PRIVATECORE_H
-#define _PRIVATECORE_H
-
-#include <map>
-
-#include <compiz-core.h>
-#include <compcore.h>
-
-extern bool shutDown;
-extern bool restartSignal;
-
-typedef struct _CompWatchFd {
- int fd;
- FdWatchCallBack callBack;
- CompWatchFdHandle handle;
-} CompWatchFd;
-
-class PrivateCore {
-
- public:
- PrivateCore (CompCore *core);
- ~PrivateCore ();
-
- short int
- watchFdEvents (CompWatchFdHandle handle);
-
- int
- doPoll (int timeout);
-
- void
- handleTimers (struct timeval *tv);
-
- void addTimer (CompCore::Timer *timer);
- void removeTimer (CompCore::Timer *timer);
-
-
- public:
- CompCore *core;
- CompDisplayList displays;
-
- std::list<CompFileWatch *> fileWatch;
- CompFileWatchHandle lastFileWatchHandle;
-
- std::list<CompCore::Timer *> timers;
- struct timeval lastTimeout;
-
- std::list<CompWatchFd *> watchFds;
- CompWatchFdHandle lastWatchFdHandle;
- struct pollfd *watchPollFds;
- int nWatchFds;
-
- std::map<CompString, CompPrivate> valueMap;
-};
-
-#endif
diff --git a/src/privatedisplay.h b/src/privatedisplay.h
deleted file mode 100644
index 8a852b2..0000000
--- a/src/privatedisplay.h
+++ /dev/null
@@ -1,210 +0,0 @@
-#ifndef _PRIVATEDISPLAY_H
-#define _PRIVATEDISPLAY_H
-
-#include <X11/XKBlib.h>
-
-#include <compiz-core.h>
-#include <compdisplay.h>
-#include <compmetadata.h>
-
-#define COMP_DISPLAY_OPTION_ACTIVE_PLUGINS 0
-#define COMP_DISPLAY_OPTION_CLICK_TO_FOCUS 1
-#define COMP_DISPLAY_OPTION_AUTORAISE 2
-#define COMP_DISPLAY_OPTION_AUTORAISE_DELAY 3
-#define COMP_DISPLAY_OPTION_CLOSE_WINDOW_KEY 4
-#define COMP_DISPLAY_OPTION_CLOSE_WINDOW_BUTTON 5
-#define COMP_DISPLAY_OPTION_MAIN_MENU_KEY 6
-#define COMP_DISPLAY_OPTION_RUN_DIALOG_KEY 7
-#define COMP_DISPLAY_OPTION_COMMAND0 8
-#define COMP_DISPLAY_OPTION_COMMAND1 9
-#define COMP_DISPLAY_OPTION_COMMAND2 10
-#define COMP_DISPLAY_OPTION_COMMAND3 11
-#define COMP_DISPLAY_OPTION_COMMAND4 12
-#define COMP_DISPLAY_OPTION_COMMAND5 13
-#define COMP_DISPLAY_OPTION_COMMAND6 14
-#define COMP_DISPLAY_OPTION_COMMAND7 15
-#define COMP_DISPLAY_OPTION_COMMAND8 16
-#define COMP_DISPLAY_OPTION_COMMAND9 17
-#define COMP_DISPLAY_OPTION_COMMAND10 18
-#define COMP_DISPLAY_OPTION_COMMAND11 19
-#define COMP_DISPLAY_OPTION_RUN_COMMAND0_KEY 20
-#define COMP_DISPLAY_OPTION_RUN_COMMAND1_KEY 21
-#define COMP_DISPLAY_OPTION_RUN_COMMAND2_KEY 22
-#define COMP_DISPLAY_OPTION_RUN_COMMAND3_KEY 23
-#define COMP_DISPLAY_OPTION_RUN_COMMAND4_KEY 24
-#define COMP_DISPLAY_OPTION_RUN_COMMAND5_KEY 25
-#define COMP_DISPLAY_OPTION_RUN_COMMAND6_KEY 26
-#define COMP_DISPLAY_OPTION_RUN_COMMAND7_KEY 27
-#define COMP_DISPLAY_OPTION_RUN_COMMAND8_KEY 28
-#define COMP_DISPLAY_OPTION_RUN_COMMAND9_KEY 29
-#define COMP_DISPLAY_OPTION_RUN_COMMAND10_KEY 30
-#define COMP_DISPLAY_OPTION_RUN_COMMAND11_KEY 31
-#define COMP_DISPLAY_OPTION_RAISE_WINDOW_KEY 32
-#define COMP_DISPLAY_OPTION_RAISE_WINDOW_BUTTON 33
-#define COMP_DISPLAY_OPTION_LOWER_WINDOW_KEY 34
-#define COMP_DISPLAY_OPTION_LOWER_WINDOW_BUTTON 35
-#define COMP_DISPLAY_OPTION_UNMAXIMIZE_WINDOW_KEY 36
-#define COMP_DISPLAY_OPTION_MINIMIZE_WINDOW_KEY 37
-#define COMP_DISPLAY_OPTION_MINIMIZE_WINDOW_BUTTON 38
-#define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_KEY 39
-#define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_HORZ_KEY 40
-#define COMP_DISPLAY_OPTION_MAXIMIZE_WINDOW_VERT_KEY 41
-#define COMP_DISPLAY_OPTION_SCREENSHOT 42
-#define COMP_DISPLAY_OPTION_RUN_SCREENSHOT_KEY 43
-#define COMP_DISPLAY_OPTION_WINDOW_SCREENSHOT 44
-#define COMP_DISPLAY_OPTION_RUN_WINDOW_SCREENSHOT_KEY 45
-#define COMP_DISPLAY_OPTION_WINDOW_MENU_BUTTON 46
-#define COMP_DISPLAY_OPTION_WINDOW_MENU_KEY 47
-#define COMP_DISPLAY_OPTION_SHOW_DESKTOP_KEY 48
-#define COMP_DISPLAY_OPTION_SHOW_DESKTOP_EDGE 49
-#define COMP_DISPLAY_OPTION_RAISE_ON_CLICK 50
-#define COMP_DISPLAY_OPTION_AUDIBLE_BELL 51
-#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_KEY 52
-#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_BUTTON 53
-#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_HORZ_KEY 54
-#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_MAXIMIZED_VERT_KEY 55
-#define COMP_DISPLAY_OPTION_HIDE_SKIP_TASKBAR_WINDOWS 56
-#define COMP_DISPLAY_OPTION_TOGGLE_WINDOW_SHADED_KEY 57
-#define COMP_DISPLAY_OPTION_IGNORE_HINTS_WHEN_MAXIMIZED 58
-#define COMP_DISPLAY_OPTION_TERMINAL 59
-#define COMP_DISPLAY_OPTION_RUN_TERMINAL_KEY 60
-#define COMP_DISPLAY_OPTION_PING_DELAY 61
-#define COMP_DISPLAY_OPTION_EDGE_DELAY 62
-#define COMP_DISPLAY_OPTION_NUM 63
-
-extern const CompMetadata::OptionInfo
-coreDisplayOptionInfo[COMP_DISPLAY_OPTION_NUM];
-
-extern bool inHandleEvent;
-
-extern CompScreen *targetScreen;
-extern CompOutput *targetOutput;
-
-typedef struct _CompDelayedEdgeSettings
-{
- CompAction::CallBack initiate;
- CompAction::CallBack terminate;
-
- unsigned int edge;
- unsigned int state;
-
- CompOption::Vector options;
-} CompDelayedEdgeSettings;
-
-
-class PrivateDisplay {
-
- public:
- PrivateDisplay (CompDisplay *display);
- ~PrivateDisplay ();
-
- void
- updatePlugins ();
-
- bool
- triggerButtonPressBindings (CompOption::Vector &options,
- XEvent *event,
- CompOption::Vector &arguments);
-
- bool
- triggerButtonReleaseBindings (CompOption::Vector &options,
- XEvent *event,
- CompOption::Vector &arguments);
-
- bool
- triggerKeyPressBindings (CompOption::Vector &options,
- XEvent *event,
- CompOption::Vector &arguments);
-
- bool
- triggerKeyReleaseBindings (CompOption::Vector &options,
- XEvent *event,
- CompOption::Vector &arguments);
-
- bool
- triggerStateNotifyBindings (CompOption::Vector &options,
- XkbStateNotifyEvent *event,
- CompOption::Vector &arguments);
- bool
- triggerEdgeEnter (unsigned int edge,
- CompAction::State state,
- CompOption::Vector &arguments);
-
- void
- setAudibleBell (bool audible);
-
- bool
- handlePingTimeout ();
-
- bool
- handleActionEvent (XEvent *event);
-
- void
- handleSelectionRequest (XEvent *event);
-
- void
- handleSelectionClear (XEvent *event);
-
- void
- initAtoms ();
-
- public:
-
- CompDisplay *display;
-
- xcb_connection_t *connection;
-
- Display *dpy;
- CompScreenList screens;
-
- CompWatchFdHandle watchFdHandle;
-
- int syncEvent, syncError;
-
- bool randrExtension;
- int randrEvent, randrError;
-
- bool shapeExtension;
- int shapeEvent, shapeError;
-
- bool xkbExtension;
- int xkbEvent, xkbError;
-
- bool xineramaExtension;
- int xineramaEvent, xineramaError;
-
- std::vector<XineramaScreenInfo> screenInfo;
-
- SnDisplay *snDisplay;
-
- unsigned int lastPing;
- CompCore::Timer pingTimer;
-
- Window activeWindow;
-
- Window below;
- char displayString[256];
-
- XModifierKeymap *modMap;
- unsigned int modMask[CompModNum];
- unsigned int ignoredModMask;
-
- KeyCode escapeKeyCode;
- KeyCode returnKeyCode;
-
- CompOption::Vector opt;
-
- CompCore::Timer autoRaiseTimer;
- Window autoRaiseWindow;
-
- CompCore::Timer edgeDelayTimer;
- CompDelayedEdgeSettings edgeDelaySettings;
-
- CompOption::Value plugin;
- bool dirtyPluginList;
-
- CompDisplay::Atoms atoms;
-
-};
-
-#endif
diff --git a/src/privatematch.h b/src/privatematch.h
index 764bec4..6cb1608 100644
--- a/src/privatematch.h
+++ b/src/privatematch.h
@@ -51,7 +51,6 @@ class PrivateMatch {
public:
MatchGroupOp op;
- CompDisplay *display;
};
#endif
diff --git a/src/privateoption.h b/src/privateoption.h
index bdbcad2..c723163 100644
--- a/src/privateoption.h
+++ b/src/privateoption.h
@@ -5,7 +5,6 @@
#include <compaction.h>
#include <compmatch.h>
-#include <compdisplay.h>
#include <compscreen.h>
typedef struct _CompOptionIntRestriction {
diff --git a/src/privatescreen.h b/src/privatescreen.h
index 1932eec..9ba403b 100644
--- a/src/privatescreen.h
+++ b/src/privatescreen.h
@@ -5,6 +5,16 @@
#include <compscreen.h>
#include <compsize.h>
#include <comppoint.h>
+#include <core/timer.h>
+
+extern bool shutDown;
+extern bool restartSignal;
+
+typedef struct _CompWatchFd {
+ int fd;
+ FdWatchCallBack callBack;
+ CompWatchFdHandle handle;
+} CompWatchFd;
extern CompWindow *lastFoundWindow;
extern CompWindow *lastDamagedWindow;
@@ -14,16 +24,100 @@ extern bool onlyCurrentScreen;
extern int defaultRefreshRate;
extern const char *defaultTextureFilter;
-#define COMP_SCREEN_OPTION_HSIZE 0
-#define COMP_SCREEN_OPTION_VSIZE 1
-#define COMP_SCREEN_OPTION_DEFAULT_ICON 2
-#define COMP_SCREEN_OPTION_NUMBER_OF_DESKTOPS 3
-#define COMP_SCREEN_OPTION_DETECT_OUTPUTS 4
-#define COMP_SCREEN_OPTION_OUTPUTS 5
-#define COMP_SCREEN_OPTION_OVERLAPPING_OUTPUTS 6
-#define COMP_SCREEN_OPTION_FOCUS_PREVENTION_LEVEL 7
-#define COMP_SCREEN_OPTION_FOCUS_PREVENTION_MATCH 8
-#define COMP_SCREEN_OPTION_NUM 9
+
+#define COMP_OPTION_ACTIVE_PLUGINS 0
+#define COMP_OPTION_CLICK_TO_FOCUS 1
+#define COMP_OPTION_AUTORAISE 2
+#define COMP_OPTION_AUTORAISE_DELAY 3
+#define COMP_OPTION_CLOSE_WINDOW_KEY 4
+#define COMP_OPTION_CLOSE_WINDOW_BUTTON 5
+#define COMP_OPTION_MAIN_MENU_KEY 6
+#define COMP_OPTION_RUN_DIALOG_KEY 7
+#define COMP_OPTION_COMMAND0 8
+#define COMP_OPTION_COMMAND1 9
+#define COMP_OPTION_COMMAND2 10
+#define COMP_OPTION_COMMAND3 11
+#define COMP_OPTION_COMMAND4 12
+#define COMP_OPTION_COMMAND5 13
+#define COMP_OPTION_COMMAND6 14
+#define COMP_OPTION_COMMAND7 15
+#define COMP_OPTION_COMMAND8 16
+#define COMP_OPTION_COMMAND9 17
+#define COMP_OPTION_COMMAND10 18
+#define COMP_OPTION_COMMAND11 19
+#define COMP_OPTION_RUN_COMMAND0_KEY 20
+#define COMP_OPTION_RUN_COMMAND1_KEY 21
+#define COMP_OPTION_RUN_COMMAND2_KEY 22
+#define COMP_OPTION_RUN_COMMAND3_KEY 23
+#define COMP_OPTION_RUN_COMMAND4_KEY 24
+#define COMP_OPTION_RUN_COMMAND5_KEY 25
+#define COMP_OPTION_RUN_COMMAND6_KEY 26
+#define COMP_OPTION_RUN_COMMAND7_KEY 27
+#define COMP_OPTION_RUN_COMMAND8_KEY 28
+#define COMP_OPTION_RUN_COMMAND9_KEY 29
+#define COMP_OPTION_RUN_COMMAND10_KEY 30
+#define COMP_OPTION_RUN_COMMAND11_KEY 31
+#define COMP_OPTION_RAISE_WINDOW_KEY 32
+#define COMP_OPTION_RAISE_WINDOW_BUTTON 33
+#define COMP_OPTION_LOWER_WINDOW_KEY 34
+#define COMP_OPTION_LOWER_WINDOW_BUTTON 35
+#define COMP_OPTION_UNMAXIMIZE_WINDOW_KEY 36
+#define COMP_OPTION_MINIMIZE_WINDOW_KEY 37
+#define COMP_OPTION_MINIMIZE_WINDOW_BUTTON 38
+#define COMP_OPTION_MAXIMIZE_WINDOW_KEY 39
+#define COMP_OPTION_MAXIMIZE_WINDOW_HORZ_KEY 40
+#define COMP_OPTION_MAXIMIZE_WINDOW_VERT_KEY 41
+#define COMP_OPTION_SCREENSHOT 42
+#define COMP_OPTION_RUN_SCREENSHOT_KEY 43
+#define COMP_OPTION_WINDOW_SCREENSHOT 44
+#define COMP_OPTION_RUN_WINDOW_SCREENSHOT_KEY 45
+#define COMP_OPTION_WINDOW_MENU_BUTTON 46
+#define COMP_OPTION_WINDOW_MENU_KEY 47
+#define COMP_OPTION_SHOW_DESKTOP_KEY 48
+#define COMP_OPTION_SHOW_DESKTOP_EDGE 49
+#define COMP_OPTION_RAISE_ON_CLICK 50
+#define COMP_OPTION_AUDIBLE_BELL 51
+#define COMP_OPTION_TOGGLE_WINDOW_MAXIMIZED_KEY 52
+#define COMP_OPTION_TOGGLE_WINDOW_MAXIMIZED_BUTTON 53
+#define COMP_OPTION_TOGGLE_WINDOW_MAXIMIZED_HORZ_KEY 54
+#define COMP_OPTION_TOGGLE_WINDOW_MAXIMIZED_VERT_KEY 55
+#define COMP_OPTION_HIDE_SKIP_TASKBAR_WINDOWS 56
+#define COMP_OPTION_TOGGLE_WINDOW_SHADED_KEY 57
+#define COMP_OPTION_IGNORE_HINTS_WHEN_MAXIMIZED 58
+#define COMP_OPTION_TERMINAL 59
+#define COMP_OPTION_RUN_TERMINAL_KEY 60
+#define COMP_OPTION_PING_DELAY 61
+#define COMP_OPTION_EDGE_DELAY 62
+#define COMP_OPTION_HSIZE 63
+#define COMP_OPTION_VSIZE 64
+#define COMP_OPTION_DEFAULT_ICON 65
+#define COMP_OPTION_NUMBER_OF_DESKTOPS 66
+#define COMP_OPTION_DETECT_OUTPUTS 67
+#define COMP_OPTION_OUTPUTS 68
+#define COMP_OPTION_OVERLAPPING_OUTPUTS 69
+#define COMP_OPTION_FOCUS_PREVENTION_LEVEL 70
+#define COMP_OPTION_FOCUS_PREVENTION_MATCH 71
+#define COMP_OPTION_NUM 72
+
+extern bool inHandleEvent;
+
+extern CompScreen *targetScreen;
+extern CompOutput *targetOutput;
+
+
+typedef struct _CompDelayedEdgeSettings
+{
+ CompAction::CallBack initiate;
+ CompAction::CallBack terminate;
+
+ unsigned int edge;
+ unsigned int state;
+
+ CompOption::Vector options;
+} CompDelayedEdgeSettings;
+
+
+
#define OUTPUT_OVERLAP_MODE_SMART 0
#define OUTPUT_OVERLAP_MODE_PREFER_LARGER 1
@@ -37,7 +131,7 @@ extern const char *defaultTextureFilter;
#define FOCUS_PREVENTION_LEVEL_LAST FOCUS_PREVENTION_LEVEL_VERYHIGH
extern const CompMetadata::OptionInfo
-coreScreenOptionInfo[COMP_SCREEN_OPTION_NUM];
+coreOptionInfo[COMP_OPTION_NUM];
class PrivateScreen {
@@ -69,6 +163,71 @@ class PrivateScreen {
PrivateScreen (CompScreen *screen);
~PrivateScreen ();
+ void processEvents ();
+
+ void removeDestroyed ();
+
+ void updatePassiveGrabs ();
+
+ short int
+ watchFdEvents (CompWatchFdHandle handle);
+
+ int
+ doPoll (int timeout);
+
+ void
+ handleTimers (struct timeval *tv);
+
+ void addTimer (CompTimer *timer);
+ void removeTimer (CompTimer *timer);
+
+ void
+ updatePlugins ();
+
+ bool
+ triggerButtonPressBindings (CompOption::Vector &options,
+ XEvent *event,
+ CompOption::Vector &arguments);
+
+ bool
+ triggerButtonReleaseBindings (CompOption::Vector &options,
+ XEvent *event,
+ CompOption::Vector &arguments);
+
+ bool
+ triggerKeyPressBindings (CompOption::Vector &options,
+ XEvent *event,
+ CompOption::Vector &arguments);
+
+ bool
+ triggerKeyReleaseBindings (CompOption::Vector &options,
+ XEvent *event,
+ CompOption::Vector &arguments);
+
+ bool
+ triggerStateNotifyBindings (CompOption::Vector &options,
+ XkbStateNotifyEvent *event,
+ CompOption::Vector &arguments);
+ bool
+ triggerEdgeEnter (unsigned int edge,
+ CompAction::State state,
+ CompOption::Vector &arguments);
+
+ void
+ setAudibleBell (bool audible);
+
+ bool
+ handlePingTimeout ();
+
+ bool
+ handleActionEvent (XEvent *event);
+
+ void
+ handleSelectionRequest (XEvent *event);
+
+ void
+ handleSelectionClear (XEvent *event);
+
bool
desktopHintEqual (unsigned long *data,
int size,
@@ -143,12 +302,74 @@ class PrivateScreen {
void
computeWorkareaForBox (BoxPtr pBox, XRectangle *area);
+ void updateScreenInfo ();
+
public:
+
+ std::list<CompFileWatch *> fileWatch;
+ CompFileWatchHandle lastFileWatchHandle;
+
+ std::list<CompTimer *> timers;
+ struct timeval lastTimeout;
+
+ std::list<CompWatchFd *> watchFds;
+ CompWatchFdHandle lastWatchFdHandle;
+ struct pollfd *watchPollFds;
+ int nWatchFds;
+
+ std::map<CompString, CompPrivate> valueMap;
+
+ xcb_connection_t *connection;
+
+ Display *dpy;
+
+ int syncEvent, syncError;
+
+ bool randrExtension;
+ int randrEvent, randrError;
+
+ bool shapeExtension;
+ int shapeEvent, shapeError;
+
+ bool xkbExtension;
+ int xkbEvent, xkbError;
+
+ bool xineramaExtension;
+ int xineramaEvent, xineramaError;
+
+ std::vector<XineramaScreenInfo> screenInfo;
+
+ SnDisplay *snDisplay;
+
+ unsigned int lastPing;
+ CompTimer pingTimer;
+
+ Window activeWindow;
+
+ Window below;
+ char displayString[256];
+
+ XModifierKeymap *modMap;
+ unsigned int modMask[CompModNum];
+ unsigned int ignoredModMask;
+
+ KeyCode escapeKeyCode;
+ KeyCode returnKeyCode;
+
+ CompTimer autoRaiseTimer;
+ Window autoRaiseWindow;
+
+ CompTimer edgeDelayTimer;
+ CompDelayedEdgeSettings edgeDelaySettings;
+
+ CompOption::Value plugin;
+ bool dirtyPluginList;
+
CompScreen *screen;
- CompDisplay *display;
+
CompWindowList windows;
CompWindow::Map windowsMap;
@@ -187,7 +408,7 @@ class PrivateScreen {
SnMonitorContext *snContext;
std::list<CompStartupSequence *> startupSequences;
- CompCore::Timer startupSequenceTimer;
+ CompTimer startupSequenceTimer;
std::list<CompGroup *> groups;
diff --git a/src/privatewindow.h b/src/privatewindow.h
index 41b8773..0251746 100644
--- a/src/privatewindow.h
+++ b/src/privatewindow.h
@@ -4,6 +4,7 @@
#include <compiz-core.h>
#include <compwindow.h>
#include <comppoint.h>
+#include <core/timer.h>
#define WINDOW_INVISIBLE(w) \
((w)->attrib.map_state != IsViewable || \
@@ -216,7 +217,7 @@ class PrivateWindow {
XSyncValue syncValue;
XSyncAlarm syncAlarm;
unsigned long syncAlarmConnection;
- CompCore::Timer syncWaitTimer;
+ CompTimer syncWaitTimer;
bool syncWait;
CompWindow::Geometry syncGeometry;
diff --git a/src/screen.cpp b/src/screen.cpp
index e243658..bbfe15a 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -38,6 +38,7 @@
#include <unistd.h>
#include <assert.h>
#include <limits.h>
+#include <poll.h>
#include <algorithm>
#include <boost/bind.hpp>
@@ -55,10 +56,38 @@
#include <compiz-core.h>
#include <compscreen.h>
-#include <compdisplay.h>
#include <compicon.h>
+#include <core/atoms.h>
#include "privatescreen.h"
-#include "privatedisplay.h"
+
+static unsigned int virtualModMask[] = {
+ CompAltMask, CompMetaMask, CompSuperMask, CompHyperMask,
+ CompModeSwitchMask, CompNumLockMask, CompScrollLockMask
+};
+
+bool inHandleEvent = false;
+
+CompScreen *targetScreen = NULL;
+CompOutput *targetOutput;
+
+int lastPointerX = 0;
+int lastPointerY = 0;
+int pointerX = 0;
+int pointerY = 0;
+
+#define MwmHintsFunctions (1L << 0)
+#define MwmHintsDecorations (1L << 1)
+#define PropMotifWmHintElements 3
+
+typedef struct {
+ unsigned long flags;
+ unsigned long functions;
+ unsigned long decorations;
+} MwmHints;
+
+
+
+CompScreen *screen;
#define NUM_OPTIONS(s) (sizeof ((s)->priv->opt) / sizeof (CompOption))
@@ -79,6 +108,1812 @@ CompScreen::freePrivateIndex (int index)
}
+
+#define TIMEVALDIFF(tv1, tv2) \
+ ((tv1)->tv_sec == (tv2)->tv_sec || (tv1)->tv_usec >= (tv2)->tv_usec) ? \
+ ((((tv1)->tv_sec - (tv2)->tv_sec) * 1000000) + \
+ ((tv1)->tv_usec - (tv2)->tv_usec)) / 1000 : \
+ ((((tv1)->tv_sec - 1 - (tv2)->tv_sec) * 1000000) + \
+ (1000000 + (tv1)->tv_usec - (tv2)->tv_usec)) / 1000
+
+
+void
+CompScreen::eventLoop ()
+{
+ struct timeval tv;
+ CompTimer *t;
+ int time;
+ CompWatchFdHandle watchFdHandle;
+
+ watchFdHandle = addWatchFd (ConnectionNumber (priv->dpy), POLLIN, NULL);
+
+ for (;;)
+ {
+ if (restartSignal || shutDown)
+ break;
+
+ priv->processEvents ();
+
+ if (!priv->timers.empty())
+ {
+ gettimeofday (&tv, 0);
+ priv->handleTimers (&tv);
+
+ if (priv->timers.front()->mMinLeft > 0)
+ {
+ std::list<CompTimer *>::iterator it = priv->timers.begin();
+
+ t = (*it);
+ time = t->mMaxLeft;
+ while (it != priv->timers.end())
+ {
+ t = (*it);
+ if (t->mMinLeft <= time)
+ break;
+ if (t->mMaxLeft < time)
+ time = t->mMaxLeft;
+ it++;
+ }
+ priv->doPoll (time);
+ gettimeofday (&tv, 0);
+ priv->handleTimers (&tv);
+ }
+ }
+ else
+ {
+ priv->doPoll (-1);
+ }
+ }
+
+ removeWatchFd (watchFdHandle);
+}
+
+CompFileWatchHandle
+CompScreen::addFileWatch (const char *path,
+ int mask,
+ FileWatchCallBack callBack)
+{
+ CompFileWatch *fileWatch = new CompFileWatch();
+ if (!fileWatch)
+ return 0;
+
+ fileWatch->path = strdup (path);
+ fileWatch->mask = mask;
+ fileWatch->callBack = callBack;
+ fileWatch->handle = priv->lastFileWatchHandle++;
+
+ if (priv->lastFileWatchHandle == MAXSHORT)
+ priv->lastFileWatchHandle = 1;
+
+ priv->fileWatch.push_front(fileWatch);
+
+ fileWatchAdded (fileWatch);
+
+ return fileWatch->handle;
+}
+
+void
+CompScreen::removeFileWatch (CompFileWatchHandle handle)
+{
+ std::list<CompFileWatch *>::iterator it;
+ CompFileWatch *w;
+
+ for (it = priv->fileWatch.begin(); it != priv->fileWatch.end(); it++)
+ if ((*it)->handle == handle)
+ break;
+
+ if (it == priv->fileWatch.end())
+ return;
+
+ w = (*it);
+ priv->fileWatch.erase (it);
+
+ fileWatchRemoved (w);
+
+ delete w;
+}
+
+void
+PrivateScreen::addTimer (CompTimer *timer)
+{
+ std::list<CompTimer *>::iterator it;
+
+ it = std::find (timers.begin (), timers.end (), timer);
+
+ if (it != timers.end ())
+ return;
+
+ for (it = timers.begin(); it != timers.end(); it++)
+ {
+ if ((int) timer->mMinTime < (*it)->mMinLeft)
+ break;
+ }
+
+ timer->mMinLeft = timer->mMinTime;
+ timer->mMaxLeft = timer->mMaxTime;
+
+ timers.insert (it, timer);
+}
+
+void
+PrivateScreen::removeTimer (CompTimer *timer)
+{
+ std::list<CompTimer *>::iterator it;
+
+ it = std::find (timers.begin (), timers.end (), timer);
+
+ if (it == timers.end ())
+ return;
+
+ timers.erase (it);
+}
+
+CompWatchFdHandle
+CompScreen::addWatchFd (int fd,
+ short int events,
+ FdWatchCallBack callBack)
+{
+ CompWatchFd *watchFd = new CompWatchFd();
+
+ if (!watchFd)
+ return 0;
+
+ watchFd->fd = fd;
+ watchFd->callBack = callBack;
+ watchFd->handle = priv->lastWatchFdHandle++;
+
+ if (priv->lastWatchFdHandle == MAXSHORT)
+ priv->lastWatchFdHandle = 1;
+
+ priv->watchFds.push_front (watchFd);
+
+ priv->nWatchFds++;
+
+ priv->watchPollFds = (struct pollfd *) realloc (priv->watchPollFds,
+ priv->nWatchFds * sizeof (struct pollfd));
+
+ priv->watchPollFds[priv->nWatchFds - 1].fd = fd;
+ priv->watchPollFds[priv->nWatchFds - 1].events = events;
+
+ return watchFd->handle;
+}
+
+void
+CompScreen::removeWatchFd (CompWatchFdHandle handle)
+{
+ std::list<CompWatchFd *>::iterator it;
+ CompWatchFd *w;
+ int i;
+
+ for (it = priv->watchFds.begin(), i = priv->nWatchFds - 1;
+ it != priv->watchFds.end(); it++, i--)
+ if ((*it)->handle == handle)
+ break;
+
+ if (it == priv->watchFds.end())
+ return;
+
+ w = (*it);
+ priv->watchFds.erase (it);
+
+ priv->nWatchFds--;
+
+ if (i < priv->nWatchFds)
+ memmove (&priv->watchPollFds[i], &priv->watchPollFds[i + 1],
+ (priv->nWatchFds - i) * sizeof (struct pollfd));
+
+ delete w;
+}
+
+void
+CompScreen::storeValue (CompString key, CompPrivate value)
+{
+ std::map<CompString,CompPrivate>::iterator it;
+ it = priv->valueMap.find (key);
+ if (it != priv->valueMap.end ())
+ {
+ it->second = value;
+ }
+ else
+ {
+ priv->valueMap.insert (std::pair<CompString,CompPrivate> (key, value));
+ }
+}
+
+bool
+CompScreen::hasValue (CompString key)
+{
+ return (priv->valueMap.find (key) != priv->valueMap.end ());
+}
+
+CompPrivate
+CompScreen::getValue (CompString key)
+{
+ CompPrivate p;
+
+ std::map<CompString,CompPrivate>::iterator it;
+ it = priv->valueMap.find (key);
+
+ if (it != priv->valueMap.end ())
+ {
+ return it->second;
+ }
+ else
+ {
+ p.uval = 0;
+ return p;
+ }
+}
+
+void
+CompScreen::eraseValue (CompString key)
+{
+ std::map<CompString,CompPrivate>::iterator it;
+ it = priv->valueMap.find (key);
+
+ if (it != priv->valueMap.end ())
+ {
+ priv->valueMap.erase (key);
+ }
+}
+
+short int
+PrivateScreen::watchFdEvents (CompWatchFdHandle handle)
+{
+ std::list<CompWatchFd *>::iterator it;
+ int i;
+
+ for (it = watchFds.begin(), i = nWatchFds - 1; it != watchFds.end();
+ it++, i--)
+ if ((*it)->handle == handle)
+ return watchPollFds[i].revents;
+
+ return 0;
+}
+
+int
+PrivateScreen::doPoll (int timeout)
+{
+ int rv;
+
+ rv = poll (watchPollFds, nWatchFds, timeout);
+ if (rv)
+ {
+ std::list<CompWatchFd *>::iterator it;
+ int i;
+
+ for (it = watchFds.begin(), i = nWatchFds - 1; it != watchFds.end();
+ it++, i--)
+ if (watchPollFds[i].revents != 0 && (*it)->callBack)
+ (*it)->callBack ();
+ }
+
+ return rv;
+}
+
+void
+PrivateScreen::handleTimers (struct timeval *tv)
+{
+ CompTimer *t;
+ int timeDiff;
+ std::list<CompTimer *>::iterator it;
+
+ timeDiff = TIMEVALDIFF (tv, &lastTimeout);
+
+ /* handle clock rollback */
+ if (timeDiff < 0)
+ timeDiff = 0;
+
+ for (it = timers.begin(); it != timers.end(); it++)
+ {
+ t = (*it);
+ t->mMinLeft -= timeDiff;
+ t->mMaxLeft -= timeDiff;
+ }
+
+ while (timers.begin() != timers.end() &&
+ (*timers.begin())->mMinLeft <= 0)
+ {
+ t = (*timers.begin());
+ timers.pop_front();
+
+ t->mActive = false;
+ if (t->mCallBack ())
+ {
+ addTimer (t);
+ t->mActive = true;
+ }
+ }
+
+ lastTimeout = *tv;
+}
+
+
+void
+CompScreen::fileWatchAdded (CompFileWatch *watch)
+ WRAPABLE_HND_FUNC(0, fileWatchAdded, watch)
+
+void
+CompScreen::fileWatchRemoved (CompFileWatch *watch)
+ WRAPABLE_HND_FUNC(1, fileWatchRemoved, watch)
+
+bool
+CompScreen::initPluginForObject (CompPlugin *plugin, CompObject *object)
+{
+ WRAPABLE_HND_FUNC_RETURN(2, bool, initPluginForObject, plugin, object)
+ return true;
+}
+
+void
+CompScreen::finiPluginForObject (CompPlugin *plugin, CompObject *object)
+ WRAPABLE_HND_FUNC(3, finiPluginForObject, plugin, object)
+
+
+bool
+CompScreen::setOptionForPlugin (CompObject *object,
+ const char *plugin,
+ const char *name,
+ CompOption::Value &value)
+{
+ WRAPABLE_HND_FUNC_RETURN(4, bool, setOptionForPlugin,
+ object, plugin, name, value)
+
+ CompPlugin *p = CompPlugin::find (plugin);
+ if (p)
+ return p->vTable->setObjectOption (object, name, value);
+
+ return false;
+}
+
+void
+CompScreen::objectAdd (CompObject *parent, CompObject *object)
+ WRAPABLE_HND_FUNC(5, objectAdd, parent, object)
+
+
+void
+CompScreen::objectRemove (CompObject *parent, CompObject *object)
+ WRAPABLE_HND_FUNC(6, objectRemove, parent, object)
+
+void
+CompScreen::sessionEvent (CompSession::Event event,
+ CompOption::Vector &arguments)
+ WRAPABLE_HND_FUNC(7, sessionEvent, event, arguments)
+
+void
+ScreenInterface::fileWatchAdded (CompFileWatch *watch)
+ WRAPABLE_DEF (fileWatchAdded, watch)
+
+void
+ScreenInterface::fileWatchRemoved (CompFileWatch *watch)
+ WRAPABLE_DEF (fileWatchRemoved, watch)
+
+bool
+ScreenInterface::initPluginForObject (CompPlugin *plugin, CompObject *object)
+ WRAPABLE_DEF (initPluginForObject, plugin, object)
+
+void
+ScreenInterface::finiPluginForObject (CompPlugin *plugin, CompObject *object)
+ WRAPABLE_DEF (finiPluginForObject, plugin, object)
+
+
+bool
+ScreenInterface::setOptionForPlugin (CompObject *object,
+ const char *plugin,
+ const char *name,
+ CompOption::Value &value)
+ WRAPABLE_DEF (setOptionForPlugin, object, plugin, name, value)
+
+void
+ScreenInterface::objectAdd (CompObject *parent, CompObject *object)
+ WRAPABLE_DEF (objectAdd, parent, object)
+
+void
+ScreenInterface::objectRemove (CompObject *parent, CompObject *object)
+ WRAPABLE_DEF (objectRemove, parent, object)
+
+void
+ScreenInterface::sessionEvent (CompSession::Event event,
+ CompOption::Vector &arguments)
+ WRAPABLE_DEF (sessionEvent, event, arguments)
+
+
+
+const CompMetadata::OptionInfo coreOptionInfo[COMP_OPTION_NUM] = {
+ { "active_plugins", "list", "<type>string</type>", 0, 0 },
+ { "click_to_focus", "bool", 0, 0, 0 },
+ { "autoraise", "bool", 0, 0, 0 },
+ { "autoraise_delay", "int", 0, 0, 0 },
+ { "close_window_key", "key", 0, CompScreen::closeWin, 0 },
+ { "close_window_button", "button", 0, CompScreen::closeWin, 0 },
+ { "main_menu_key", "key", 0, CompScreen::mainMenu, 0 },
+ { "run_key", "key", 0, CompScreen::runDialog, 0 },
+ { "command0", "string", 0, 0, 0 },
+ { "command1", "string", 0, 0, 0 },
+ { "command2", "string", 0, 0, 0 },
+ { "command3", "string", 0, 0, 0 },
+ { "command4", "string", 0, 0, 0 },
+ { "command5", "string", 0, 0, 0 },
+ { "command6", "string", 0, 0, 0 },
+ { "command7", "string", 0, 0, 0 },
+ { "command8", "string", 0, 0, 0 },
+ { "command9", "string", 0, 0, 0 },
+ { "command10", "string", 0, 0, 0 },
+ { "command11", "string", 0, 0, 0 },
+ { "run_command0_key", "key", 0, CompScreen::runCommandDispatch, 0 },
+ { "run_command1_key", "key", 0, CompScreen::runCommandDispatch, 0 },
+ { "run_command2_key", "key", 0, CompScreen::runCommandDispatch, 0 },
+ { "run_command3_key", "key", 0, CompScreen::runCommandDispatch, 0 },
+ { "run_command4_key", "key", 0, CompScreen::runCommandDispatch, 0 },
+ { "run_command5_key", "key", 0, CompScreen::runCommandDispatch, 0 },
+ { "run_command6_key", "key", 0, CompScreen::runCommandDispatch, 0 },
+ { "run_command7_key", "key", 0, CompScreen::runCommandDispatch, 0 },
+ { "run_command8_key", "key", 0, CompScreen::runCommandDispatch, 0 },
+ { "run_command9_key", "key", 0, CompScreen::runCommandDispatch, 0 },
+ { "run_command10_key", "key", 0, CompScreen::runCommandDispatch, 0 },
+ { "run_command11_key", "key", 0, CompScreen::runCommandDispatch, 0 },
+ { "raise_window_key", "key", 0, CompScreen::raiseWin, 0 },
+ { "raise_window_button", "button", 0, CompScreen::raiseWin, 0 },
+ { "lower_window_key", "key", 0, CompScreen::lowerWin, 0 },
+ { "lower_window_button", "button", 0, CompScreen::lowerWin, 0 },
+ { "unmaximize_window_key", "key", 0, CompScreen::unmaximizeWin, 0 },
+ { "minimize_window_key", "key", 0, CompScreen::minimizeWin, 0 },
+ { "minimize_window_button", "button", 0, CompScreen::minimizeWin, 0 },
+ { "maximize_window_key", "key", 0, CompScreen::maximizeWin, 0 },
+ { "maximize_window_horizontally_key", "key", 0,
+ CompScreen::maximizeWinHorizontally, 0 },
+ { "maximize_window_vertically_key", "key", 0,
+ CompScreen::maximizeWinVertically, 0 },
+ { "command_screenshot", "string", 0, 0, 0 },
+ { "run_command_screenshot_key", "key", 0,
+ CompScreen::runCommandScreenshot, 0 },
+ { "command_window_screenshot", "string", 0, 0, 0 },
+ { "run_command_window_screenshot_key", "key", 0,
+ CompScreen::runCommandWindowScreenshot, 0 },
+ { "window_menu_button", "button", 0, CompScreen::windowMenu, 0 },
+ { "window_menu_key", "key", 0, CompScreen::windowMenu, 0 },
+ { "show_desktop_key", "key", 0, CompScreen::showDesktop, 0 },
+ { "show_desktop_edge", "edge", 0, CompScreen::showDesktop, 0 },
+ { "raise_on_click", "bool", 0, 0, 0 },
+ { "audible_bell", "bool", 0, 0, 0 },
+ { "toggle_window_maximized_key", "key", 0,
+ CompScreen::toggleWinMaximized, 0 },
+ { "toggle_window_maximized_button", "button", 0,
+ CompScreen::toggleWinMaximized, 0 },
+ { "toggle_window_maximized_horizontally_key", "key", 0,
+ CompScreen::toggleWinMaximizedHorizontally, 0 },
+ { "toggle_window_maximized_vertically_key", "key", 0,
+ CompScreen::toggleWinMaximizedVertically, 0 },
+ { "hide_skip_taskbar_windows", "bool", 0, 0, 0 },
+ { "toggle_window_shaded_key", "key", 0, CompScreen::shadeWin, 0 },
+ { "ignore_hints_when_maximized", "bool", 0, 0, 0 },
+ { "command_terminal", "string", 0, 0, 0 },
+ { "run_command_terminal_key", "key", 0,
+ CompScreen::runCommandTerminal, 0 },
+ { "ping_delay", "int", "<min>1000</min>", 0, 0 },
+ { "edge_delay", "int", "<min>0</min>", 0, 0 },
+ { "hsize", "int", "<min>1</min><max>32</max>", 0, 0 },
+ { "vsize", "int", "<min>1</min><max>32</max>", 0, 0 },
+ { "default_icon", "string", 0, 0, 0 },
+ { "number_of_desktops", "int", "<min>1</min>", 0, 0 },
+ { "detect_outputs", "bool", 0, 0, 0 },
+ { "outputs", "list", "<type>string</type>", 0, 0 },
+ { "overlapping_outputs", "int",
+ RESTOSTRING (0, OUTPUT_OVERLAP_MODE_LAST), 0, 0 },
+ { "focus_prevention_level", "int",
+ RESTOSTRING (0, FOCUS_PREVENTION_LEVEL_LAST), 0, 0 },
+ { "focus_prevention_match", "match", 0, 0, 0 }
+};
+
+CompOption::Vector &
+CompScreen::getOptions (CompObject *object)
+{
+ return screen->priv->opt;
+}
+
+bool
+CompScreen::setOption (CompObject *object,
+ const char *name,
+ CompOption::Value &value)
+{
+ return screen->setOption (name, value);
+}
+
+
+static const int maskTable[] = {
+ ShiftMask, LockMask, ControlMask, Mod1Mask,
+ Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
+};
+static const int maskTableSize = sizeof (maskTable) / sizeof (int);
+
+static int errors = 0;
+
+static int
+errorHandler (Display *dpy,
+ XErrorEvent *e)
+{
+
+#ifdef DEBUG
+ char str[128];
+#endif
+
+ errors++;
+
+#ifdef DEBUG
+ XGetErrorDatabaseText (dpy, "XlibMessage", "XError", "", str, 128);
+ fprintf (stderr, "%s", str);
+
+ XGetErrorText (dpy, e->error_code, str, 128);
+ fprintf (stderr, ": %s\n ", str);
+
+ XGetErrorDatabaseText (dpy, "XlibMessage", "MajorCode", "%d", str, 128);
+ fprintf (stderr, str, e->request_code);
+
+ sprintf (str, "%d", e->request_code);
+ XGetErrorDatabaseText (dpy, "XRequest", str, "", str, 128);
+ if (strcmp (str, ""))
+ fprintf (stderr, " (%s)", str);
+ fprintf (stderr, "\n ");
+
+ XGetErrorDatabaseText (dpy, "XlibMessage", "MinorCode", "%d", str, 128);
+ fprintf (stderr, str, e->minor_code);
+ fprintf (stderr, "\n ");
+
+ XGetErrorDatabaseText (dpy, "XlibMessage", "ResourceID", "%d", str, 128);
+ fprintf (stderr, str, e->resourceid);
+ fprintf (stderr, "\n");
+
+ /* abort (); */
+#endif
+
+ return 0;
+}
+
+int
+CompScreen::checkForError (Display *dpy)
+{
+ int e;
+
+ XSync (dpy, FALSE);
+
+ e = errors;
+ errors = 0;
+
+ return e;
+}
+
+Display *
+CompScreen::dpy ()
+{
+ return priv->dpy;
+}
+
+
+CompOption *
+CompScreen::getOption (const char *name)
+{
+ CompOption *o = CompOption::findOption (priv->opt, name);
+ return o;
+}
+
+bool
+CompScreen::XRandr ()
+{
+ return priv->randrExtension;
+}
+
+int
+CompScreen::randrEvent ()
+{
+ return priv->randrEvent;
+}
+
+bool
+CompScreen::XShape ()
+{
+ return priv->shapeExtension;
+}
+
+int
+CompScreen::shapeEvent ()
+{
+ return priv->shapeEvent;
+}
+
+int
+CompScreen::syncEvent ()
+{
+ return priv->syncEvent;
+}
+
+
+SnDisplay *
+CompScreen::snDisplay ()
+{
+ return priv->snDisplay;
+}
+
+Window
+CompScreen::activeWindow ()
+{
+ return priv->activeWindow;
+}
+
+Window
+CompScreen::autoRaiseWindow ()
+{
+ return priv->autoRaiseWindow;
+}
+
+
+const char *
+CompScreen::displayString ()
+{
+ return priv->displayString;
+}
+
+unsigned int
+CompScreen::lastPing ()
+{
+ return priv->lastPing;
+}
+
+void
+PrivateScreen::updateScreenInfo ()
+{
+ if (xineramaExtension)
+ {
+ int nInfo;
+ XineramaScreenInfo *info = XineramaQueryScreens (dpy, &nInfo);
+
+ screenInfo = std::vector<XineramaScreenInfo> (info, info + nInfo);
+
+ if (info)
+ XFree (info);
+ }
+}
+
+
+
+void
+PrivateScreen::setAudibleBell (bool audible)
+{
+ if (xkbExtension)
+ XkbChangeEnabledControls (dpy,
+ XkbUseCoreKbd,
+ XkbAudibleBellMask,
+ audible ? XkbAudibleBellMask : 0);
+}
+
+bool
+PrivateScreen::handlePingTimeout ()
+{
+ XEvent ev;
+ int ping = lastPing + 1;
+
+ ev.type = ClientMessage;
+ ev.xclient.window = 0;
+ ev.xclient.message_type = Atoms::wmProtocols;
+ ev.xclient.format = 32;
+ ev.xclient.data.l[0] = Atoms::wmPing;
+ ev.xclient.data.l[1] = ping;
+ ev.xclient.data.l[2] = 0;
+ ev.xclient.data.l[3] = 0;
+ ev.xclient.data.l[4] = 0;
+
+ foreach (CompWindow *w, windows)
+ {
+ if (w->handlePingTimeout (lastPing))
+ {
+ ev.xclient.window = w->id ();
+ ev.xclient.data.l[2] = w->id ();
+
+ XSendEvent (dpy, w->id (), false, NoEventMask, &ev);
+ }
+ }
+
+ lastPing = ping;
+
+ return true;
+}
+
+bool
+CompScreen::setOption (const char *name,
+ CompOption::Value &value)
+{
+ CompOption *o;
+ unsigned int index;
+
+ o = CompOption::findOption (priv->opt, name, &index);
+ if (!o)
+ return false;
+
+ switch (index) {
+ case COMP_OPTION_ACTIVE_PLUGINS:
+ if (o->set (value))
+ {
+ priv->dirtyPluginList = true;
+ return true;
+ }
+ break;
+ case COMP_OPTION_PING_DELAY:
+ if (o->set (value))
+ {
+ priv->pingTimer.setTimes (o->value ().i (),
+ o->value ().i () + 500);
+ return true;
+ }
+ break;
+ case COMP_OPTION_AUDIBLE_BELL:
+ if (o->set (value))
+ {
+ priv->setAudibleBell (o->value ().b ());
+ return true;
+ }
+ break;
+ case COMP_OPTION_DETECT_OUTPUTS:
+ if (o->set (value))
+ {
+ if (value.b ())
+ priv->detectOutputDevices ();
+
+ return true;
+ }
+ break;
+ case COMP_OPTION_HSIZE:
+ if (o->set (value))
+ {
+ CompOption *vsize;
+
+ vsize = CompOption::findOption (priv->opt, "vsize");
+
+ if (!vsize)
+ return false;
+
+ if (o->value ().i () * priv->size.width () > MAXSHORT)
+ return false;
+
+ priv->setVirtualScreenSize (o->value ().i (), vsize->value ().i ());
+ return true;
+ }
+ break;
+ case COMP_OPTION_VSIZE:
+ if (o->set (value))
+ {
+ CompOption *hsize;
+
+ hsize = CompOption::findOption (priv->opt, "hsize");
+
+ if (!hsize)
+ return false;
+
+ if (o->value ().i () * priv->size.height () > MAXSHORT)
+ return false;
+
+ priv->setVirtualScreenSize (hsize->value ().i (), o->value ().i ());
+ return true;
+ }
+ break;
+ case COMP_OPTION_NUMBER_OF_DESKTOPS:
+ if (o->set (value))
+ {
+ setNumberOfDesktops (o->value ().i ());
+ return true;
+ }
+ break;
+ case COMP_OPTION_DEFAULT_ICON:
+ if (o->set (value))
+ return updateDefaultIcon ();
+ break;
+ case COMP_OPTION_OUTPUTS:
+ if (!noDetection &&
+ priv->opt[COMP_OPTION_DETECT_OUTPUTS].value ().b ())
+ return false;
+
+ if (o->set (value))
+ {
+ priv->updateOutputDevices ();
+ return true;
+ }
+ break;
+ default:
+ if (CompOption::setOption (*o, value))
+ return true;
+ break;
+ }
+
+ return false;
+}
+
+void
+CompScreen::updateModifierMappings ()
+{
+ unsigned int modMask[CompModNum];
+ int i, minKeycode, maxKeycode, keysymsPerKeycode = 0;
+ KeySym* key;
+
+ for (i = 0; i < CompModNum; i++)
+ modMask[i] = 0;
+
+ XDisplayKeycodes (priv->dpy, &minKeycode, &maxKeycode);
+ key = XGetKeyboardMapping (priv->dpy,
+ minKeycode, (maxKeycode - minKeycode + 1),
+ &keysymsPerKeycode);
+
+ if (priv->modMap)
+ XFreeModifiermap (priv->modMap);
+
+ priv->modMap = XGetModifierMapping (priv->dpy);
+ if (priv->modMap && priv->modMap->max_keypermod > 0)
+ {
+ KeySym keysym;
+ int index, size, mask;
+
+ size = maskTableSize * priv->modMap->max_keypermod;
+
+ for (i = 0; i < size; i++)
+ {
+ if (!priv->modMap->modifiermap[i])
+ continue;
+
+ index = 0;
+ do
+ {
+ keysym = XKeycodeToKeysym (priv->dpy,
+ priv->modMap->modifiermap[i],
+ index++);
+ } while (!keysym && index < keysymsPerKeycode);
+
+ if (keysym)
+ {
+ mask = maskTable[i / priv->modMap->max_keypermod];
+
+ if (keysym == XK_Alt_L ||
+ keysym == XK_Alt_R)
+ {
+ modMask[CompModAlt] |= mask;
+ }
+ else if (keysym == XK_Meta_L ||
+ keysym == XK_Meta_R)
+ {
+ modMask[CompModMeta] |= mask;
+ }
+ else if (keysym == XK_Super_L ||
+ keysym == XK_Super_R)
+ {
+ modMask[CompModSuper] |= mask;
+ }
+ else if (keysym == XK_Hyper_L ||
+ keysym == XK_Hyper_R)
+ {
+ modMask[CompModHyper] |= mask;
+ }
+ else if (keysym == XK_Mode_switch)
+ {
+ modMask[CompModModeSwitch] |= mask;
+ }
+ else if (keysym == XK_Scroll_Lock)
+ {
+ modMask[CompModScrollLock] |= mask;
+ }
+ else if (keysym == XK_Num_Lock)
+ {
+ modMask[CompModNumLock] |= mask;
+ }
+ }
+ }
+
+ for (i = 0; i < CompModNum; i++)
+ {
+ if (!modMask[i])
+ modMask[i] = CompNoMask;
+ }
+
+ if (memcmp (modMask, priv->modMask, sizeof (modMask)))
+ {
+ memcpy (priv->modMask, modMask, sizeof (modMask));
+
+ priv->ignoredModMask = LockMask |
+ (modMask[CompModNumLock] & ~CompNoMask) |
+ (modMask[CompModScrollLock] & ~CompNoMask);
+
+ priv->updatePassiveKeyGrabs ();
+ }
+ }
+
+ if (key)
+ XFree (key);
+}
+
+unsigned int
+CompScreen::virtualToRealModMask (unsigned int modMask)
+{
+ int i;
+
+ for (i = 0; i < CompModNum; i++)
+ {
+ if (modMask & virtualModMask[i])
+ {
+ modMask &= ~virtualModMask[i];
+ modMask |= priv->modMask[i];
+ }
+ }
+
+ return modMask;
+}
+
+unsigned int
+CompScreen::keycodeToModifiers (int keycode)
+{
+ unsigned int mods = 0;
+ int mod, k;
+
+ for (mod = 0; mod < maskTableSize; mod++)
+ {
+ for (k = 0; k < priv->modMap->max_keypermod; k++)
+ {
+ if (priv->modMap->modifiermap[mod *
+ priv->modMap->max_keypermod + k] == keycode)
+ mods |= maskTable[mod];
+ }
+ }
+
+ return mods;
+}
+
+void
+PrivateScreen::processEvents ()
+{
+ XEvent event;
+
+ /* remove destroyed windows */
+ removeDestroyed ();
+
+ if (dirtyPluginList)
+ updatePlugins ();
+
+ while (XPending (dpy))
+ {
+ XNextEvent (dpy, &event);
+
+ switch (event.type) {
+ case ButtonPress:
+ case ButtonRelease:
+ pointerX = event.xbutton.x_root;
+ pointerY = event.xbutton.y_root;
+ break;
+ case KeyPress:
+ case KeyRelease:
+ pointerX = event.xkey.x_root;
+ pointerY = event.xkey.y_root;
+ break;
+ case MotionNotify:
+ pointerX = event.xmotion.x_root;
+ pointerY = event.xmotion.y_root;
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ pointerX = event.xcrossing.x_root;
+ pointerY = event.xcrossing.y_root;
+ break;
+ case ClientMessage:
+ if (event.xclient.message_type == Atoms::xdndPosition)
+ {
+ pointerX = event.xclient.data.l[2] >> 16;
+ pointerY = event.xclient.data.l[2] & 0xffff;
+ }
+ default:
+ break;
+ }
+
+ sn_display_process_event (snDisplay, &event);
+
+ inHandleEvent = true;
+ screen->handleEvent (&event);
+ inHandleEvent = false;
+
+ lastPointerX = pointerX;
+ lastPointerY = pointerY;
+ }
+}
+
+void
+PrivateScreen::updatePlugins ()
+{
+ CompOption *o;
+ CompPlugin *p;
+ unsigned int nPop, i, j;
+ CompPlugin::List pop;
+
+ dirtyPluginList = false;
+
+ o = &opt[COMP_OPTION_ACTIVE_PLUGINS];
+
+ /* The old plugin list always begins with the core plugin. To make sure
+ we don't unnecessarily unload plugins if the new plugin list does not
+ contain the core plugin, we have to use an offset */
+
+ if (o->value ().list ().size () > 0 &&
+ o->value ().list ()[0]. s (). compare ("core"))
+ i = 0;
+ else
+ i = 1;
+
+ /* j is initialized to 1 to make sure we never pop the core plugin */
+ for (j = 1; j < plugin.list ().size () &&
+ i < o->value ().list ().size (); i++, j++)
+ {
+ if (plugin.list ()[j].s ().compare (o->value ().list ()[i].s ()))
+ break;
+ }
+
+ nPop = plugin.list ().size () - j;
+
+ for (j = 0; j < nPop; j++)
+ {
+ pop.push_back (CompPlugin::pop ());
+ plugin.list ().pop_back ();
+ }
+
+ for (; i < o->value ().list ().size (); i++)
+ {
+ p = NULL;
+ foreach (CompPlugin *pp, pop)
+ {
+ if (o->value ().list ()[i]. s ().compare (pp->vTable->name ()) == 0)
+ {
+ if (CompPlugin::push (pp))
+ {
+ p = pp;
+ pop.erase (std::find (pop.begin (), pop.end (), pp));
+ break;
+ }
+ }
+ }
+
+ if (p == 0)
+ {
+ p = CompPlugin::load (o->value ().list ()[i].s ().c_str ());
+ if (p)
+ {
+ if (!CompPlugin::push (p))
+ {
+ CompPlugin::unload (p);
+ p = 0;
+ }
+ }
+ }
+
+ if (p)
+ {
+ plugin.list ().push_back (p->vTable->name ());
+ }
+ }
+
+ foreach (CompPlugin *pp, pop)
+ {
+ CompPlugin::unload (pp);
+ }
+
+ screen->setOptionForPlugin (screen, "core", o->name ().c_str (), plugin);
+}
+
+/* from fvwm2, Copyright Matthias Clasen, Dominik Vogt */
+static bool
+convertProperty (Display *dpy,
+ Time time,
+ Window w,
+ Atom target,
+ Atom property)
+{
+
+#define N_TARGETS 4
+
+ Atom conversionTargets[N_TARGETS];
+ long icccmVersion[] = { 2, 0 };
+
+ conversionTargets[0] = Atoms::targets;
+ conversionTargets[1] = Atoms::multiple;
+ conversionTargets[2] = Atoms::timestamp;
+ conversionTargets[3] = Atoms::version;
+
+ if (target == Atoms::targets)
+ XChangeProperty (dpy, w, property,
+ XA_ATOM, 32, PropModeReplace,
+ (unsigned char *) conversionTargets, N_TARGETS);
+ else if (target == Atoms::timestamp)
+ XChangeProperty (dpy, w, property,
+ XA_INTEGER, 32, PropModeReplace,
+ (unsigned char *) &time, 1);
+ else if (target == Atoms::version)
+ XChangeProperty (dpy, w, property,
+ XA_INTEGER, 32, PropModeReplace,
+ (unsigned char *) icccmVersion, 2);
+ else
+ return false;
+
+ /* Be sure the PropertyNotify has arrived so we
+ * can send SelectionNotify
+ */
+ XSync (dpy, FALSE);
+
+ return true;
+}
+
+/* from fvwm2, Copyright Matthias Clasen, Dominik Vogt */
+void
+PrivateScreen::handleSelectionRequest (XEvent *event)
+{
+ XSelectionEvent reply;
+
+ if (wmSnSelectionWindow != event->xselectionrequest.owner ||
+ wmSnAtom != event->xselectionrequest.selection)
+ return;
+
+ reply.type = SelectionNotify;
+ reply.display = dpy;
+ reply.requestor = event->xselectionrequest.requestor;
+ reply.selection = event->xselectionrequest.selection;
+ reply.target = event->xselectionrequest.target;
+ reply.property = None;
+ reply.time = event->xselectionrequest.time;
+
+ if (event->xselectionrequest.target == Atoms::multiple)
+ {
+ if (event->xselectionrequest.property != None)
+ {
+ Atom type, *adata;
+ int i, format;
+ unsigned long num, rest;
+ unsigned char *data;
+
+ if (XGetWindowProperty (dpy,
+ event->xselectionrequest.requestor,
+ event->xselectionrequest.property,
+ 0, 256, FALSE,
+ Atoms::atomPair,
+ &type, &format, &num, &rest,
+ &data) != Success)
+ return;
+
+ /* FIXME: to be 100% correct, should deal with rest > 0,
+ * but since we have 4 possible targets, we will hardly ever
+ * meet multiple requests with a length > 8
+ */
+ adata = (Atom *) data;
+ i = 0;
+ while (i < (int) num)
+ {
+ if (!convertProperty (dpy, wmSnTimestamp,
+ event->xselectionrequest.requestor,
+ adata[i], adata[i + 1]))
+ adata[i + 1] = None;
+
+ i += 2;
+ }
+
+ XChangeProperty (dpy,
+ event->xselectionrequest.requestor,
+ event->xselectionrequest.property,
+ Atoms::atomPair,
+ 32, PropModeReplace, data, num);
+ }
+ }
+ else
+ {
+ if (event->xselectionrequest.property == None)
+ event->xselectionrequest.property = event->xselectionrequest.target;
+
+ if (convertProperty (dpy, wmSnTimestamp,
+ event->xselectionrequest.requestor,
+ event->xselectionrequest.target,
+ event->xselectionrequest.property))
+ reply.property = event->xselectionrequest.property;
+ }
+
+ XSendEvent (dpy, event->xselectionrequest.requestor,
+ FALSE, 0L, (XEvent *) &reply);
+}
+
+void
+PrivateScreen::handleSelectionClear (XEvent *event)
+{
+ /* We need to unmanage the screen on which we lost the selection */
+ if (wmSnSelectionWindow != event->xselectionrequest.owner ||
+ wmSnAtom != event->xselectionrequest.selection)
+ return;
+
+ shutDown = TRUE;
+}
+
+
+#define HOME_IMAGEDIR ".compiz/images"
+
+bool
+CompScreen::readImageFromFile (const char *name,
+ int *width,
+ int *height,
+ void **data)
+{
+ Bool status;
+ int stride;
+
+ status = fileToImage (NULL, name, width, height, &stride, data);
+ if (!status)
+ {
+ char *home;
+
+ home = getenv ("HOME");
+ if (home)
+ {
+ char *path;
+
+ path = (char *) malloc (strlen (home) + strlen (HOME_IMAGEDIR) + 2);
+ if (path)
+ {
+ sprintf (path, "%s/%s", home, HOME_IMAGEDIR);
+ status = fileToImage (path, name, width, height, &stride, data);
+
+ free (path);
+
+ if (status)
+ return TRUE;
+ }
+ }
+
+ status = fileToImage (IMAGEDIR, name, width, height, &stride, data);
+ }
+
+ return status;
+}
+
+bool
+CompScreen::writeImageToFile (const char *path,
+ const char *name,
+ const char *format,
+ int width,
+ int height,
+ void *data)
+{
+ return imageToFile (path, name, format, width, height, width * 4, data);
+}
+
+Window
+CompScreen::getActiveWindow (Window root)
+{
+ Atom actual;
+ int result, format;
+ unsigned long n, left;
+ unsigned char *data;
+ Window w = None;
+
+ result = XGetWindowProperty (priv->dpy, root,
+ Atoms::winActive, 0L, 1L, FALSE,
+ XA_WINDOW, &actual, &format,
+ &n, &left, &data);
+
+ if (result == Success && n && data)
+ {
+ memcpy (&w, data, sizeof (Window));
+ XFree (data);
+ }
+
+ return w;
+}
+
+
+bool
+CompScreen::fileToImage (const char *path,
+ const char *name,
+ int *width,
+ int *height,
+ int *stride,
+ void **data)
+{
+ WRAPABLE_HND_FUNC_RETURN(10, bool, fileToImage, path, name, width, height,
+ stride, data)
+ return false;
+}
+
+bool
+CompScreen::imageToFile (const char *path,
+ const char *name,
+ const char *format,
+ int width,
+ int height,
+ int stride,
+ void *data)
+{
+ WRAPABLE_HND_FUNC_RETURN(11, bool, imageToFile, path, name, format, width,
+ height, stride, data)
+ return false;
+}
+
+void
+CompScreen::logMessage (const char *componentName,
+ CompLogLevel level,
+ const char *message)
+ WRAPABLE_HND_FUNC(15, logMessage, componentName, level, message)
+
+const char *
+logLevelToString (CompLogLevel level)
+{
+ switch (level) {
+ case CompLogLevelFatal:
+ return "Fatal";
+ case CompLogLevelError:
+ return "Error";
+ case CompLogLevelWarn:
+ return "Warn";
+ case CompLogLevelInfo:
+ return "Info";
+ case CompLogLevelDebug:
+ return "Debug";
+ default:
+ break;
+ }
+
+ return "Unknown";
+}
+
+static void
+logMessage (const char *componentName,
+ CompLogLevel level,
+ const char *message)
+{
+ fprintf (stderr, "%s (%s) - %s: %s\n",
+ programName, componentName,
+ logLevelToString (level), message);
+}
+
+void
+compLogMessage (const char *componentName,
+ CompLogLevel level,
+ const char *format,
+ ...)
+{
+ va_list args;
+ char message[2048];
+
+ va_start (args, format);
+
+ vsnprintf (message, 2048, format, args);
+
+ if (screen)
+ screen->logMessage (componentName, level, message);
+ else
+ logMessage (componentName, level, message);
+
+ va_end (args);
+}
+
+int
+CompScreen::getWmState (Window id)
+{
+ Atom actual;
+ int result, format;
+ unsigned long n, left;
+ unsigned char *data;
+ unsigned long state = NormalState;
+
+ result = XGetWindowProperty (priv->dpy, id,
+ Atoms::wmState, 0L, 2L, FALSE,
+ Atoms::wmState, &actual, &format,
+ &n, &left, &data);
+
+ if (result == Success && n && data)
+ {
+ memcpy (&state, data, sizeof (unsigned long));
+ XFree ((void *) data);
+ }
+
+ return state;
+}
+
+void
+CompScreen::setWmState (int state, Window id)
+{
+ unsigned long data[2];
+
+ data[0] = state;
+ data[1] = None;
+
+ XChangeProperty (priv->dpy, id,
+ Atoms::wmState, Atoms::wmState,
+ 32, PropModeReplace, (unsigned char *) data, 2);
+}
+
+unsigned int
+CompScreen::windowStateMask (Atom state)
+{
+ if (state == Atoms::winStateModal)
+ return CompWindowStateModalMask;
+ else if (state == Atoms::winStateSticky)
+ return CompWindowStateStickyMask;
+ else if (state == Atoms::winStateMaximizedVert)
+ return CompWindowStateMaximizedVertMask;
+ else if (state == Atoms::winStateMaximizedHorz)
+ return CompWindowStateMaximizedHorzMask;
+ else if (state == Atoms::winStateShaded)
+ return CompWindowStateShadedMask;
+ else if (state == Atoms::winStateSkipTaskbar)
+ return CompWindowStateSkipTaskbarMask;
+ else if (state == Atoms::winStateSkipPager)
+ return CompWindowStateSkipPagerMask;
+ else if (state == Atoms::winStateHidden)
+ return CompWindowStateHiddenMask;
+ else if (state == Atoms::winStateFullscreen)
+ return CompWindowStateFullscreenMask;
+ else if (state == Atoms::winStateAbove)
+ return CompWindowStateAboveMask;
+ else if (state == Atoms::winStateBelow)
+ return CompWindowStateBelowMask;
+ else if (state == Atoms::winStateDemandsAttention)
+ return CompWindowStateDemandsAttentionMask;
+ else if (state == Atoms::winStateDisplayModal)
+ return CompWindowStateDisplayModalMask;
+
+ return 0;
+}
+
+unsigned int
+CompScreen::windowStateFromString (const char *str)
+{
+ if (strcasecmp (str, "modal") == 0)
+ return CompWindowStateModalMask;
+ else if (strcasecmp (str, "sticky") == 0)
+ return CompWindowStateStickyMask;
+ else if (strcasecmp (str, "maxvert") == 0)
+ return CompWindowStateMaximizedVertMask;
+ else if (strcasecmp (str, "maxhorz") == 0)
+ return CompWindowStateMaximizedHorzMask;
+ else if (strcasecmp (str, "shaded") == 0)
+ return CompWindowStateShadedMask;
+ else if (strcasecmp (str, "skiptaskbar") == 0)
+ return CompWindowStateSkipTaskbarMask;
+ else if (strcasecmp (str, "skippager") == 0)
+ return CompWindowStateSkipPagerMask;
+ else if (strcasecmp (str, "hidden") == 0)
+ return CompWindowStateHiddenMask;
+ else if (strcasecmp (str, "fullscreen") == 0)
+ return CompWindowStateFullscreenMask;
+ else if (strcasecmp (str, "above") == 0)
+ return CompWindowStateAboveMask;
+ else if (strcasecmp (str, "below") == 0)
+ return CompWindowStateBelowMask;
+ else if (strcasecmp (str, "demandsattention") == 0)
+ return CompWindowStateDemandsAttentionMask;
+
+ return 0;
+}
+
+unsigned int
+CompScreen::getWindowState (Window id)
+{
+ Atom actual;
+ int result, format;
+ unsigned long n, left;
+ unsigned char *data;
+ unsigned int state = 0;
+
+ result = XGetWindowProperty (priv->dpy, id,
+ Atoms::winState,
+ 0L, 1024L, FALSE, XA_ATOM, &actual, &format,
+ &n, &left, &data);
+
+ if (result == Success && data)
+ {
+ Atom *a = (Atom *) data;
+
+ while (n--)
+ state |= windowStateMask (*a++);
+
+ XFree ((void *) data);
+ }
+
+ return state;
+}
+
+void
+CompScreen::setWindowState (unsigned int state,
+ Window id)
+{
+ Atom data[32];
+ int i = 0;
+
+ if (state & CompWindowStateModalMask)
+ data[i++] = Atoms::winStateModal;
+ if (state & CompWindowStateStickyMask)
+ data[i++] = Atoms::winStateSticky;
+ if (state & CompWindowStateMaximizedVertMask)
+ data[i++] = Atoms::winStateMaximizedVert;
+ if (state & CompWindowStateMaximizedHorzMask)
+ data[i++] = Atoms::winStateMaximizedHorz;
+ if (state & CompWindowStateShadedMask)
+ data[i++] = Atoms::winStateShaded;
+ if (state & CompWindowStateSkipTaskbarMask)
+ data[i++] = Atoms::winStateSkipTaskbar;
+ if (state & CompWindowStateSkipPagerMask)
+ data[i++] = Atoms::winStateSkipPager;
+ if (state & CompWindowStateHiddenMask)
+ data[i++] = Atoms::winStateHidden;
+ if (state & CompWindowStateFullscreenMask)
+ data[i++] = Atoms::winStateFullscreen;
+ if (state & CompWindowStateAboveMask)
+ data[i++] = Atoms::winStateAbove;
+ if (state & CompWindowStateBelowMask)
+ data[i++] = Atoms::winStateBelow;
+ if (state & CompWindowStateDemandsAttentionMask)
+ data[i++] = Atoms::winStateDemandsAttention;
+ if (state & CompWindowStateDisplayModalMask)
+ data[i++] = Atoms::winStateDisplayModal;
+
+ XChangeProperty (priv->dpy, id, Atoms::winState,
+ XA_ATOM, 32, PropModeReplace,
+ (unsigned char *) data, i);
+}
+
+unsigned int
+CompScreen::getWindowType (Window id)
+{
+ Atom actual;
+ int result, format;
+ unsigned long n, left;
+ unsigned char *data;
+
+ result = XGetWindowProperty (priv->dpy , id,
+ Atoms::winType,
+ 0L, 1L, FALSE, XA_ATOM, &actual, &format,
+ &n, &left, &data);
+
+ if (result == Success && n && data)
+ {
+ Atom a;
+
+ memcpy (&a, data, sizeof (Atom));
+ XFree ((void *) data);
+
+ if (a == Atoms::winTypeNormal)
+ return CompWindowTypeNormalMask;
+ else if (a == Atoms::winTypeMenu)
+ return CompWindowTypeMenuMask;
+ else if (a == Atoms::winTypeDesktop)
+ return CompWindowTypeDesktopMask;
+ else if (a == Atoms::winTypeDock)
+ return CompWindowTypeDockMask;
+ else if (a == Atoms::winTypeToolbar)
+ return CompWindowTypeToolbarMask;
+ else if (a == Atoms::winTypeUtil)
+ return CompWindowTypeUtilMask;
+ else if (a == Atoms::winTypeSplash)
+ return CompWindowTypeSplashMask;
+ else if (a == Atoms::winTypeDialog)
+ return CompWindowTypeDialogMask;
+ else if (a == Atoms::winTypeDropdownMenu)
+ return CompWindowTypeDropdownMenuMask;
+ else if (a == Atoms::winTypePopupMenu)
+ return CompWindowTypePopupMenuMask;
+ else if (a == Atoms::winTypeTooltip)
+ return CompWindowTypeTooltipMask;
+ else if (a == Atoms::winTypeNotification)
+ return CompWindowTypeNotificationMask;
+ else if (a == Atoms::winTypeCombo)
+ return CompWindowTypeComboMask;
+ else if (a == Atoms::winTypeDnd)
+ return CompWindowTypeDndMask;
+ }
+
+ return CompWindowTypeUnknownMask;
+}
+
+void
+CompScreen::getMwmHints (Window id,
+ unsigned int *func,
+ unsigned int *decor)
+{
+ Atom actual;
+ int result, format;
+ unsigned long n, left;
+ unsigned char *data;
+
+ *func = MwmFuncAll;
+ *decor = MwmDecorAll;
+
+ result = XGetWindowProperty (priv->dpy, id,
+ Atoms::mwmHints,
+ 0L, 20L, FALSE, Atoms::mwmHints,
+ &actual, &format, &n, &left, &data);
+
+ if (result == Success && n && data)
+ {
+ MwmHints *mwmHints = (MwmHints *) data;
+
+ if (n >= PropMotifWmHintElements)
+ {
+ if (mwmHints->flags & MwmHintsDecorations)
+ *decor = mwmHints->decorations;
+
+ if (mwmHints->flags & MwmHintsFunctions)
+ *func = mwmHints->functions;
+ }
+
+ XFree (data);
+ }
+}
+
+unsigned int
+CompScreen::getProtocols (Window id)
+{
+ Atom *protocol;
+ int count;
+ unsigned int protocols = 0;
+
+ if (XGetWMProtocols (priv->dpy, id, &protocol, &count))
+ {
+ int i;
+
+ for (i = 0; i < count; i++)
+ {
+ if (protocol[i] == Atoms::wmDeleteWindow)
+ protocols |= CompWindowProtocolDeleteMask;
+ else if (protocol[i] == Atoms::wmTakeFocus)
+ protocols |= CompWindowProtocolTakeFocusMask;
+ else if (protocol[i] == Atoms::wmPing)
+ protocols |= CompWindowProtocolPingMask;
+ else if (protocol[i] == Atoms::wmSyncRequest)
+ protocols |= CompWindowProtocolSyncRequestMask;
+ }
+
+ XFree (protocol);
+ }
+
+ return protocols;
+}
+
+unsigned int
+CompScreen::getWindowProp (Window id,
+ Atom property,
+ unsigned int defaultValue)
+{
+ Atom actual;
+ int result, format;
+ unsigned long n, left;
+ unsigned char *data;
+
+ result = XGetWindowProperty (priv->dpy, id, property,
+ 0L, 1L, FALSE, XA_CARDINAL, &actual, &format,
+ &n, &left, &data);
+
+ if (result == Success && n && data)
+ {
+ unsigned long value;
+
+ memcpy (&value, data, sizeof (unsigned long));
+
+ XFree (data);
+
+ return (unsigned int) value;
+ }
+
+ return defaultValue;
+}
+
+void
+CompScreen::setWindowProp (Window id,
+ Atom property,
+ unsigned int value)
+{
+ unsigned long data = value;
+
+ XChangeProperty (priv->dpy, id, property,
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *) &data, 1);
+}
+
+bool
+CompScreen::readWindowProp32 (Window id,
+ Atom property,
+ unsigned short *returnValue)
+{
+ Atom actual;
+ int result, format;
+ unsigned long n, left;
+ unsigned char *data;
+
+ result = XGetWindowProperty (priv->dpy, id, property,
+ 0L, 1L, FALSE, XA_CARDINAL, &actual, &format,
+ &n, &left, &data);
+
+ if (result == Success && n && data)
+ {
+ CARD32 value;
+
+ memcpy (&value, data, sizeof (CARD32));
+
+ XFree (data);
+
+ *returnValue = value >> 16;
+
+ return true;
+ }
+
+ return false;
+}
+
+unsigned short
+CompScreen::getWindowProp32 (Window id,
+ Atom property,
+ unsigned short defaultValue)
+{
+ unsigned short result;
+
+ if (readWindowProp32 (id, property, &result))
+ return result;
+
+ return defaultValue;
+}
+
+void
+CompScreen::setWindowProp32 (Window id,
+ Atom property,
+ unsigned short value)
+{
+ CARD32 value32;
+
+ value32 = value << 16 | value;
+
+ XChangeProperty (priv->dpy, id, property,
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *) &value32, 1);
+}
+
+void
+ScreenInterface::handleEvent (XEvent *event)
+ WRAPABLE_DEF (handleEvent, event)
+
+void
+ScreenInterface::handleCompizEvent (const char *plugin,
+ const char *event,
+ CompOption::Vector &options)
+ WRAPABLE_DEF (handleCompizEvent, plugin, event, options)
+
+bool
+ScreenInterface::fileToImage (const char *path,
+ const char *name,
+ int *width,
+ int *height,
+ int *stride,
+ void **data)
+ WRAPABLE_DEF (fileToImage, path, name, width, height, stride, data)
+
+bool
+ScreenInterface::imageToFile (const char *path,
+ const char *name,
+ const char *format,
+ int width,
+ int height,
+ int stride,
+ void *data)
+ WRAPABLE_DEF (imageToFile, path, name, format, width, height, stride, data)
+
+CompMatch::Expression *
+ScreenInterface::matchInitExp (const CompString value)
+ WRAPABLE_DEF (matchInitExp, value)
+
+void
+ScreenInterface::matchExpHandlerChanged ()
+ WRAPABLE_DEF (matchExpHandlerChanged)
+
+void
+ScreenInterface::matchPropertyChanged (CompWindow *window)
+ WRAPABLE_DEF (matchPropertyChanged, window)
+
+void
+ScreenInterface::logMessage (const char *componentName,
+ CompLogLevel level,
+ const char *message)
+ WRAPABLE_DEF (logMessage, componentName, level, message)
+
+
bool
PrivateScreen::desktopHintEqual (unsigned long *data,
int size,
@@ -119,8 +1954,8 @@ PrivateScreen::setDesktopHints ()
}
if (!desktopHintEqual (data, dSize, offset, hintSize))
- XChangeProperty (display->dpy (), root,
- display->atoms ().desktopViewport,
+ XChangeProperty (dpy, root,
+ Atoms::desktopViewport,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &data[offset], hintSize);
@@ -133,8 +1968,8 @@ PrivateScreen::setDesktopHints ()
}
if (!desktopHintEqual (data, dSize, offset, hintSize))
- XChangeProperty (display->dpy (), root,
- display->atoms ().desktopGeometry,
+ XChangeProperty (dpy, root,
+ Atoms::desktopGeometry,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &data[offset], hintSize);
@@ -150,8 +1985,8 @@ PrivateScreen::setDesktopHints ()
}
if (!desktopHintEqual (data, dSize, offset, hintSize))
- XChangeProperty (display->dpy (), root,
- display->atoms ().workarea,
+ XChangeProperty (dpy, root,
+ Atoms::workarea,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &data[offset], hintSize);
@@ -161,8 +1996,8 @@ PrivateScreen::setDesktopHints ()
hintSize = 1;
if (!desktopHintEqual (data, dSize, offset, hintSize))
- XChangeProperty (display->dpy (), root,
- display->atoms ().numberOfDesktops,
+ XChangeProperty (dpy, root,
+ Atoms::numberOfDesktops,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &data[offset], hintSize);
@@ -186,7 +2021,7 @@ void
PrivateScreen::updateOutputDevices ()
{
CompOption::Value::Vector &list =
- opt[COMP_SCREEN_OPTION_OUTPUTS].value ().list ();
+ opt[COMP_OPTION_OUTPUTS].value ().list ();
unsigned int nOutput = 0;
int x, y, bits;
@@ -266,15 +2101,15 @@ PrivateScreen::updateOutputDevices ()
void
PrivateScreen::detectOutputDevices ()
{
- if (!noDetection && opt[COMP_SCREEN_OPTION_DETECT_OUTPUTS].value ().b ())
+ if (!noDetection && opt[COMP_OPTION_DETECT_OUTPUTS].value ().b ())
{
CompString name;
CompOption::Value value;
- if (display->screenInfo ().size ())
+ if (screenInfo.size ())
{
CompOption::Value::Vector l;
- foreach (XineramaScreenInfo xi, display->screenInfo ())
+ foreach (XineramaScreenInfo xi, screenInfo)
{
l.push_back (compPrintf ("%dx%d+%d+%d", xi.width, xi.height,
xi.x_org, xi.y_org));
@@ -290,11 +2125,11 @@ PrivateScreen::detectOutputDevices ()
value.set (CompOption::TypeString, l);
}
- name = opt[COMP_SCREEN_OPTION_OUTPUTS].name ();
+ name = opt[COMP_OPTION_OUTPUTS].name ();
- opt[COMP_SCREEN_OPTION_DETECT_OUTPUTS].value ().set (false);
- core->setOptionForPlugin (screen, "core", name.c_str (), value);
- opt[COMP_SCREEN_OPTION_DETECT_OUTPUTS].value ().set (true);
+ opt[COMP_OPTION_DETECT_OUTPUTS].value ().set (false);
+ screen->setOptionForPlugin (screen, "core", name.c_str (), value);
+ opt[COMP_OPTION_DETECT_OUTPUTS].value ().set (true);
}
else
@@ -303,134 +2138,14 @@ PrivateScreen::detectOutputDevices ()
}
}
-CompOption::Vector &
-CompScreen::getScreenOptions (CompObject *object)
-{
- CompScreen *screen = dynamic_cast<CompScreen *> (object);
- if (screen)
- return screen->priv->opt;
- return noOptions;
-}
-
-bool
-CompScreen::setScreenOption (CompObject *object,
- const char *name,
- CompOption::Value &value)
-{
- CompScreen *screen = dynamic_cast<CompScreen *> (object);
- if (screen)
- return screen->setOption (name, value);
- return false;
-}
-
-bool
-CompScreen::setOption (const char *name,
- CompOption::Value &value)
-{
- CompOption *o;
- unsigned int index;
-
- o = CompOption::findOption (priv->opt, name, &index);
- if (!o)
- return false;
-
- switch (index) {
-
- case COMP_SCREEN_OPTION_DETECT_OUTPUTS:
- if (o->set (value))
- {
- if (value.b ())
- priv->detectOutputDevices ();
-
- return true;
- }
- break;
- case COMP_SCREEN_OPTION_HSIZE:
- if (o->set (value))
- {
- CompOption *vsize;
-
- vsize = CompOption::findOption (priv->opt, "vsize");
-
- if (!vsize)
- return false;
-
- if (o->value ().i () * priv->size.width () > MAXSHORT)
- return false;
-
- priv->setVirtualScreenSize (o->value ().i (), vsize->value ().i ());
- return true;
- }
- break;
- case COMP_SCREEN_OPTION_VSIZE:
- if (o->set (value))
- {
- CompOption *hsize;
-
- hsize = CompOption::findOption (priv->opt, "hsize");
-
- if (!hsize)
- return false;
-
- if (o->value ().i () * priv->size.height () > MAXSHORT)
- return false;
-
- priv->setVirtualScreenSize (hsize->value ().i (), o->value ().i ());
- return true;
- }
- break;
- case COMP_SCREEN_OPTION_NUMBER_OF_DESKTOPS:
- if (o->set (value))
- {
- setNumberOfDesktops (o->value ().i ());
- return true;
- }
- break;
- case COMP_SCREEN_OPTION_DEFAULT_ICON:
- if (o->set (value))
- return updateDefaultIcon ();
- break;
- case COMP_SCREEN_OPTION_OUTPUTS:
- if (!noDetection &&
- priv->opt[COMP_SCREEN_OPTION_DETECT_OUTPUTS].value ().b ())
- return false;
-
- if (o->set (value))
- {
- priv->updateOutputDevices ();
- return true;
- }
- break;
- default:
- if (CompOption::setScreenOption (this, *o, value))
- return true;
- break;
- }
-
- return false;
-}
-
-const CompMetadata::OptionInfo coreScreenOptionInfo[COMP_SCREEN_OPTION_NUM] = {
- { "hsize", "int", "<min>1</min><max>32</max>", 0, 0 },
- { "vsize", "int", "<min>1</min><max>32</max>", 0, 0 },
- { "default_icon", "string", 0, 0, 0 },
- { "number_of_desktops", "int", "<min>1</min>", 0, 0 },
- { "detect_outputs", "bool", 0, 0, 0 },
- { "outputs", "list", "<type>string</type>", 0, 0 },
- { "overlapping_outputs", "int",
- RESTOSTRING (0, OUTPUT_OVERLAP_MODE_LAST), 0, 0 },
- { "focus_prevention_level", "int",
- RESTOSTRING (0, FOCUS_PREVENTION_LEVEL_LAST), 0, 0 },
- { "focus_prevention_match", "match", 0, 0, 0 },
-};
void
PrivateScreen::updateStartupFeedback ()
{
if (!startupSequences.empty ())
- XDefineCursor (display->dpy (), root, busyCursor);
+ XDefineCursor (dpy, root, busyCursor);
else
- XDefineCursor (display->dpy (), root, normalCursor);
+ XDefineCursor (dpy, root, normalCursor);
}
#define STARTUP_TIMEOUT_DELAY 15000
@@ -558,7 +2273,7 @@ PrivateScreen::updateScreenEdges ()
for (i = 0; i < SCREEN_EDGE_NUM; i++)
{
if (screenEdge[i].id)
- XMoveResizeWindow (display->dpy (), screenEdge[i].id,
+ XMoveResizeWindow (dpy, screenEdge[i].id,
geometry[i].xw * size.width () + geometry[i].x0,
geometry[i].yh * size.height () + geometry[i].y0,
geometry[i].ww * size.width () + geometry[i].w0,
@@ -579,7 +2294,7 @@ CompScreen::setCurrentOutput (unsigned int outputNum)
void
PrivateScreen::reshape (int w, int h)
{
- display->updateScreenInfo();
+ updateScreenInfo();
region.rects = &region.extents;
region.numRects = 1;
@@ -618,26 +2333,26 @@ CompScreen::configure (XConfigureEvent *ce)
void
PrivateScreen::setSupportingWmCheck ()
{
- XChangeProperty (display->dpy (), grabWindow,
- display->atoms ().supportingWmCheck,
+ XChangeProperty (dpy, grabWindow,
+ Atoms::supportingWmCheck,
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) &grabWindow, 1);
- XChangeProperty (display->dpy (), grabWindow, display->atoms ().wmName,
- display->atoms ().utf8String, 8, PropModeReplace,
+ XChangeProperty (dpy, grabWindow, Atoms::wmName,
+ Atoms::utf8String, 8, PropModeReplace,
(unsigned char *) PACKAGE, strlen (PACKAGE));
- XChangeProperty (display->dpy (), grabWindow, display->atoms ().winState,
+ XChangeProperty (dpy, grabWindow, Atoms::winState,
XA_ATOM, 32, PropModeReplace,
- (unsigned char *) &display->atoms ().winStateSkipTaskbar,
+ (unsigned char *) &Atoms::winStateSkipTaskbar,
1);
- XChangeProperty (display->dpy (), grabWindow, display->atoms ().winState,
+ XChangeProperty (dpy, grabWindow, Atoms::winState,
XA_ATOM, 32, PropModeAppend,
- (unsigned char *) &display->atoms ().winStateSkipPager, 1);
- XChangeProperty (display->dpy (), grabWindow, display->atoms ().winState,
+ (unsigned char *) &Atoms::winStateSkipPager, 1);
+ XChangeProperty (dpy, grabWindow, Atoms::winState,
XA_ATOM, 32, PropModeAppend,
- (unsigned char *) &display->atoms ().winStateHidden, 1);
+ (unsigned char *) &Atoms::winStateHidden, 1);
- XChangeProperty (display->dpy (), root, display->atoms ().supportingWmCheck,
+ XChangeProperty (dpy, root, Atoms::supportingWmCheck,
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) &grabWindow, 1);
}
@@ -648,99 +2363,99 @@ PrivateScreen::setSupported ()
Atom data[256];
int i = 0;
- data[i++] = display->atoms ().supported;
- data[i++] = display->atoms ().supportingWmCheck;
+ data[i++] = Atoms::supported;
+ data[i++] = Atoms::supportingWmCheck;
- data[i++] = display->atoms ().utf8String;
+ data[i++] = Atoms::utf8String;
- data[i++] = display->atoms ().clientList;
- data[i++] = display->atoms ().clientListStacking;
+ data[i++] = Atoms::clientList;
+ data[i++] = Atoms::clientListStacking;
- data[i++] = display->atoms ().winActive;
+ data[i++] = Atoms::winActive;
- data[i++] = display->atoms ().desktopViewport;
- data[i++] = display->atoms ().desktopGeometry;
- data[i++] = display->atoms ().currentDesktop;
- data[i++] = display->atoms ().numberOfDesktops;
- data[i++] = display->atoms ().showingDesktop;
+ data[i++] = Atoms::desktopViewport;
+ data[i++] = Atoms::desktopGeometry;
+ data[i++] = Atoms::currentDesktop;
+ data[i++] = Atoms::numberOfDesktops;
+ data[i++] = Atoms::showingDesktop;
- data[i++] = display->atoms ().workarea;
+ data[i++] = Atoms::workarea;
- data[i++] = display->atoms ().wmName;
+ data[i++] = Atoms::wmName;
/*
- data[i++] = display->atoms ().wmVisibleName;
+ data[i++] = Atoms::wmVisibleName;
*/
- data[i++] = display->atoms ().wmStrut;
- data[i++] = display->atoms ().wmStrutPartial;
+ data[i++] = Atoms::wmStrut;
+ data[i++] = Atoms::wmStrutPartial;
/*
- data[i++] = display->atoms ().wmPid;
+ data[i++] = Atoms::wmPid;
*/
- data[i++] = display->atoms ().wmUserTime;
- data[i++] = display->atoms ().frameExtents;
- data[i++] = display->atoms ().frameWindow;
-
- data[i++] = display->atoms ().winState;
- data[i++] = display->atoms ().winStateModal;
- data[i++] = display->atoms ().winStateSticky;
- data[i++] = display->atoms ().winStateMaximizedVert;
- data[i++] = display->atoms ().winStateMaximizedHorz;
- data[i++] = display->atoms ().winStateShaded;
- data[i++] = display->atoms ().winStateSkipTaskbar;
- data[i++] = display->atoms ().winStateSkipPager;
- data[i++] = display->atoms ().winStateHidden;
- data[i++] = display->atoms ().winStateFullscreen;
- data[i++] = display->atoms ().winStateAbove;
- data[i++] = display->atoms ().winStateBelow;
- data[i++] = display->atoms ().winStateDemandsAttention;
-
- data[i++] = display->atoms ().winOpacity;
- data[i++] = display->atoms ().winBrightness;
+ data[i++] = Atoms::wmUserTime;
+ data[i++] = Atoms::frameExtents;
+ data[i++] = Atoms::frameWindow;
+
+ data[i++] = Atoms::winState;
+ data[i++] = Atoms::winStateModal;
+ data[i++] = Atoms::winStateSticky;
+ data[i++] = Atoms::winStateMaximizedVert;
+ data[i++] = Atoms::winStateMaximizedHorz;
+ data[i++] = Atoms::winStateShaded;
+ data[i++] = Atoms::winStateSkipTaskbar;
+ data[i++] = Atoms::winStateSkipPager;
+ data[i++] = Atoms::winStateHidden;
+ data[i++] = Atoms::winStateFullscreen;
+ data[i++] = Atoms::winStateAbove;
+ data[i++] = Atoms::winStateBelow;
+ data[i++] = Atoms::winStateDemandsAttention;
+
+ data[i++] = Atoms::winOpacity;
+ data[i++] = Atoms::winBrightness;
#warning fixme
#if 0
if (canDoSaturated)
{
- data[i++] = display->atoms ().winSaturation;
- data[i++] = display->atoms ().winStateDisplayModal;
+ data[i++] = Atoms::winSaturation;
+ data[i++] = Atoms::winStateDisplayModal;
}
#endif
- data[i++] = display->atoms ().wmAllowedActions;
-
- data[i++] = display->atoms ().winActionMove;
- data[i++] = display->atoms ().winActionResize;
- data[i++] = display->atoms ().winActionStick;
- data[i++] = display->atoms ().winActionMinimize;
- data[i++] = display->atoms ().winActionMaximizeHorz;
- data[i++] = display->atoms ().winActionMaximizeVert;
- data[i++] = display->atoms ().winActionFullscreen;
- data[i++] = display->atoms ().winActionClose;
- data[i++] = display->atoms ().winActionShade;
- data[i++] = display->atoms ().winActionChangeDesktop;
- data[i++] = display->atoms ().winActionAbove;
- data[i++] = display->atoms ().winActionBelow;
-
- data[i++] = display->atoms ().winType;
- data[i++] = display->atoms ().winTypeDesktop;
- data[i++] = display->atoms ().winTypeDock;
- data[i++] = display->atoms ().winTypeToolbar;
- data[i++] = display->atoms ().winTypeMenu;
- data[i++] = display->atoms ().winTypeSplash;
- data[i++] = display->atoms ().winTypeDialog;
- data[i++] = display->atoms ().winTypeUtil;
- data[i++] = display->atoms ().winTypeNormal;
-
- data[i++] = display->atoms ().wmDeleteWindow;
- data[i++] = display->atoms ().wmPing;
-
- data[i++] = display->atoms ().wmMoveResize;
- data[i++] = display->atoms ().moveResizeWindow;
- data[i++] = display->atoms ().restackWindow;
-
- XChangeProperty (display->dpy (), root, display->atoms ().supported,
+ data[i++] = Atoms::wmAllowedActions;
+
+ data[i++] = Atoms::winActionMove;
+ data[i++] = Atoms::winActionResize;
+ data[i++] = Atoms::winActionStick;
+ data[i++] = Atoms::winActionMinimize;
+ data[i++] = Atoms::winActionMaximizeHorz;
+ data[i++] = Atoms::winActionMaximizeVert;
+ data[i++] = Atoms::winActionFullscreen;
+ data[i++] = Atoms::winActionClose;
+ data[i++] = Atoms::winActionShade;
+ data[i++] = Atoms::winActionChangeDesktop;
+ data[i++] = Atoms::winActionAbove;
+ data[i++] = Atoms::winActionBelow;
+
+ data[i++] = Atoms::winType;
+ data[i++] = Atoms::winTypeDesktop;
+ data[i++] = Atoms::winTypeDock;
+ data[i++] = Atoms::winTypeToolbar;
+ data[i++] = Atoms::winTypeMenu;
+ data[i++] = Atoms::winTypeSplash;
+ data[i++] = Atoms::winTypeDialog;
+ data[i++] = Atoms::winTypeUtil;
+ data[i++] = Atoms::winTypeNormal;
+
+ data[i++] = Atoms::wmDeleteWindow;
+ data[i++] = Atoms::wmPing;
+
+ data[i++] = Atoms::wmMoveResize;
+ data[i++] = Atoms::moveResizeWindow;
+ data[i++] = Atoms::restackWindow;
+
+ XChangeProperty (dpy, root, Atoms::supported,
XA_ATOM, 32, PropModeReplace, (unsigned char *) data, i);
}
@@ -753,8 +2468,8 @@ PrivateScreen::getDesktopHints ()
unsigned long n, left;
unsigned char *propData;
- result = XGetWindowProperty (display->dpy (), root,
- display->atoms ().numberOfDesktops,
+ result = XGetWindowProperty (dpy, root,
+ Atoms::numberOfDesktops,
0L, 1L, FALSE, XA_CARDINAL, &actual, &format,
&n, &left, &propData);
@@ -767,8 +2482,8 @@ PrivateScreen::getDesktopHints ()
nDesktop = data[0];
}
- result = XGetWindowProperty (display->dpy (), root,
- display->atoms ().desktopViewport, 0L, 2L,
+ result = XGetWindowProperty (dpy, root,
+ Atoms::desktopViewport, 0L, 2L,
FALSE, XA_CARDINAL, &actual, &format,
&n, &left, &propData);
@@ -788,8 +2503,8 @@ PrivateScreen::getDesktopHints ()
XFree (propData);
}
- result = XGetWindowProperty (display->dpy (), root,
- display->atoms ().currentDesktop,
+ result = XGetWindowProperty (dpy, root,
+ Atoms::currentDesktop,
0L, 1L, FALSE, XA_CARDINAL, &actual, &format,
&n, &left, &propData);
@@ -802,8 +2517,8 @@ PrivateScreen::getDesktopHints ()
currentDesktop = data[0];
}
- result = XGetWindowProperty (display->dpy (), root,
- display->atoms ().showingDesktop,
+ result = XGetWindowProperty (dpy, root,
+ Atoms::showingDesktop,
0L, 1L, FALSE, XA_CARDINAL, &actual, &format,
&n, &left, &propData);
@@ -818,13 +2533,13 @@ PrivateScreen::getDesktopHints ()
data[0] = currentDesktop;
- XChangeProperty (display->dpy (), root, display->atoms ().currentDesktop,
+ XChangeProperty (dpy, root, Atoms::currentDesktop,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) data, 1);
data[0] = showingDesktopMask ? TRUE : FALSE;
- XChangeProperty (display->dpy (), root, display->atoms ().showingDesktop,
+ XChangeProperty (dpy, root, Atoms::showingDesktop,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) data, 1);
}
@@ -832,12 +2547,12 @@ PrivateScreen::getDesktopHints ()
void
CompScreen::enterShowDesktopMode ()
{
- WRAPABLE_HND_FUNC(0, enterShowDesktopMode)
+ WRAPABLE_HND_FUNC(16, enterShowDesktopMode)
+
- CompDisplay *d = priv->display;
unsigned long data = 1;
int count = 0;
- CompOption *st = d->getOption ("hide_skip_taskbar_windows");
+ CompOption &st = priv->opt[COMP_OPTION_HIDE_SKIP_TASKBAR_WINDOWS];
priv->showingDesktopMask = ~(CompWindowTypeDesktopMask |
CompWindowTypeDockMask);
@@ -846,7 +2561,7 @@ CompScreen::enterShowDesktopMode ()
{
if ((priv->showingDesktopMask & w->wmType ()) &&
(!(w->state () & CompWindowStateSkipTaskbarMask) ||
- (st && st->value ().b ())))
+ (st.value ().b ())))
{
if (!w->inShowDesktopMode () && !w->grabbed () &&
w->managed () && w->focus ())
@@ -866,8 +2581,8 @@ CompScreen::enterShowDesktopMode ()
data = 0;
}
- XChangeProperty (priv->display->dpy (), priv->root,
- priv->display->atoms ().showingDesktop,
+ XChangeProperty (priv->dpy, priv->root,
+ Atoms::showingDesktop,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &data, 1);
}
@@ -875,7 +2590,7 @@ CompScreen::enterShowDesktopMode ()
void
CompScreen::leaveShowDesktopMode (CompWindow *window)
{
- WRAPABLE_HND_FUNC(1, leaveShowDesktopMode, window)
+ WRAPABLE_HND_FUNC(17, leaveShowDesktopMode, window)
unsigned long data = 0;
@@ -912,402 +2627,12 @@ CompScreen::leaveShowDesktopMode (CompWindow *window)
focusDefaultWindow ();
}
- XChangeProperty (priv->display->dpy (), priv->root,
- priv->display->atoms ().showingDesktop,
+ XChangeProperty (priv->dpy, priv->root,
+ Atoms::showingDesktop,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &data, 1);
}
-
-
-CompScreen::CompScreen ():
- CompObject (COMP_OBJECT_TYPE_SCREEN, "screen", &screenPrivateIndices)
-{
- priv = new PrivateScreen (this);
- assert (priv);
-}
-
-PrivateScreen::PrivateScreen (CompScreen *screen) :
- screen(screen),
- display (0),
- windows (),
- size (0, 0),
- vp (0, 0),
- vpSize (1, 1),
- nDesktop (1),
- currentDesktop (0),
- root (None),
- grabWindow (None),
- desktopWindowCount (0),
- mapNum (1),
- activeNum (1),
- outputDevs (0),
- currentOutputDev (0),
- hasOverlappingOutputs (false),
- currentHistory (0),
- snContext (0),
- startupSequences (0),
- startupSequenceTimer (),
- groups (0),
- defaultIcon (0),
- clientList (0),
- nClientList (0),
- buttonGrabs (0),
- keyGrabs (0),
- grabs (0),
- pendingDestroys (0),
- showingDesktopMask (0),
- desktopHintData (0),
- desktopHintSize (0),
- opt (COMP_SCREEN_OPTION_NUM)
-{
- memset (history, 0, sizeof (history));
-}
-
-PrivateScreen::~PrivateScreen ()
-{
- CompOption::finiScreenOptions (screen, opt);
-}
-
-bool
-CompScreen::init (CompDisplay *display, int screenNum)
-{
- Display *dpy = display->dpy ();
- Window newWmSnOwner = None;
- Atom wmSnAtom = 0;
- Time wmSnTimestamp = 0;
- XEvent event;
- XSetWindowAttributes attr;
- Window currentWmSnOwner;
- char buf[128];
- bool rv;
-
- sprintf (buf, "WM_S%d", screenNum);
- wmSnAtom = XInternAtom (dpy, buf, 0);
-
- currentWmSnOwner = XGetSelectionOwner (dpy, wmSnAtom);
-
- if (currentWmSnOwner != None)
- {
- if (!replaceCurrentWm)
- {
- compLogMessage (display, "core", CompLogLevelError,
- "Screen %d on display \"%s\" already "
- "has a window manager; try using the "
- "--replace option to replace the current "
- "window manager.",
- screenNum, DisplayString (dpy));
-
- return false;
- }
-
- XSelectInput (dpy, currentWmSnOwner, StructureNotifyMask);
- }
-
- attr.override_redirect = TRUE;
- attr.event_mask = PropertyChangeMask;
-
- newWmSnOwner =
- XCreateWindow (dpy, XRootWindow (dpy, screenNum),
- -100, -100, 1, 1, 0,
- CopyFromParent, CopyFromParent,
- CopyFromParent,
- CWOverrideRedirect | CWEventMask,
- &attr);
-
- XChangeProperty (dpy,
- newWmSnOwner,
- display->atoms ().wmName,
- display->atoms ().utf8String, 8,
- PropModeReplace,
- (unsigned char *) PACKAGE,
- strlen (PACKAGE));
-
- XWindowEvent (dpy, newWmSnOwner, PropertyChangeMask, &event);
-
- wmSnTimestamp = event.xproperty.time;
-
- XSetSelectionOwner (dpy, wmSnAtom, newWmSnOwner, wmSnTimestamp);
-
- if (XGetSelectionOwner (dpy, wmSnAtom) != newWmSnOwner)
- {
- compLogMessage (display, "core", CompLogLevelError,
- "Could not acquire window manager "
- "selection on screen %d display \"%s\"",
- screenNum, DisplayString (dpy));
-
- XDestroyWindow (dpy, newWmSnOwner);
-
- return false;
- }
-
- /* Send client message indicating that we are now the WM */
- event.xclient.type = ClientMessage;
- event.xclient.window = XRootWindow (dpy, screenNum);
- event.xclient.message_type = display->atoms ().manager;
- event.xclient.format = 32;
- event.xclient.data.l[0] = wmSnTimestamp;
- event.xclient.data.l[1] = wmSnAtom;
- event.xclient.data.l[2] = 0;
- event.xclient.data.l[3] = 0;
- event.xclient.data.l[4] = 0;
-
- XSendEvent (dpy, XRootWindow (dpy, screenNum), FALSE,
- StructureNotifyMask, &event);
-
- /* Wait for old window manager to go away */
- if (currentWmSnOwner != None)
- {
- do {
- XWindowEvent (dpy, currentWmSnOwner,
- StructureNotifyMask, &event);
- } while (event.type != DestroyNotify);
- }
-
- CompDisplay::checkForError (dpy);
-
- XGrabServer (dpy);
-
- XSelectInput (dpy, XRootWindow (dpy, screenNum),
- SubstructureRedirectMask |
- SubstructureNotifyMask |
- StructureNotifyMask |
- PropertyChangeMask |
- LeaveWindowMask |
- EnterWindowMask |
- KeyPressMask |
- KeyReleaseMask |
- ButtonPressMask |
- ButtonReleaseMask |
- FocusChangeMask |
- ExposureMask);
-
- if (CompDisplay::checkForError (dpy))
- {
- compLogMessage (display, "core", CompLogLevelError,
- "Another window manager is "
- "already running on screen: %d", screenNum);
-
- XUngrabServer (dpy);
- return false;
- }
-
- rv = init (display, screenNum, newWmSnOwner, wmSnAtom, wmSnTimestamp);
-
- XUngrabServer (dpy);
- return rv;
-}
-
-
-bool
-CompScreen::init (CompDisplay *display,
- int screenNum,
- Window wmSnSelectionWindow,
- Atom wmSnAtom,
- Time wmSnTimestamp)
-{
- Display *dpy = display->dpy ();
- static char data = 0;
- XColor black;
- Pixmap bitmap;
- XVisualInfo templ;
- XVisualInfo *visinfo;
- Window rootReturn, parentReturn;
- Window *children;
- unsigned int nchildren;
- int defaultDepth, nvisinfo, i;
- XSetWindowAttributes attrib;
-
- priv->display = display;
-
- if (!coreMetadata->initScreenOptions (this, coreScreenOptionInfo,
- COMP_SCREEN_OPTION_NUM, priv->opt))
- return false;
-
- priv->vpSize.setWidth (priv->opt[COMP_SCREEN_OPTION_HSIZE].value ().i ());
- priv->vpSize.setHeight (priv->opt[COMP_SCREEN_OPTION_VSIZE].value ().i ());
-
- for (i = 0; i < SCREEN_EDGE_NUM; i++)
- {
- priv->screenEdge[i].id = None;
- priv->screenEdge[i].count = 0;
- }
-
- priv->screenNum = screenNum;
- priv->colormap = DefaultColormap (dpy, screenNum);
- priv->root = XRootWindow (dpy, screenNum);
-
- priv->snContext = sn_monitor_context_new (display->snDisplay (),
- screenNum,
- compScreenSnEvent, this,
- NULL);
-
- priv->wmSnSelectionWindow = wmSnSelectionWindow;
- priv->wmSnAtom = wmSnAtom;
- priv->wmSnTimestamp = wmSnTimestamp;
-
- if (!XGetWindowAttributes (dpy, priv->root, &priv->attrib))
- return false;
-
- priv->workArea.x = 0;
- priv->workArea.y = 0;
- priv->workArea.width = priv->attrib.width;
- priv->workArea.height = priv->attrib.height;
- priv->grabWindow = None;
-
- templ.visualid = XVisualIDFromVisual (priv->attrib.visual);
-
- visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);
- if (!nvisinfo)
- {
- compLogMessage (display, "core", CompLogLevelFatal,
- "Couldn't get visual info for default visual");
- return false;
- }
-
- defaultDepth = visinfo->depth;
-
- black.red = black.green = black.blue = 0;
-
- if (!XAllocColor (dpy, priv->colormap, &black))
- {
- compLogMessage (display, "core", CompLogLevelFatal,
- "Couldn't allocate color");
- XFree (visinfo);
- return false;
- }
-
- bitmap = XCreateBitmapFromData (dpy, priv->root, &data, 1, 1);
- if (!bitmap)
- {
- compLogMessage (display, "core", CompLogLevelFatal,
- "Couldn't create bitmap");
- XFree (visinfo);
- return false;
- }
-
- priv->invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap,
- &black, &black, 0, 0);
- if (!priv->invisibleCursor)
- {
- compLogMessage (display, "core", CompLogLevelFatal,
- "Couldn't create invisible cursor");
- XFree (visinfo);
- return false;
- }
-
- XFreePixmap (dpy, bitmap);
- XFreeColors (dpy, priv->colormap, &black.pixel, 1, 0);
-
- XFree (visinfo);
-
- priv->reshape (priv->attrib.width, priv->attrib.height);
-
- priv->detectOutputDevices ();
- priv->updateOutputDevices ();
-
- priv->display->addScreenActions (this);
-
- priv->getDesktopHints ();
-
- /* TODO: bailout properly when objectInitPlugins fails */
- assert (CompPlugin::objectInitPlugins (this));
-
- display->addChild (this);
-
-
- XQueryTree (dpy, priv->root,
- &rootReturn, &parentReturn,
- &children, &nchildren);
-
- for (unsigned int i = 0; i < nchildren; i++)
- new CompWindow (this, children[i], i ? children[i - 1] : 0);
-
- foreach (CompWindow *w, priv->windows)
- {
- if (w->isViewable ())
- w->setActiveNum (priv->activeNum++);
- }
-
- XFree (children);
-
- attrib.override_redirect = 1;
- attrib.event_mask = PropertyChangeMask;
-
- priv->grabWindow = XCreateWindow (dpy, priv->root, -100, -100, 1, 1, 0,
- CopyFromParent, InputOnly, CopyFromParent,
- CWOverrideRedirect | CWEventMask,
- &attrib);
- XMapWindow (dpy, priv->grabWindow);
-
- for (i = 0; i < SCREEN_EDGE_NUM; i++)
- {
- long xdndVersion = 3;
-
- priv->screenEdge[i].id = XCreateWindow (dpy, priv->root, -100, -100, 1, 1, 0,
- CopyFromParent, InputOnly,
- CopyFromParent, CWOverrideRedirect,
- &attrib);
-
- XChangeProperty (dpy, priv->screenEdge[i].id, display->atoms ().xdndAware,
- XA_ATOM, 32, PropModeReplace,
- (unsigned char *) &xdndVersion, 1);
-
- XSelectInput (dpy, priv->screenEdge[i].id,
- EnterWindowMask |
- LeaveWindowMask |
- ButtonPressMask |
- ButtonReleaseMask |
- PointerMotionMask);
- }
-
- priv->updateScreenEdges ();
-
- priv->setDesktopHints ();
- priv->setSupportingWmCheck ();
- priv->setSupported ();
-
- priv->normalCursor = XCreateFontCursor (dpy, XC_left_ptr);
- priv->busyCursor = XCreateFontCursor (dpy, XC_watch);
-
- XDefineCursor (dpy, priv->root, priv->normalCursor);
-
- return true;
-}
-
-CompScreen::~CompScreen ()
-{
- while (!priv->windows.empty ())
- delete priv->windows.front ();
-
- removeFromParent ();
-
- CompPlugin::objectFiniPlugins (this);
-
- XUngrabKey (priv->display->dpy (), AnyKey, AnyModifier, priv->root);
-
- for (int i = 0; i < SCREEN_EDGE_NUM; i++)
- XDestroyWindow (priv->display->dpy (), priv->screenEdge[i].id);
-
- XDestroyWindow (priv->display->dpy (), priv->grabWindow);
-
- if (priv->defaultIcon)
- delete priv->defaultIcon;
-
- XFreeCursor (priv->display->dpy (), priv->invisibleCursor);
-
- if (priv->clientList)
- free (priv->clientList);
-
- if (priv->desktopHintData)
- free (priv->desktopHintData);
-
- if (priv->snContext)
- sn_monitor_context_unref (priv->snContext);
-
- delete priv;
-}
-
CompString
CompScreen::objectName ()
{
@@ -1330,13 +2655,12 @@ CompScreen::forEachWindow (CompWindow::ForEach proc)
void
CompScreen::focusDefaultWindow ()
{
- CompDisplay *d = priv->display;
CompWindow *w;
CompWindow *focus = NULL;
- if (!d->getOption ("click_to_focus")->value ().b ())
+ if (!priv->opt[COMP_OPTION_CLICK_TO_FOCUS].value ().b ())
{
- w = d->findTopLevelWindow (d->below ());
+ w = findTopLevelWindow (priv->below);
if (w && !(w->type () & (CompWindowTypeDesktopMask |
CompWindowTypeDockMask)))
{
@@ -1375,12 +2699,12 @@ CompScreen::focusDefaultWindow ()
if (focus)
{
- if (focus->id () != d->activeWindow ())
+ if (focus->id () != priv->activeWindow)
focus->moveInputFocusTo ();
}
else
{
- XSetInputFocus (d->dpy (), priv->root, RevertToPointerRoot,
+ XSetInputFocus (priv->dpy, priv->root, RevertToPointerRoot,
CurrentTime);
}
}
@@ -1513,14 +2837,14 @@ CompScreen::unhookWindow (CompWindow *w)
#define POINTER_GRAB_MASK (ButtonReleaseMask | \
ButtonPressMask | \
PointerMotionMask)
-CompScreen::grabHandle
+CompScreen::GrabHandle
CompScreen::pushGrab (Cursor cursor, const char *name)
{
if (priv->grabs.empty())
{
int status;
- status = XGrabPointer (priv->display->dpy (), priv->grabWindow, TRUE,
+ status = XGrabPointer (priv->dpy, priv->grabWindow, TRUE,
POINTER_GRAB_MASK,
GrabModeAsync, GrabModeAsync,
priv->root, cursor,
@@ -1528,13 +2852,13 @@ CompScreen::pushGrab (Cursor cursor, const char *name)
if (status == GrabSuccess)
{
- status = XGrabKeyboard (priv->display->dpy (),
+ status = XGrabKeyboard (priv->dpy,
priv->grabWindow, TRUE,
GrabModeAsync, GrabModeAsync,
CurrentTime);
if (status != GrabSuccess)
{
- XUngrabPointer (priv->display->dpy (), CurrentTime);
+ XUngrabPointer (priv->dpy, CurrentTime);
return NULL;
}
}
@@ -1543,7 +2867,7 @@ CompScreen::pushGrab (Cursor cursor, const char *name)
}
else
{
- XChangeActivePointerGrab (priv->display->dpy (), POINTER_GRAB_MASK,
+ XChangeActivePointerGrab (priv->dpy, POINTER_GRAB_MASK,
cursor, CurrentTime);
}
@@ -1557,19 +2881,19 @@ CompScreen::pushGrab (Cursor cursor, const char *name)
}
void
-CompScreen::updateGrab (CompScreen::grabHandle handle, Cursor cursor)
+CompScreen::updateGrab (CompScreen::GrabHandle handle, Cursor cursor)
{
if (!handle)
return;
- XChangeActivePointerGrab (priv->display->dpy (), POINTER_GRAB_MASK,
+ XChangeActivePointerGrab (priv->dpy, POINTER_GRAB_MASK,
cursor, CurrentTime);
((PrivateScreen::Grab *) handle)->cursor = cursor;
}
void
-CompScreen::removeGrab (CompScreen::grabHandle handle,
+CompScreen::removeGrab (CompScreen::GrabHandle handle,
CompPoint *restorePointer)
{
if (!handle)
@@ -1586,7 +2910,7 @@ CompScreen::removeGrab (CompScreen::grabHandle handle,
}
if (!priv->grabs.empty ())
{
- XChangeActivePointerGrab (priv->display->dpy (),
+ XChangeActivePointerGrab (priv->dpy,
POINTER_GRAB_MASK,
priv->grabs.back ()->cursor,
CurrentTime);
@@ -1597,8 +2921,8 @@ CompScreen::removeGrab (CompScreen::grabHandle handle,
warpPointer (restorePointer->x () - pointerX,
restorePointer->y () - pointerY);
- XUngrabPointer (priv->display->dpy (), CurrentTime);
- XUngrabKeyboard (priv->display->dpy (), CurrentTime);
+ XUngrabPointer (priv->dpy, CurrentTime);
+ XUngrabKeyboard (priv->dpy, CurrentTime);
}
}
@@ -1643,7 +2967,7 @@ PrivateScreen::grabUngrabOneKey (unsigned int modifiers,
{
if (grab)
{
- XGrabKey (display->dpy (),
+ XGrabKey (dpy,
keycode,
modifiers,
root,
@@ -1653,7 +2977,7 @@ PrivateScreen::grabUngrabOneKey (unsigned int modifiers,
}
else
{
- XUngrabKey (display->dpy (),
+ XUngrabKey (dpy,
keycode,
modifiers,
root);
@@ -1665,15 +2989,14 @@ PrivateScreen::grabUngrabKeys (unsigned int modifiers,
int keycode,
bool grab)
{
- XModifierKeymap *modMap = display->modMap ();
int mod, k;
unsigned int ignore;
- CompDisplay::checkForError (display->dpy ());
+ CompScreen::checkForError (dpy);
- for (ignore = 0; ignore <= display->ignoredModMask (); ignore++)
+ for (ignore = 0; ignore <= ignoredModMask; ignore++)
{
- if (ignore & ~display->ignoredModMask ())
+ if (ignore & ~ignoredModMask)
continue;
if (keycode != 0)
@@ -1702,7 +3025,7 @@ PrivateScreen::grabUngrabKeys (unsigned int modifiers,
}
}
- if (CompDisplay::checkForError (display->dpy ()))
+ if (CompScreen::checkForError (dpy))
return false;
}
@@ -1716,7 +3039,7 @@ PrivateScreen::addPassiveKeyGrab (CompAction::KeyBinding &key)
unsigned int mask;
std::list<KeyGrab>::iterator it;
- mask = display->virtualToRealModMask (key.modifiers ());
+ mask = screen->virtualToRealModMask (key.modifiers ());
for (it = keyGrabs.begin (); it != keyGrabs.end (); it++)
{
@@ -1751,7 +3074,7 @@ PrivateScreen::removePassiveKeyGrab (CompAction::KeyBinding &key)
unsigned int mask;
std::list<KeyGrab>::iterator it;
- mask = display->virtualToRealModMask (key.modifiers ());
+ mask = screen->virtualToRealModMask (key.modifiers ());
for (it = keyGrabs.begin (); it != keyGrabs.end (); it++)
{
@@ -1775,7 +3098,7 @@ PrivateScreen::updatePassiveKeyGrabs ()
{
std::list<KeyGrab>::iterator it;
- XUngrabKey (display->dpy (), AnyKey, AnyModifier, root);
+ XUngrabKey (dpy, AnyKey, AnyModifier, root);
for (it = keyGrabs.begin (); it != keyGrabs.end (); it++)
{
@@ -1883,12 +3206,6 @@ CompScreen::removeAction (CompAction *action)
}
void
-CompScreen::updatePassiveGrabs ()
-{
- priv->updatePassiveKeyGrabs ();
-}
-
-void
PrivateScreen::computeWorkareaForBox (BoxPtr pBox,
XRectangle *area)
{
@@ -2092,12 +3409,12 @@ CompScreen::updateClientList ()
priv->clientList = NULL;
priv->nClientList = 0;
- XChangeProperty (priv->display->dpy (), priv->root,
- priv->display->atoms ().clientList,
+ XChangeProperty (priv->dpy, priv->root,
+ Atoms::clientList,
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) &priv->grabWindow, 1);
- XChangeProperty (priv->display->dpy (), priv->root,
- priv->display->atoms ().clientListStacking,
+ XChangeProperty (priv->dpy, priv->root,
+ Atoms::clientListStacking,
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) &priv->grabWindow, 1);
}
@@ -2158,14 +3475,14 @@ CompScreen::updateClientList ()
}
if (updateClientList)
- XChangeProperty (priv->display->dpy (), priv->root,
- priv->display->atoms ().clientList,
+ XChangeProperty (priv->dpy, priv->root,
+ Atoms::clientList,
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) clientList, priv->nClientList);
if (updateClientListStacking)
- XChangeProperty (priv->display->dpy (), priv->root,
- priv->display->atoms ().clientListStacking,
+ XChangeProperty (priv->dpy, priv->root,
+ Atoms::clientListStacking,
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) clientListStacking,
priv->nClientList);
@@ -2183,7 +3500,7 @@ CompScreen::toolkitAction (Atom toolkitAction,
ev.type = ClientMessage;
ev.xclient.window = window;
- ev.xclient.message_type = priv->display->atoms ().toolkitAction;
+ ev.xclient.message_type = Atoms::toolkitAction;
ev.xclient.format = 32;
ev.xclient.data.l[0] = toolkitAction;
ev.xclient.data.l[1] = eventTime;
@@ -2191,10 +3508,10 @@ CompScreen::toolkitAction (Atom toolkitAction,
ev.xclient.data.l[3] = data1;
ev.xclient.data.l[4] = data2;
- XUngrabPointer (priv->display->dpy (), CurrentTime);
- XUngrabKeyboard (priv->display->dpy (), CurrentTime);
+ XUngrabPointer (priv->dpy, CurrentTime);
+ XUngrabKeyboard (priv->dpy, CurrentTime);
- XSendEvent (priv->display->dpy (), priv->root, FALSE,
+ XSendEvent (priv->dpy, priv->root, FALSE,
StructureNotifyMask, &ev);
}
@@ -2207,7 +3524,7 @@ CompScreen::runCommand (CompString command)
if (fork () == 0)
{
size_t pos;
- CompString env = priv->display->displayString ();
+ CompString env (priv->displayString);
setsid ();
@@ -2283,7 +3600,7 @@ CompScreen::moveViewport (int tx, int ty, bool sync)
setCurrentActiveWindowHistory (priv->vp.x (), priv->vp.y ());
- w = priv->display->findWindow (priv->display->activeWindow ());
+ w = findWindow (priv->activeWindow);
if (w)
{
int x, y;
@@ -2379,10 +3696,10 @@ CompScreen::sendWindowActivationRequest (Window id)
XEvent xev;
xev.xclient.type = ClientMessage;
- xev.xclient.display = priv->display->dpy ();
+ xev.xclient.display = priv->dpy;
xev.xclient.format = 32;
- xev.xclient.message_type = priv->display->atoms ().winActive;
+ xev.xclient.message_type = Atoms::winActive;
xev.xclient.window = id;
xev.xclient.data.l[0] = 2;
@@ -2391,11 +3708,8 @@ CompScreen::sendWindowActivationRequest (Window id)
xev.xclient.data.l[3] = 0;
xev.xclient.data.l[4] = 0;
- XSendEvent (priv->display->dpy (),
- priv->root,
- FALSE,
- SubstructureRedirectMask | SubstructureNotifyMask,
- &xev);
+ XSendEvent (priv->dpy, priv->root, FALSE,
+ SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}
@@ -2404,7 +3718,7 @@ CompScreen::enableEdge (int edge)
{
priv->screenEdge[edge].count++;
if (priv->screenEdge[edge].count == 1)
- XMapRaised (priv->display->dpy (), priv->screenEdge[edge].id);
+ XMapRaised (priv->dpy, priv->screenEdge[edge].id);
}
void
@@ -2412,7 +3726,7 @@ CompScreen::disableEdge (int edge)
{
priv->screenEdge[edge].count--;
if (priv->screenEdge[edge].count == 0)
- XUnmapWindow (priv->display->dpy (), priv->screenEdge[edge].id);
+ XUnmapWindow (priv->dpy, priv->screenEdge[edge].id);
}
Window
@@ -2507,8 +3821,7 @@ CompScreen::setCurrentDesktop (unsigned int desktop)
data = desktop;
- XChangeProperty (priv->display->dpy (), priv->root,
- priv->display->atoms ().currentDesktop,
+ XChangeProperty (priv->dpy, priv->root, Atoms::currentDesktop,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &data, 1);
}
@@ -2612,7 +3925,7 @@ CompScreen::outputDeviceForGeometry (CompWindow::Geometry gm)
if (priv->outputDevs.size () == 1)
return 0;
- strategy = priv->opt[COMP_SCREEN_OPTION_OVERLAPPING_OUTPUTS].value ().i ();
+ strategy = priv->opt[COMP_OPTION_OVERLAPPING_OUTPUTS].value ().i ();
if (strategy == OUTPUT_OVERLAP_MODE_SMART)
{
@@ -2705,7 +4018,7 @@ CompScreen::outputDeviceForGeometry (CompWindow::Geometry gm)
bool
CompScreen::updateDefaultIcon ()
{
- CompString file = priv->opt[COMP_SCREEN_OPTION_DEFAULT_ICON].value ().s ();
+ CompString file = priv->opt[COMP_OPTION_DEFAULT_ICON].value ().s ();
void *data;
int width, height;
@@ -2715,8 +4028,7 @@ CompScreen::updateDefaultIcon ()
priv->defaultIcon = NULL;
}
- if (!priv->display->readImageFromFile (file.c_str (), &width,
- &height, &data))
+ if (!readImageFromFile (file.c_str (), &width, &height, &data))
return false;
priv->defaultIcon = new CompIcon (this, width, height);
@@ -2790,31 +4102,12 @@ ScreenInterface::outputChangeNotify ()
WRAPABLE_DEF (outputChangeNotify)
-CompDisplay *
-CompScreen::display ()
-{
- return priv->display;
-}
-
Window
CompScreen::root ()
{
return priv->root;
}
-CompOption *
-CompScreen::getOption (const char *name)
-{
- CompOption *o = CompOption::findOption (priv->opt, name);
- return o;
-}
-
-bool
-CompScreen::hasGrab ()
-{
- return !priv->grabs.empty ();
-}
-
unsigned int
CompScreen::showingDesktopMask ()
{
@@ -2828,7 +4121,6 @@ CompScreen::showingDesktopMask ()
void
CompScreen::warpPointer (int dx, int dy)
{
- CompDisplay *display = priv->display;
XEvent event;
pointerX += dx;
@@ -2844,14 +4136,14 @@ CompScreen::warpPointer (int dx, int dy)
else if (pointerY < 0)
pointerY = 0;
- XWarpPointer (display->dpy (),
+ XWarpPointer (priv->dpy,
None, priv->root,
0, 0, 0, 0,
pointerX, pointerY);
- XSync (display->dpy (), FALSE);
+ XSync (priv->dpy, FALSE);
- while (XCheckMaskEvent (display->dpy (),
+ while (XCheckMaskEvent (priv->dpy,
LeaveWindowMask |
EnterWindowMask |
PointerMotionMask,
@@ -2875,10 +4167,10 @@ CompScreen::getCurrentTime ()
{
XEvent event;
- XChangeProperty (priv->display->dpy (), priv->grabWindow,
+ XChangeProperty (priv->dpy, priv->grabWindow,
XA_PRIMARY, XA_STRING, 8,
PropModeAppend, NULL, 0);
- XWindowEvent (priv->display->dpy (), priv->grabWindow,
+ XWindowEvent (priv->dpy, priv->grabWindow,
PropertyChangeMask,
&event);
@@ -2989,11 +4281,11 @@ CompScreen::pendingDestroys ()
}
void
-CompScreen::removeDestroyed ()
+PrivateScreen::removeDestroyed ()
{
- while (priv->pendingDestroys)
+ while (pendingDestroys)
{
- foreach (CompWindow *w, priv->windows)
+ foreach (CompWindow *w, windows)
{
if (w->destroyed ())
{
@@ -3002,7 +4294,7 @@ CompScreen::removeDestroyed ()
}
}
- priv->pendingDestroys--;
+ pendingDestroys--;
}
}
@@ -3030,3 +4322,543 @@ CompScreen::attrib ()
{
return priv->attrib;
}
+
+std::vector<XineramaScreenInfo> &
+CompScreen::screenInfo ()
+{
+ return priv->screenInfo;
+}
+
+CompScreen::CompScreen ():
+ CompObject (COMP_OBJECT_TYPE_SCREEN, "screen", &screenPrivateIndices)
+{
+ priv = new PrivateScreen (this);
+ assert (priv);
+}
+
+bool
+CompScreen::init (const char *name)
+{
+ Window focus;
+ int revertTo, i;
+ int xkbOpcode;
+ Display *dpy;
+ Window newWmSnOwner = None;
+ Atom wmSnAtom = 0;
+ Time wmSnTimestamp = 0;
+ XEvent event;
+ XSetWindowAttributes attr;
+ Window currentWmSnOwner;
+ char buf[128];
+ static char data = 0;
+ XColor black;
+ Pixmap bitmap;
+ XVisualInfo templ;
+ XVisualInfo *visinfo;
+ Window rootReturn, parentReturn;
+ Window *children;
+ unsigned int nchildren;
+ int defaultDepth, nvisinfo;
+ XSetWindowAttributes attrib;
+
+ CompOption::Value::Vector vList;
+
+ CompPlugin *corePlugin = CompPlugin::load ("core");
+ if (!corePlugin)
+ {
+ compLogMessage ("core", CompLogLevelFatal,
+ "Couldn't load core plugin");
+ return false;
+ }
+
+ if (!CompPlugin::push (corePlugin))
+ {
+ compLogMessage ("core", CompLogLevelFatal,
+ "Couldn't activate core plugin");
+ return false;
+ }
+
+ CompPrivate p;
+ p.uval = CORE_ABIVERSION;
+ storeValue ("core_ABI", p);
+
+ vList.push_back ("core");
+
+ priv->plugin.set (CompOption::TypeString, vList);
+
+ dpy = priv->dpy = XOpenDisplay (name);
+ if (!priv->dpy)
+ {
+ compLogMessage ("core", CompLogLevelFatal,
+ "Couldn't open display %s", XDisplayName (name));
+ return false;
+ }
+
+// priv->connection = XGetXCBConnection (priv->dpy);
+
+ if (!coreMetadata->initOptions (coreOptionInfo,
+ COMP_OPTION_NUM, priv->opt))
+ return true;
+
+ snprintf (priv->displayString, 255, "DISPLAY=%s",
+ DisplayString (dpy));
+
+#ifdef DEBUG
+ XSynchronize (priv->dpy, TRUE);
+#endif
+
+ Atoms::init (priv->dpy);
+
+ XSetErrorHandler (errorHandler);
+
+ updateModifierMappings ();
+
+ priv->snDisplay = sn_display_new (dpy, NULL, NULL);
+ if (!priv->snDisplay)
+ return true;
+
+ priv->lastPing = 1;
+
+ if (!XSyncQueryExtension (dpy, &priv->syncEvent, &priv->syncError))
+ {
+ compLogMessage ("core", CompLogLevelFatal,
+ "No sync extension");
+ return false;
+ }
+
+ priv->randrExtension = XRRQueryExtension (dpy, &priv->randrEvent,
+ &priv->randrError);
+
+ priv->shapeExtension = XShapeQueryExtension (dpy, &priv->shapeEvent,
+ &priv->shapeError);
+
+ priv->xkbExtension = XkbQueryExtension (dpy, &xkbOpcode,
+ &priv->xkbEvent, &priv->xkbError,
+ NULL, NULL);
+ if (priv->xkbExtension)
+ {
+ XkbSelectEvents (dpy, XkbUseCoreKbd,
+ XkbBellNotifyMask | XkbStateNotifyMask,
+ XkbAllEventsMask);
+ }
+ else
+ {
+ compLogMessage ("core", CompLogLevelFatal,
+ "No XKB extension");
+
+ priv->xkbEvent = priv->xkbError = -1;
+ }
+
+ priv->xineramaExtension = XineramaQueryExtension (dpy,
+ &priv->xineramaEvent,
+ &priv->xineramaError);
+
+
+ priv->updateScreenInfo();
+
+ priv->escapeKeyCode =
+ XKeysymToKeycode (dpy, XStringToKeysym ("Escape"));
+ priv->returnKeyCode =
+ XKeysymToKeycode (dpy, XStringToKeysym ("Return"));
+
+
+
+
+
+
+
+
+
+
+ sprintf (buf, "WM_S%d", DefaultScreen (dpy));
+ wmSnAtom = XInternAtom (dpy, buf, 0);
+
+ currentWmSnOwner = XGetSelectionOwner (dpy, wmSnAtom);
+
+ if (currentWmSnOwner != None)
+ {
+ if (!replaceCurrentWm)
+ {
+ compLogMessage ("core", CompLogLevelError,
+ "Screen %d on display \"%s\" already "
+ "has a window manager; try using the "
+ "--replace option to replace the current "
+ "window manager.",
+ DefaultScreen (dpy), DisplayString (dpy));
+
+ return false;
+ }
+
+ XSelectInput (dpy, currentWmSnOwner, StructureNotifyMask);
+ }
+
+ attr.override_redirect = TRUE;
+ attr.event_mask = PropertyChangeMask;
+
+ newWmSnOwner =
+ XCreateWindow (dpy, XRootWindow (dpy, DefaultScreen (dpy)),
+ -100, -100, 1, 1, 0,
+ CopyFromParent, CopyFromParent,
+ CopyFromParent,
+ CWOverrideRedirect | CWEventMask,
+ &attr);
+
+ XChangeProperty (dpy, newWmSnOwner, Atoms::wmName, Atoms::utf8String, 8,
+ PropModeReplace, (unsigned char *) PACKAGE,
+ strlen (PACKAGE));
+
+ XWindowEvent (dpy, newWmSnOwner, PropertyChangeMask, &event);
+
+ wmSnTimestamp = event.xproperty.time;
+
+ XSetSelectionOwner (dpy, wmSnAtom, newWmSnOwner, wmSnTimestamp);
+
+ if (XGetSelectionOwner (dpy, wmSnAtom) != newWmSnOwner)
+ {
+ compLogMessage ("core", CompLogLevelError,
+ "Could not acquire window manager "
+ "selection on screen %d display \"%s\"",
+ DefaultScreen (dpy), DisplayString (dpy));
+
+ XDestroyWindow (dpy, newWmSnOwner);
+
+ return false;
+ }
+
+ /* Send client message indicating that we are now the WM */
+ event.xclient.type = ClientMessage;
+ event.xclient.window = XRootWindow (dpy, DefaultScreen (dpy));
+ event.xclient.message_type = Atoms::manager;
+ event.xclient.format = 32;
+ event.xclient.data.l[0] = wmSnTimestamp;
+ event.xclient.data.l[1] = wmSnAtom;
+ event.xclient.data.l[2] = 0;
+ event.xclient.data.l[3] = 0;
+ event.xclient.data.l[4] = 0;
+
+ XSendEvent (dpy, XRootWindow (dpy, DefaultScreen (dpy)), FALSE,
+ StructureNotifyMask, &event);
+
+ /* Wait for old window manager to go away */
+ if (currentWmSnOwner != None)
+ {
+ do {
+ XWindowEvent (dpy, currentWmSnOwner, StructureNotifyMask, &event);
+ } while (event.type != DestroyNotify);
+ }
+
+ CompScreen::checkForError (dpy);
+
+ XGrabServer (dpy);
+
+ XSelectInput (dpy, XRootWindow (dpy, DefaultScreen (dpy)),
+ SubstructureRedirectMask |
+ SubstructureNotifyMask |
+ StructureNotifyMask |
+ PropertyChangeMask |
+ LeaveWindowMask |
+ EnterWindowMask |
+ KeyPressMask |
+ KeyReleaseMask |
+ ButtonPressMask |
+ ButtonReleaseMask |
+ FocusChangeMask |
+ ExposureMask);
+
+ if (CompScreen::checkForError (dpy))
+ {
+ compLogMessage ("core", CompLogLevelError,
+ "Another window manager is "
+ "already running on screen: %d", DefaultScreen (dpy));
+
+ XUngrabServer (dpy);
+ return false;
+ }
+
+ priv->vpSize.setWidth (priv->opt[COMP_OPTION_HSIZE].value ().i ());
+ priv->vpSize.setHeight (priv->opt[COMP_OPTION_VSIZE].value ().i ());
+
+ for (i = 0; i < SCREEN_EDGE_NUM; i++)
+ {
+ priv->screenEdge[i].id = None;
+ priv->screenEdge[i].count = 0;
+ }
+
+ priv->screenNum = DefaultScreen (dpy);
+ priv->colormap = DefaultColormap (dpy, priv->screenNum);
+ priv->root = XRootWindow (dpy, priv->screenNum);
+
+ priv->snContext = sn_monitor_context_new (priv->snDisplay, priv->screenNum,
+ compScreenSnEvent, this, NULL);
+
+ priv->wmSnSelectionWindow = newWmSnOwner;
+ priv->wmSnAtom = wmSnAtom;
+ priv->wmSnTimestamp = wmSnTimestamp;
+
+ if (!XGetWindowAttributes (dpy, priv->root, &priv->attrib))
+ return false;
+
+ priv->workArea.x = 0;
+ priv->workArea.y = 0;
+ priv->workArea.width = priv->attrib.width;
+ priv->workArea.height = priv->attrib.height;
+ priv->grabWindow = None;
+
+ templ.visualid = XVisualIDFromVisual (priv->attrib.visual);
+
+ visinfo = XGetVisualInfo (dpy, VisualIDMask, &templ, &nvisinfo);
+ if (!nvisinfo)
+ {
+ compLogMessage ("core", CompLogLevelFatal,
+ "Couldn't get visual info for default visual");
+ return false;
+ }
+
+ defaultDepth = visinfo->depth;
+
+ black.red = black.green = black.blue = 0;
+
+ if (!XAllocColor (dpy, priv->colormap, &black))
+ {
+ compLogMessage ("core", CompLogLevelFatal,
+ "Couldn't allocate color");
+ XFree (visinfo);
+ return false;
+ }
+
+ bitmap = XCreateBitmapFromData (dpy, priv->root, &data, 1, 1);
+ if (!bitmap)
+ {
+ compLogMessage ("core", CompLogLevelFatal,
+ "Couldn't create bitmap");
+ XFree (visinfo);
+ return false;
+ }
+
+ priv->invisibleCursor = XCreatePixmapCursor (dpy, bitmap, bitmap,
+ &black, &black, 0, 0);
+ if (!priv->invisibleCursor)
+ {
+ compLogMessage ("core", CompLogLevelFatal,
+ "Couldn't create invisible cursor");
+ XFree (visinfo);
+ return false;
+ }
+
+ XFreePixmap (dpy, bitmap);
+ XFreeColors (dpy, priv->colormap, &black.pixel, 1, 0);
+
+ XFree (visinfo);
+
+ priv->reshape (priv->attrib.width, priv->attrib.height);
+
+ priv->detectOutputDevices ();
+ priv->updateOutputDevices ();
+
+ priv->getDesktopHints ();
+
+ /* TODO: bailout properly when objectInitPlugins fails */
+ assert (CompPlugin::objectInitPlugins (this));
+
+ XQueryTree (dpy, priv->root,
+ &rootReturn, &parentReturn,
+ &children, &nchildren);
+
+ for (unsigned int i = 0; i < nchildren; i++)
+ new CompWindow (this, children[i], i ? children[i - 1] : 0);
+
+ foreach (CompWindow *w, priv->windows)
+ {
+ if (w->isViewable ())
+ w->setActiveNum (priv->activeNum++);
+ }
+
+ XFree (children);
+
+ attrib.override_redirect = 1;
+ attrib.event_mask = PropertyChangeMask;
+
+ priv->grabWindow = XCreateWindow (dpy, priv->root, -100, -100, 1, 1, 0,
+ CopyFromParent, InputOnly, CopyFromParent,
+ CWOverrideRedirect | CWEventMask,
+ &attrib);
+ XMapWindow (dpy, priv->grabWindow);
+
+ for (i = 0; i < SCREEN_EDGE_NUM; i++)
+ {
+ long xdndVersion = 3;
+
+ priv->screenEdge[i].id = XCreateWindow (dpy, priv->root, -100, -100, 1, 1, 0,
+ CopyFromParent, InputOnly,
+ CopyFromParent, CWOverrideRedirect,
+ &attrib);
+
+ XChangeProperty (dpy, priv->screenEdge[i].id, Atoms::xdndAware,
+ XA_ATOM, 32, PropModeReplace,
+ (unsigned char *) &xdndVersion, 1);
+
+ XSelectInput (dpy, priv->screenEdge[i].id,
+ EnterWindowMask |
+ LeaveWindowMask |
+ ButtonPressMask |
+ ButtonReleaseMask |
+ PointerMotionMask);
+ }
+
+ priv->updateScreenEdges ();
+
+ priv->setDesktopHints ();
+ priv->setSupportingWmCheck ();
+ priv->setSupported ();
+
+ priv->normalCursor = XCreateFontCursor (dpy, XC_left_ptr);
+ priv->busyCursor = XCreateFontCursor (dpy, XC_watch);
+
+ XDefineCursor (dpy, priv->root, priv->normalCursor);
+
+ XUngrabServer (dpy);
+
+ priv->setAudibleBell (
+ priv->opt[COMP_OPTION_AUDIBLE_BELL].value ().b ());
+
+ XGetInputFocus (dpy, &focus, &revertTo);
+
+ /* move input focus to root window so that we get a FocusIn event when
+ moving it to the default window */
+ XSetInputFocus (dpy, priv->root,
+ RevertToPointerRoot, CurrentTime);
+
+ if (focus == None || focus == PointerRoot)
+ {
+ focusDefaultWindow ();
+ }
+ else
+ {
+ CompWindow *w;
+
+ w = findWindow (focus);
+ if (w)
+ {
+ w->moveInputFocusTo ();
+ }
+ else
+ focusDefaultWindow ();
+ }
+
+ priv->pingTimer.start (
+ boost::bind(&PrivateScreen::handlePingTimeout, priv),
+ priv->opt[COMP_OPTION_PING_DELAY].value ().i (),
+ priv->opt[COMP_OPTION_PING_DELAY].value ().i () + 500);
+
+ return true;
+}
+
+CompScreen::~CompScreen ()
+{
+ CompPlugin *p;
+
+ while (!priv->windows.empty ())
+ delete priv->windows.front ();
+
+ CompPlugin::objectFiniPlugins (this);
+
+ XUngrabKey (priv->dpy, AnyKey, AnyModifier, priv->root);
+
+ for (int i = 0; i < SCREEN_EDGE_NUM; i++)
+ XDestroyWindow (priv->dpy, priv->screenEdge[i].id);
+
+ XDestroyWindow (priv->dpy, priv->grabWindow);
+
+ if (priv->defaultIcon)
+ delete priv->defaultIcon;
+
+ XFreeCursor (priv->dpy, priv->invisibleCursor);
+
+ if (priv->clientList)
+ free (priv->clientList);
+
+ if (priv->desktopHintData)
+ free (priv->desktopHintData);
+
+ if (priv->snContext)
+ sn_monitor_context_unref (priv->snContext);
+
+ if (priv->snDisplay)
+ sn_display_unref (priv->snDisplay);
+
+ XSync (priv->dpy, False);
+ XCloseDisplay (priv->dpy);
+
+ if (priv->modMap)
+ XFreeModifiermap (priv->modMap);
+
+ if (priv->watchPollFds)
+ free (priv->watchPollFds);
+
+ while ((p = CompPlugin::pop ()))
+ CompPlugin::unload (p);
+
+ delete priv;
+}
+
+PrivateScreen::PrivateScreen (CompScreen *screen) :
+ fileWatch (0),
+ lastFileWatchHandle (1),
+ timers (0),
+ watchFds (0),
+ lastWatchFdHandle (1),
+ watchPollFds (0),
+ nWatchFds (0),
+ valueMap (),
+ screenInfo (0),
+ activeWindow (0),
+ below (None),
+ modMap (0),
+ ignoredModMask (LockMask),
+ autoRaiseTimer (),
+ autoRaiseWindow (0),
+ edgeDelayTimer (),
+ plugin (),
+ dirtyPluginList (true),
+ screen(screen),
+ windows (),
+ size (0, 0),
+ vp (0, 0),
+ vpSize (1, 1),
+ nDesktop (1),
+ currentDesktop (0),
+ root (None),
+ grabWindow (None),
+ desktopWindowCount (0),
+ mapNum (1),
+ activeNum (1),
+ outputDevs (0),
+ currentOutputDev (0),
+ hasOverlappingOutputs (false),
+ currentHistory (0),
+ snContext (0),
+ startupSequences (0),
+ startupSequenceTimer (),
+ groups (0),
+ defaultIcon (0),
+ clientList (0),
+ nClientList (0),
+ buttonGrabs (0),
+ keyGrabs (0),
+ grabs (0),
+ pendingDestroys (0),
+ showingDesktopMask (0),
+ desktopHintData (0),
+ desktopHintSize (0),
+ opt (COMP_OPTION_NUM)
+{
+ for (int i = 0; i < CompModNum; i++)
+ modMask[i] = CompNoMask;
+ memset (history, 0, sizeof (history));
+ gettimeofday (&lastTimeout, 0);
+}
+
+PrivateScreen::~PrivateScreen ()
+{
+ opt.clear ();
+}
diff --git a/src/session.cpp b/src/session.cpp
index 6c0a223..1b2b30d 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -179,7 +179,7 @@ saveYourselfCallback (SmcConn connection,
args[2].value ().set (interact_Style);
args[3].value ().set ((bool) fast);
- core->sessionEvent (CompSession::EventSaveYourself, args);
+ screen->sessionEvent (CompSession::EventSaveYourself, args);
setCloneRestartCommands (connection);
setRestartStyle (connection, SmRestartImmediately);
@@ -191,7 +191,7 @@ static void
dieCallback (SmcConn connection,
SmPointer clientData)
{
- core->sessionEvent (CompSession::EventDie, noOptions);
+ screen->sessionEvent (CompSession::EventDie, noOptions);
CompSession::closeSession ();
exit (0);
@@ -201,14 +201,14 @@ static void
saveCompleteCallback (SmcConn connection,
SmPointer clientData)
{
- core->sessionEvent (CompSession::EventSaveComplete, noOptions);
+ screen->sessionEvent (CompSession::EventSaveComplete, noOptions);
}
static void
shutdownCancelledCallback (SmcConn connection,
SmPointer clientData)
{
- core->sessionEvent (CompSession::EventShutdownCancelled, noOptions);
+ screen->sessionEvent (CompSession::EventShutdownCancelled, noOptions);
}
void
@@ -248,7 +248,7 @@ CompSession::initSession (char *prevClientId)
sizeof (errorBuffer),
errorBuffer);
if (!smcConnection)
- compLogMessage (NULL, "core", CompLogLevelWarn,
+ compLogMessage ("core", CompLogLevelWarn,
"SmcOpenConnection failed: %s",
errorBuffer);
else
@@ -345,7 +345,7 @@ iceNewConnection (IceConn connection,
fcntl (IceConnectionNumber (connection),
F_GETFD,0) | FD_CLOEXEC);
- iceWatchFdHandle = core->addWatchFd (IceConnectionNumber (connection),
+ iceWatchFdHandle = screen->addWatchFd (IceConnectionNumber (connection),
POLLIN | POLLPRI | POLLHUP | POLLERR,
boost::bind (iceProcessMessages, connection));
@@ -357,7 +357,7 @@ iceNewConnection (IceConn connection,
if (iceConnected)
{
- core->removeWatchFd (iceWatchFdHandle);
+ screen->removeWatchFd (iceWatchFdHandle);
iceWatchFdHandle = 0;
iceConnected = 0;
diff --git a/src/timer.cpp b/src/timer.cpp
new file mode 100644
index 0000000..2045220
--- /dev/null
+++ b/src/timer.cpp
@@ -0,0 +1,107 @@
+#include <core/timer.h>
+#include <compscreen.h>
+#include "privatescreen.h"
+
+CompTimer::CompTimer () :
+ mActive (false),
+ mMinTime (0),
+ mMaxTime (0),
+ mMinLeft (0),
+ mMaxLeft (0),
+ mCallBack (NULL)
+{
+}
+
+CompTimer::~CompTimer ()
+{
+ if (mActive)
+ screen->priv->removeTimer (this);
+}
+
+void
+CompTimer::setTimes (unsigned int min, unsigned int max)
+{
+ bool wasActive = mActive;
+ if (mActive)
+ stop ();
+ mMinTime = min;
+ mMaxTime = (min <= max)? max : min;
+
+ if (wasActive)
+ start ();
+}
+
+void
+CompTimer::setCallback (CompTimer::CallBack callback)
+{
+ bool wasActive = mActive;
+ if (mActive)
+ stop ();
+ mCallBack = callback;
+
+ if (wasActive)
+ start ();
+}
+
+void
+CompTimer::start ()
+{
+ stop ();
+ mActive = true;
+ screen->priv->addTimer (this);
+}
+
+void
+CompTimer::start (unsigned int min, unsigned int max)
+{
+ stop ();
+ setTimes (min, max);
+ start ();
+}
+
+void
+CompTimer::start (CompTimer::CallBack callback,
+ unsigned int min, unsigned int max)
+{
+ stop ();
+ setTimes (min, max);
+ setCallback (callback);
+ start ();
+}
+
+void
+CompTimer::stop ()
+{
+ mActive = false;
+ screen->priv->removeTimer (this);
+}
+
+unsigned int
+CompTimer::minTime ()
+{
+ return mMinTime;
+}
+
+unsigned int
+CompTimer::maxTime ()
+{
+ return mMaxTime;
+}
+
+unsigned int
+CompTimer::minLeft ()
+{
+ return (mMinLeft < 0)? 0 : mMinLeft;
+}
+
+unsigned int
+CompTimer::maxLeft ()
+{
+ return (mMaxLeft < 0)? 0 : mMaxLeft;
+}
+
+bool
+CompTimer::active ()
+{
+ return mActive;
+}
diff --git a/src/window.cpp b/src/window.cpp
index 27f79fd..ad3f8fd 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -42,6 +42,7 @@
#include <compiz-core.h>
#include <compicon.h>
+#include <core/atoms.h>
#include "privatewindow.h"
#include "privatescreen.h"
@@ -206,7 +207,7 @@ CompWindow::updateNormalHints ()
Status status;
long supplied;
- status = XGetWMNormalHints (priv->screen->display ()->dpy (), priv->id,
+ status = XGetWMNormalHints (priv->screen->dpy (), priv->id,
&priv->sizeHints, &supplied);
if (!status)
@@ -220,7 +221,7 @@ CompWindow::updateWmHints ()
{
XWMHints *hints;
- hints = XGetWMHints (priv->screen->display ()->dpy (), priv->id);
+ hints = XGetWMHints (priv->screen->dpy (), priv->id);
if (hints)
{
if (hints->flags & InputHint)
@@ -248,7 +249,7 @@ CompWindow::updateClassHints ()
priv->resClass = NULL;
}
- status = XGetClassHint (priv->screen->display ()->dpy (),
+ status = XGetClassHint (priv->screen->dpy (),
priv->id, &classHint);
if (status)
{
@@ -274,7 +275,7 @@ CompWindow::updateTransientHint ()
priv->transientFor = None;
- status = XGetTransientForHint (priv->screen->display ()->dpy (),
+ status = XGetTransientForHint (priv->screen->dpy (),
priv->id, &transientFor);
if (status)
@@ -302,8 +303,8 @@ CompWindow::updateIconGeometry ()
unsigned long n, left;
unsigned char *data;
- result = XGetWindowProperty (priv->screen->display ()->dpy (), priv->id,
- priv->screen->display ()->atoms ().wmIconGeometry,
+ result = XGetWindowProperty (priv->screen->dpy (), priv->id,
+ Atoms::wmIconGeometry,
0L, 1024L, False, XA_CARDINAL,
&actual, &format, &n, &left, &data);
@@ -353,8 +354,8 @@ CompWindow::getClientLeader ()
unsigned long n, left;
unsigned char *data;
- result = XGetWindowProperty (priv->screen->display ()->dpy (), priv->id,
- priv->screen->display ()->atoms ().wmClientLeader,
+ result = XGetWindowProperty (priv->screen->dpy (), priv->id,
+ Atoms::wmClientLeader,
0L, 1L, False, XA_WINDOW, &actual, &format,
&n, &left, &data);
@@ -380,10 +381,10 @@ CompWindow::getStartupId ()
unsigned long n, left;
unsigned char *data;
- result = XGetWindowProperty (priv->screen->display ()->dpy (), priv->id,
- priv->screen->display ()->atoms ().startupId,
+ result = XGetWindowProperty (priv->screen->dpy (), priv->id,
+ Atoms::startupId,
0L, 1024L, False,
- priv->screen->display ()->atoms ().utf8String,
+ Atoms::utf8String,
&actual, &format,
&n, &left, &data);
@@ -403,7 +404,6 @@ CompWindow::getStartupId ()
void
CompWindow::changeState (unsigned int newState)
{
- CompDisplay *d = priv->screen->display ();
unsigned int oldState;
if (priv->state == newState)
@@ -415,14 +415,14 @@ CompWindow::changeState (unsigned int newState)
recalcType ();
recalcActions ();
- d->setWindowState (priv->state, priv->id);
+ priv->screen->setWindowState (priv->state, priv->id);
stateChangeNotify (oldState);
- d->matchPropertyChanged (this);
+ priv->screen->matchPropertyChanged (this);
}
static void
-setWindowActions (CompDisplay *display,
+setWindowActions (CompScreen *s,
unsigned int actions,
Window id)
{
@@ -430,31 +430,31 @@ setWindowActions (CompDisplay *display,
int i = 0;
if (actions & CompWindowActionMoveMask)
- data[i++] = display->atoms ().winActionMove;
+ data[i++] = Atoms::winActionMove;
if (actions & CompWindowActionResizeMask)
- data[i++] = display->atoms ().winActionResize;
+ data[i++] = Atoms::winActionResize;
if (actions & CompWindowActionStickMask)
- data[i++] = display->atoms ().winActionStick;
+ data[i++] = Atoms::winActionStick;
if (actions & CompWindowActionMinimizeMask)
- data[i++] = display->atoms ().winActionMinimize;
+ data[i++] = Atoms::winActionMinimize;
if (actions & CompWindowActionMaximizeHorzMask)
- data[i++] = display->atoms ().winActionMaximizeHorz;
+ data[i++] = Atoms::winActionMaximizeHorz;
if (actions & CompWindowActionMaximizeVertMask)
- data[i++] = display->atoms ().winActionMaximizeVert;
+ data[i++] = Atoms::winActionMaximizeVert;
if (actions & CompWindowActionFullscreenMask)
- data[i++] = display->atoms ().winActionFullscreen;
+ data[i++] = Atoms::winActionFullscreen;
if (actions & CompWindowActionCloseMask)
- data[i++] = display->atoms ().winActionClose;
+ data[i++] = Atoms::winActionClose;
if (actions & CompWindowActionShadeMask)
- data[i++] = display->atoms ().winActionShade;
+ data[i++] = Atoms::winActionShade;
if (actions & CompWindowActionChangeDesktopMask)
- data[i++] = display->atoms ().winActionChangeDesktop;
+ data[i++] = Atoms::winActionChangeDesktop;
if (actions & CompWindowActionAboveMask)
- data[i++] = display->atoms ().winActionAbove;
+ data[i++] = Atoms::winActionAbove;
if (actions & CompWindowActionBelowMask)
- data[i++] = display->atoms ().winActionBelow;
+ data[i++] = Atoms::winActionBelow;
- XChangeProperty (display->dpy (), id, display->atoms ().wmAllowedActions,
+ XChangeProperty (s->dpy (), id, Atoms::wmAllowedActions,
XA_ATOM, 32, PropModeReplace,
(unsigned char *) data, i);
}
@@ -563,7 +563,7 @@ CompWindow::recalcActions ()
if (actions != priv->actions)
{
priv->actions = actions;
- setWindowActions (priv->screen->display (), actions, priv->id);
+ setWindowActions (priv->screen, actions, priv->id);
}
}
@@ -671,8 +671,6 @@ CompWindow::recalcType ()
void
PrivateWindow::updateFrameWindow ()
{
- CompDisplay *d = screen->display ();
-
if (input.left || input.right || input.top || input.bottom)
{
int x, y, width, height;
@@ -689,10 +687,10 @@ PrivateWindow::updateFrameWindow ()
if (!frame)
reparent ();
- XMoveResizeWindow (d->dpy (), frame, x, y, width, height);
- XMoveResizeWindow (d->dpy (), wrapper, input.left, input.top,
+ XMoveResizeWindow (screen->dpy (), frame, x, y, width, height);
+ XMoveResizeWindow (screen->dpy (), wrapper, input.left, input.top,
serverGeometry.width (), serverGeometry.height ());
- XMoveResizeWindow (d->dpy (), id, 0, 0,
+ XMoveResizeWindow (screen->dpy (), id, 0, 0,
serverGeometry.width (), serverGeometry.height ());
window->sendConfigureNotify ();
@@ -751,11 +749,11 @@ CompWindow::updateRegion ()
EMPTY_REGION (priv->region);
- if (priv->screen->display ()->XShape ())
+ if (priv->screen->XShape ())
{
int order;
- shapeRects = XShapeGetRectangles (priv->screen->display ()->dpy (), priv->id,
+ shapeRects = XShapeGetRectangles (priv->screen->dpy (), priv->id,
ShapeBounding, &n, &order);
}
@@ -859,8 +857,8 @@ CompWindow::updateStruts ()
c_new.bottom.width = priv->screen->size().width ();
c_new.bottom.height = 0;
- result = XGetWindowProperty (priv->screen->display ()->dpy (), priv->id,
- priv->screen->display ()->atoms ().wmStrutPartial,
+ result = XGetWindowProperty (priv->screen->dpy (), priv->id,
+ Atoms::wmStrutPartial,
0L, 12L, FALSE, XA_CARDINAL, &actual, &format,
&n, &left, &data);
@@ -906,8 +904,8 @@ CompWindow::updateStruts ()
if (!hasNew)
{
- result = XGetWindowProperty (priv->screen->display ()->dpy (), priv->id,
- priv->screen->display ()->atoms ().wmStrut,
+ result = XGetWindowProperty (priv->screen->dpy (), priv->id,
+ Atoms::wmStrut,
0L, 4L, FALSE, XA_CARDINAL,
&actual, &format, &n, &left, &data);
@@ -953,12 +951,12 @@ CompWindow::updateStruts ()
/* applications expect us to clip struts to xinerama edges */
for (unsigned int i = 0;
- i < priv->screen->display ()->screenInfo ().size (); i++)
+ i < priv->screen->screenInfo ().size (); i++)
{
- x1 = priv->screen->display ()->screenInfo ()[i].x_org;
- y1 = priv->screen->display ()->screenInfo ()[i].y_org;
- x2 = x1 + priv->screen->display ()->screenInfo ()[i].width;
- y2 = y1 + priv->screen->display ()->screenInfo ()[i].height;
+ x1 = priv->screen->screenInfo ()[i].x_org;
+ y1 = priv->screen->screenInfo ()[i].y_org;
+ x2 = x1 + priv->screen->screenInfo ()[i].width;
+ y2 = y1 + priv->screen->screenInfo ()[i].height;
strutX1 = c_new.left.x;
strutX2 = strutX1 + c_new.left.width;
@@ -1094,9 +1092,9 @@ CompWindow::sendConfigureNotify ()
{
XWindowAttributes attrib;
- XGrabServer (priv->screen->display ()->dpy ());
+ XGrabServer (priv->screen->dpy ());
- if (XGetWindowAttributes (priv->screen->display ()->dpy (), priv->id, &attrib))
+ if (XGetWindowAttributes (priv->screen->dpy (), priv->id, &attrib))
{
xev.x = attrib.x;
xev.y = attrib.y;
@@ -1107,11 +1105,11 @@ CompWindow::sendConfigureNotify ()
xev.above = (prev) ? prev->priv->id : None;
xev.override_redirect = TRUE;
- XSendEvent (priv->screen->display ()->dpy (), priv->id, FALSE,
+ XSendEvent (priv->screen->dpy (), priv->id, FALSE,
StructureNotifyMask, (XEvent *) &xev);
}
- XUngrabServer (priv->screen->display ()->dpy ());
+ XUngrabServer (priv->screen->dpy ());
}
else
{
@@ -1124,7 +1122,7 @@ CompWindow::sendConfigureNotify ()
xev.above = (prev) ? prev->priv->id : None;
xev.override_redirect = priv->attrib.override_redirect;
- XSendEvent (priv->screen->display ()->dpy (), priv->id, FALSE,
+ XSendEvent (priv->screen->dpy (), priv->id, FALSE,
StructureNotifyMask, (XEvent *) &xev);
}
}
@@ -1150,20 +1148,20 @@ CompWindow::map ()
priv->attrib.map_state = IsViewable;
if (!overrideRedirect ())
- priv->screen->display ()->setWmState (NormalState, priv->id);
+ priv->screen->setWmState (NormalState, priv->id);
priv->invisible = true;
priv->alive = true;
- priv->lastPong = priv->screen->display ()->lastPing ();
+ priv->lastPong = priv->screen->lastPing ();
updateRegion ();
updateSize ();
if (priv->frame)
{
- XMapWindow (priv->screen->display ()->dpy (), priv->frame);
- XMapWindow (priv->screen->display ()->dpy (), priv->wrapper);
+ XMapWindow (priv->screen->dpy (), priv->frame);
+ XMapWindow (priv->screen->dpy (), priv->wrapper);
}
priv->screen->updateClientList ();
@@ -1341,8 +1339,8 @@ PrivateWindow::initializeSyncCounter ()
if (!(protocols & CompWindowProtocolSyncRequestMask))
return false;
- result = XGetWindowProperty (screen->display ()->dpy (), id,
- screen->display ()->atoms ().wmSyncRequestCounter,
+ result = XGetWindowProperty (screen->dpy (), id,
+ Atoms::wmSyncRequestCounter,
0L, 1L, FALSE, XA_CARDINAL, &actual, &format,
&n, &left, &data);
@@ -1355,7 +1353,7 @@ PrivateWindow::initializeSyncCounter ()
XFree (data);
XSyncIntsToValue (&syncValue, (unsigned int) rand (), 0);
- XSyncSetCounter (screen->display ()->dpy (),
+ XSyncSetCounter (screen->dpy (),
syncCounter,
syncValue);
@@ -1373,13 +1371,13 @@ PrivateWindow::initializeSyncCounter ()
values.events = TRUE;
- CompDisplay::checkForError (screen->display ()->dpy ());
+ CompScreen::checkForError (screen->dpy ());
/* Note that by default, the alarm increments the trigger value
* when it fires until the condition (counter.value < trigger.value)
* is FALSE again.
*/
- syncAlarm = XSyncCreateAlarm (screen->display ()->dpy (),
+ syncAlarm = XSyncCreateAlarm (screen->dpy (),
XSyncCACounter |
XSyncCAValue |
XSyncCAValueType |
@@ -1388,10 +1386,10 @@ PrivateWindow::initializeSyncCounter ()
XSyncCAEvents,
&values);
- if (CompDisplay::checkForError (screen->display ()->dpy ()))
+ if (CompScreen::checkForError (screen->dpy ()))
return true;
- XSyncDestroyAlarm (screen->display ()->dpy (), syncAlarm);
+ XSyncDestroyAlarm (screen->dpy (), syncAlarm);
syncAlarm = None;
}
@@ -1411,9 +1409,9 @@ CompWindow::sendSyncRequest ()
xev.type = ClientMessage;
xev.window = priv->id;
- xev.message_type = priv->screen->display ()->atoms ().wmProtocols;
+ xev.message_type = Atoms::wmProtocols;
xev.format = 32;
- xev.data.l[0] = priv->screen->display ()->atoms ().wmSyncRequest;
+ xev.data.l[0] = Atoms::wmSyncRequest;
xev.data.l[1] = CurrentTime;
xev.data.l[2] = XSyncValueLow32 (priv->syncValue);
xev.data.l[3] = XSyncValueHigh32 (priv->syncValue);
@@ -1421,7 +1419,7 @@ CompWindow::sendSyncRequest ()
syncValueIncrement (&priv->syncValue);
- XSendEvent (priv->screen->display ()->dpy (), priv->id, FALSE, 0,
+ XSendEvent (priv->screen->dpy (), priv->id, FALSE, 0,
(XEvent *) &xev);
priv->syncWait = TRUE;
@@ -1528,13 +1526,13 @@ CompWindow::syncPosition ()
priv->serverGeometry.setX (priv->attrib.x);
priv->serverGeometry.setY (priv->attrib.y);
- XMoveWindow (priv->screen->display ()->dpy (), ROOTPARENT (this),
+ XMoveWindow (priv->screen->dpy (), ROOTPARENT (this),
priv->attrib.x - priv->input.left,
priv->attrib.y - priv->input.top);
if (priv->frame)
{
- XMoveWindow (priv->screen->display ()->dpy (), priv->wrapper,
+ XMoveWindow (priv->screen->dpy (), priv->wrapper,
priv->input.left, priv->input.top);
sendConfigureNotify ();
}
@@ -1700,7 +1698,6 @@ void
CompWindow::moveInputFocusTo ()
{
CompScreen *s = priv->screen;
- CompDisplay *d = s->display ();
CompWindow *modalTransient;
modalTransient = priv->getModalTransient ();
@@ -1709,8 +1706,8 @@ CompWindow::moveInputFocusTo ()
if (priv->state & CompWindowStateHiddenMask)
{
- XSetInputFocus (d->dpy (), priv->frame, RevertToPointerRoot, CurrentTime);
- XChangeProperty (d->dpy (), s->root (), d->atoms ().winActive,
+ XSetInputFocus (s->dpy (), priv->frame, RevertToPointerRoot, CurrentTime);
+ XChangeProperty (s->dpy (), s->root (), Atoms::winActive,
XA_WINDOW, 32, PropModeReplace,
(unsigned char *) &priv->id, 1);
}
@@ -1720,7 +1717,7 @@ CompWindow::moveInputFocusTo ()
if (priv->inputHint)
{
- XSetInputFocus (d->dpy (), priv->id, RevertToPointerRoot,
+ XSetInputFocus (s->dpy (), priv->id, RevertToPointerRoot,
CurrentTime);
setFocus = true;
}
@@ -1731,15 +1728,15 @@ CompWindow::moveInputFocusTo ()
ev.type = ClientMessage;
ev.xclient.window = priv->id;
- ev.xclient.message_type = d->atoms ().wmProtocols;
+ ev.xclient.message_type = Atoms::wmProtocols;
ev.xclient.format = 32;
- ev.xclient.data.l[0] = d->atoms ().wmTakeFocus;
+ ev.xclient.data.l[0] = Atoms::wmTakeFocus;
ev.xclient.data.l[1] = s->getCurrentTime ();
ev.xclient.data.l[2] = 0;
ev.xclient.data.l[3] = 0;
ev.xclient.data.l[4] = 0;
- XSendEvent (d->dpy (), priv->id, FALSE, NoEventMask, &ev);
+ XSendEvent (s->dpy (), priv->id, FALSE, NoEventMask, &ev);
setFocus = true;
}
@@ -1765,15 +1762,13 @@ CompWindow::moveInputFocusTo ()
void
CompWindow::moveInputFocusToOtherWindow ()
{
- CompDisplay *display = priv->screen->display ();
-
- if (priv->id == display->activeWindow ())
+ if (priv->id == priv->screen->activeWindow ())
{
CompWindow *ancestor;
if (priv->transientFor && priv->transientFor != priv->screen->root ())
{
- ancestor = display->findWindow (priv->transientFor);
+ ancestor = priv->screen->findWindow (priv->transientFor);
if (ancestor &&
!(ancestor->priv->type & (CompWindowTypeDesktopMask |
CompWindowTypeDockMask)))
@@ -2158,18 +2153,18 @@ PrivateWindow::reconfigureXWindow (unsigned int valueMask,
wc.width += input.left + input.right;
wc.height += input.top + input.bottom;
- XConfigureWindow (screen->display ()->dpy (), frame,
+ XConfigureWindow (screen->dpy (), frame,
valueMask, &wc);
valueMask &= ~(CWSibling | CWStackMode);
xwc->x = input.left;
xwc->y = input.top;
- XConfigureWindow (screen->display ()->dpy (), wrapper,
+ XConfigureWindow (screen->dpy (), wrapper,
valueMask, xwc);
xwc->x = 0;
xwc->y = 0;
}
- XConfigureWindow (screen->display ()->dpy (), id, valueMask, xwc);
+ XConfigureWindow (screen->dpy (), id, valueMask, xwc);
}
bool
@@ -2750,9 +2745,9 @@ PrivateWindow::addWindowStackChanges (XWindowChanges *xwc,
{
if (!sibling)
{
- XLowerWindow (screen->display ()->dpy (), id);
+ XLowerWindow (screen->dpy (), id);
if (frame)
- XLowerWindow (screen->display ()->dpy (), frame);
+ XLowerWindow (screen->dpy (), frame);
}
else if (sibling->priv->id != window->prev->priv->id)
{
@@ -2923,7 +2918,7 @@ CompWindow::updateAttributes (CompStackingUpdateMode stackingMode)
CompWindow *p;
for (p = sibling; p; p = p->prev)
- if (p->priv->id == priv->screen->display ()->activeWindow ())
+ if (p->priv->id == priv->screen->activeWindow ())
break;
/* window is above active window so we should lower it */
@@ -3067,7 +3062,6 @@ CompWindow::constrainNewWindowSize (int width,
int *newWidth,
int *newHeight)
{
- CompDisplay *d = priv->screen->display ();
const XSizeHints *hints = &priv->sizeHints;
int oldWidth = width;
int oldHeight = height;
@@ -3082,7 +3076,7 @@ CompWindow::constrainNewWindowSize (int width,
long flags = hints->flags;
long resizeIncFlags = (flags & PResizeInc) ? ~0 : 0;
- if (d->getOption ("ignore_hints_when_maximized")->value ().b ())
+ if (priv->screen->getOption ("ignore_hints_when_maximized")->value ().b ())
{
if (priv->state & MAXIMIZE_STATE)
{
@@ -3238,7 +3232,7 @@ CompWindow::hide ()
priv->shaded = false;
if ((priv->state & CompWindowStateShadedMask) && priv->frame)
- XUnmapWindow (priv->screen->display ()->dpy (), priv->frame);
+ XUnmapWindow (priv->screen->dpy (), priv->frame);
}
windowNotify (CompWindowNotifyHide);
@@ -3249,15 +3243,15 @@ CompWindow::hide ()
priv->pendingUnmaps++;
if (priv->frame && !priv->shaded)
- XUnmapWindow (priv->screen->display ()->dpy (), priv->frame);
+ XUnmapWindow (priv->screen->dpy (), priv->frame);
- XUnmapWindow (priv->screen->display ()->dpy (), priv->id);
+ XUnmapWindow (priv->screen->dpy (), priv->id);
if (priv->minimized || priv->inShowDesktopMode ||
priv->hidden || priv->shaded)
changeState (priv->state | CompWindowStateHiddenMask);
- if (priv->shaded && priv->id == priv->screen->display ()->activeWindow ())
+ if (priv->shaded && priv->id == priv->screen->activeWindow ())
moveInputFocusTo ();
}
@@ -3285,7 +3279,7 @@ CompWindow::show ()
priv->shaded = true;
if (priv->frame)
- XMapWindow (priv->screen->display ()->dpy (), priv->frame);
+ XMapWindow (priv->screen->dpy (), priv->frame);
if (priv->height)
resize (priv->attrib.x, priv->attrib.y,
@@ -3303,7 +3297,7 @@ CompWindow::show ()
priv->pendingMaps++;
- XMapWindow (priv->screen->display ()->dpy (), priv->id);
+ XMapWindow (priv->screen->dpy (), priv->id);
changeState (priv->state & ~CompWindowStateHiddenMask);
}
@@ -3386,8 +3380,8 @@ CompWindow::getUserTime (Time *time)
unsigned long n, left;
unsigned char *data;
- result = XGetWindowProperty (priv->screen->display ()->dpy (), priv->id,
- priv->screen->display ()->atoms ().wmUserTime,
+ result = XGetWindowProperty (priv->screen->dpy (), priv->id,
+ Atoms::wmUserTime,
0L, 1L, False, XA_CARDINAL, &actual, &format,
&n, &left, &data);
@@ -3410,8 +3404,8 @@ CompWindow::setUserTime (Time time)
{
CARD32 value = (CARD32) time;
- XChangeProperty (priv->screen->display ()->dpy (), priv->id,
- priv->screen->display ()->atoms ().wmUserTime,
+ XChangeProperty (priv->screen->dpy (), priv->id,
+ Atoms::wmUserTime,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) &value, 1);
}
@@ -3462,7 +3456,6 @@ PrivateWindow::getUsageTimestamp (Time *timestamp)
bool
PrivateWindow::isWindowFocusAllowed (Time timestamp)
{
- CompDisplay *d = screen->display ();
CompScreen *s = screen;
CompWindow *active;
Time wUserTime, aUserTime;
@@ -3529,7 +3522,7 @@ PrivateWindow::isWindowFocusAllowed (Time timestamp)
}
/* can't get user time for active window */
- active = d->findWindow (d->activeWindow ());
+ active = s->findWindow (s->activeWindow ());
if (!active || !active->getUserTime (&aUserTime))
return true;
@@ -3545,7 +3538,7 @@ CompWindow::allowWindowFocus (unsigned int noFocusMask,
{
bool retval;
- if (priv->id == priv->screen->display ()->activeWindow ())
+ if (priv->id == priv->screen->activeWindow ())
return true;
/* do not focus windows of these types */
@@ -3590,8 +3583,8 @@ CompWindow::getIcon (int width, int height)
unsigned long n, left;
unsigned char *data;
- result = XGetWindowProperty (priv->screen->display ()->dpy (), priv->id,
- priv->screen->display ()->atoms ().wmIcon,
+ result = XGetWindowProperty (priv->screen->dpy (), priv->id,
+ Atoms::wmIcon,
0L, 65536L,
FALSE, XA_CARDINAL,
&actual, &format, &n,
@@ -3733,9 +3726,7 @@ CompWindow::setDesktop (unsigned int desktop)
else
hide ();
- priv->screen->display ()->setWindowProp (priv->id,
- priv->screen->display ()->atoms ().winDesktop,
- priv->desktop);
+ priv->screen->setWindowProp (priv->id, Atoms::winDesktop, priv->desktop);
}
/* The compareWindowActiveness function compares the two windows 'w1'
@@ -3930,8 +3921,6 @@ CompWindow::protocols ()
void
CompWindow::close (Time serverTime)
{
- CompDisplay *display = priv->screen->display ();
-
if (serverTime == 0)
serverTime = priv->screen->getCurrentTime ();
@@ -3943,28 +3932,28 @@ CompWindow::close (Time serverTime)
ev.type = ClientMessage;
ev.xclient.window = priv->id;
- ev.xclient.message_type = display->atoms ().wmProtocols;
+ ev.xclient.message_type = Atoms::wmProtocols;
ev.xclient.format = 32;
- ev.xclient.data.l[0] = display->atoms ().wmDeleteWindow;
+ ev.xclient.data.l[0] = Atoms::wmDeleteWindow;
ev.xclient.data.l[1] = serverTime;
ev.xclient.data.l[2] = 0;
ev.xclient.data.l[3] = 0;
ev.xclient.data.l[4] = 0;
- XSendEvent (display->dpy (), priv->id, false, NoEventMask, &ev);
+ XSendEvent (priv->screen->dpy (), priv->id, false,
+ NoEventMask, &ev);
}
else
{
- XKillClient (display->dpy (), priv->id);
+ XKillClient (priv->screen->dpy (), priv->id);
}
priv->closeRequests++;
}
else
{
- priv->screen->toolkitAction (
- priv->screen->display ()->atoms ().toolkitActionForceQuitDialog,
- serverTime, priv->id, true, 0, 0);
+ priv->screen->toolkitAction (Atoms::toolkitActionForceQuitDialog,
+ serverTime, priv->id, true, 0, 0);
}
priv->lastCloseRequestTime = serverTime;
@@ -3995,8 +3984,7 @@ CompWindow::handlePingTimeout (unsigned int lastPing)
if (priv->closeRequests)
{
priv->screen->toolkitAction (
- priv->screen->display ()->atoms ().
- toolkitActionForceQuitDialog,
+ Atoms::toolkitActionForceQuitDialog,
priv->lastCloseRequestTime,
priv->id, true, 0, 0);
@@ -4022,12 +4010,9 @@ CompWindow::handlePing (int lastPing)
if (priv->lastCloseRequestTime)
{
priv->screen->toolkitAction (
- priv->screen->display ()->atoms ().toolkitActionForceQuitDialog,
+ Atoms::toolkitActionForceQuitDialog,
priv->lastCloseRequestTime,
- priv->id,
- false,
- 0,
- 0);
+ priv->id, false, 0, 0);
priv->lastCloseRequestTime = 0;
}
@@ -4093,7 +4078,7 @@ CompWindow::processMap ()
if (!(priv->state & CompWindowStateHiddenMask))
{
priv->pendingMaps++;
- XMapWindow (priv->screen->display ()->dpy (), priv->id);
+ XMapWindow (priv->screen->dpy (), priv->id);
}
if (allowFocus)
@@ -4366,7 +4351,7 @@ CompWindow::sizeHints ()
void
CompWindow::updateMwmHints ()
{
- priv->screen->display ()->getMwmHints (priv->id, &priv->mwmFunc,
+ priv->screen->getMwmHints (priv->id, &priv->mwmFunc,
&priv->mwmDecor);
recalcActions ();
@@ -4409,8 +4394,6 @@ CompWindow::CompWindow (CompScreen *screen,
priv = new PrivateWindow (this, screen);
assert (priv);
- CompDisplay *d = screen->display ();
-
priv->region = XCreateRegion ();
assert (priv->region);
priv->frameRegion = XCreateRegion ();
@@ -4422,7 +4405,7 @@ CompWindow::CompWindow (CompScreen *screen,
window to the window list as we might get configure requests which
require us to stack other windows relative to it. Setting some default
values if this is the case. */
- if (!XGetWindowAttributes (d->dpy (), id, &priv->attrib))
+ if (!XGetWindowAttributes (screen->dpy (), id, &priv->attrib))
setDefaultWindowAttributes (&priv->attrib);
@@ -4446,22 +4429,22 @@ CompWindow::CompWindow (CompScreen *screen,
priv->transientFor = None;
priv->clientLeader = None;
- XSelectInput (d->dpy (), id,
+ XSelectInput (screen->dpy (), id,
PropertyChangeMask |
EnterWindowMask |
FocusChangeMask);
priv->id = id;
- XGrabButton (d->dpy (), AnyButton, AnyModifier, priv->id, TRUE,
+ XGrabButton (screen->dpy (), AnyButton, AnyModifier, priv->id, TRUE,
ButtonPressMask | ButtonReleaseMask | ButtonMotionMask,
GrabModeSync, GrabModeSync, None, None);
priv->alpha = (depth () == 32);
- priv->lastPong = d->lastPing ();
+ priv->lastPong = screen->lastPing ();
- if (d->XShape ())
- XShapeSelectInput (d->dpy (), id, ShapeNotifyMask);
+ if (screen->XShape ())
+ XShapeSelectInput (screen->dpy (), id, ShapeNotifyMask);
screen->insertWindow (this, aboveId);
@@ -4482,7 +4465,7 @@ CompWindow::CompWindow (CompScreen *screen,
XUnionRegion (&rect, priv->region, priv->region);
/* need to check for DisplayModal state on all windows */
- priv->state = d->getWindowState (priv->id);
+ priv->state = screen->getWindowState (priv->id);
updateClassHints ();
}
@@ -4491,8 +4474,8 @@ CompWindow::CompWindow (CompScreen *screen,
priv->attrib.map_state = IsUnmapped;
}
- priv->wmType = d->getWindowType (priv->id);
- priv->protocols = d->getProtocols (priv->id);
+ priv->wmType = screen->getWindowType (priv->id);
+ priv->protocols = screen->getProtocols (priv->id);
if (!overrideRedirect ())
{
@@ -4507,12 +4490,12 @@ CompWindow::CompWindow (CompScreen *screen,
recalcType ();
- d->getMwmHints (priv->id, &priv->mwmFunc, &priv->mwmDecor);
+ screen->getMwmHints (priv->id, &priv->mwmFunc, &priv->mwmDecor);
if (!(priv->type & (CompWindowTypeDesktopMask | CompWindowTypeDockMask)))
{
- priv->desktop = d->getWindowProp (priv->id, d->atoms ().winDesktop,
- priv->desktop);
+ priv->desktop = screen->getWindowProp (priv->id, Atoms::winDesktop,
+ priv->desktop);
if (priv->desktop != 0xffffffff)
{
if (priv->desktop >= screen->nDesktop ())
@@ -4533,7 +4516,7 @@ CompWindow::CompWindow (CompScreen *screen,
{
priv->managed = true;
- if (d->getWmState (priv->id) == IconicState)
+ if (screen->getWmState (priv->id) == IconicState)
{
if (priv->state & CompWindowStateShadedMask)
priv->shaded = true;
@@ -4552,8 +4535,8 @@ CompWindow::CompWindow (CompScreen *screen,
if (priv->desktop != 0xffffffff)
priv->desktop = screen->currentDesktop ();
- d->setWindowProp (priv->id, d->atoms ().winDesktop,
- priv->desktop);
+ screen->setWindowProp (priv->id, Atoms::winDesktop,
+ priv->desktop);
}
}
}
@@ -4572,14 +4555,14 @@ CompWindow::CompWindow (CompScreen *screen,
priv->pendingUnmaps++;
- XUnmapWindow (d->dpy (), priv->id);
+ XUnmapWindow (screen->dpy (), priv->id);
- d->setWindowState (priv->state, priv->id);
+ screen->setWindowState (priv->state, priv->id);
}
}
else if (!overrideRedirect ())
{
- if (d->getWmState (priv->id) == IconicState)
+ if (screen->getWmState (priv->id) == IconicState)
{
priv->managed = true;
priv->placed = true;
@@ -4619,8 +4602,6 @@ CompWindow::~CompWindow ()
if (!priv->destroyed)
{
- CompDisplay *d = priv->screen->display ();
-
if (priv->frame)
priv->unreparent ();
@@ -4628,21 +4609,22 @@ CompWindow::~CompWindow ()
if (!priv->attrib.override_redirect)
{
if (priv->saveMask)
- XConfigureWindow (d->dpy (), priv->id, priv->saveMask, &priv->saveWc);
+ XConfigureWindow (priv->screen->dpy (), priv->id,
+ priv->saveMask, &priv->saveWc);
if (!priv->hidden)
{
if (priv->state & CompWindowStateHiddenMask)
- XMapWindow (d->dpy (), priv->id);
+ XMapWindow (priv->screen->dpy (), priv->id);
}
}
- if (d->XShape ())
- XShapeSelectInput (d->dpy (), priv->id, NoEventMask);
+ if (priv->screen->XShape ())
+ XShapeSelectInput (priv->screen->dpy (), priv->id, NoEventMask);
- XSelectInput (d->dpy (), priv->id, NoEventMask);
+ XSelectInput (priv->screen->dpy (), priv->id, NoEventMask);
- XUngrabButton (d->dpy (), AnyButton, AnyModifier, priv->id);
+ XUngrabButton (priv->screen->dpy (), AnyButton, AnyModifier, priv->id);
}
if (priv->attrib.map_state == IsViewable)
@@ -4755,12 +4737,12 @@ PrivateWindow::PrivateWindow (CompWindow *window, CompScreen *screen) :
PrivateWindow::~PrivateWindow ()
{
if (syncAlarm)
- XSyncDestroyAlarm (screen->display ()->dpy (), syncAlarm);
+ XSyncDestroyAlarm (screen->dpy (), syncAlarm);
syncWaitTimer.stop ();
if (frame)
- XDestroyWindow (screen->display ()->dpy (), frame);
+ XDestroyWindow (screen->dpy (), frame);
if (region)
XDestroyRegion (region);
@@ -4816,8 +4798,6 @@ CompWindow::overrideRedirect ()
void
CompWindow::setOverrideRedirect (bool overrideRedirect)
{
- CompDisplay *d = priv->screen->display ();
-
if (overrideRedirect == this->overrideRedirect ())
return;
@@ -4825,7 +4805,7 @@ CompWindow::setOverrideRedirect (bool overrideRedirect)
recalcType ();
recalcActions ();
- d->matchPropertyChanged (this);
+ priv->screen->matchPropertyChanged (this);
}
bool
@@ -4896,7 +4876,7 @@ CompWindow::updateFrameRegion ()
y = priv->serverGeometry.y () - priv->input.top;
- XShapeCombineRegion (priv->screen->display ()->dpy (), priv->frame,
+ XShapeCombineRegion (priv->screen->dpy (), priv->frame,
ShapeBounding, -x, -y, priv->frameRegion,
ShapeSet);
}
@@ -4923,8 +4903,8 @@ CompWindow::setWindowFrameExtents (CompWindowExtents *i)
data[2] = i->top;
data[3] = i->bottom;
- XChangeProperty (priv->screen->display ()->dpy (), priv->id,
- priv->screen->display ()->atoms ().frameExtents,
+ XChangeProperty (priv->screen->dpy (), priv->id,
+ Atoms::frameExtents,
XA_CARDINAL, 32, PropModeReplace,
(unsigned char *) data, 4);
}
@@ -4942,7 +4922,7 @@ PrivateWindow::reparent ()
int mask;
XEvent e;
- Display *dpy = screen->display ()->dpy ();
+ Display *dpy = screen->dpy ();
if (frame)
return false;
@@ -5015,7 +4995,7 @@ PrivateWindow::reparent ()
void
PrivateWindow::unreparent ()
{
- Display *dpy = screen->display ()->dpy ();
+ Display *dpy = screen->dpy ();
XEvent e;
XWindowChanges xwc;