2
* Copyright © 2008 Dennis Kasprzyk
3
* Copyright © 2007 Novell, Inc.
5
* Permission to use, copy, modify, distribute, and sell this software
6
* and its documentation for any purpose is hereby granted without
7
* fee, provided that the above copyright notice appear in all copies
8
* and that both that copyright notice and this permission notice
9
* appear in supporting documentation, and that the name of
10
* Dennis Kasprzyk not be used in advertising or publicity pertaining to
11
* distribution of the software without specific, written prior permission.
12
* Dennis Kasprzyk makes no representations about the suitability of this
13
* software for any purpose. It is provided "as is" without express or
16
* DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
18
* NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
20
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
21
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
22
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24
* Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
25
* David Reveman <davidr@novell.com>
28
#ifndef _PRIVATESCREEN_H
29
#define _PRIVATESCREEN_H
31
#include <core/core.h>
32
#include <core/screen.h>
33
#include <core/size.h>
34
#include <core/point.h>
35
#include <core/timer.h>
36
#include <core/plugin.h>
39
#include <glibmm/main.h>
41
#include "privatetimeoutsource.h"
42
#include "privateiosource.h"
43
#include "privateeventsource.h"
45
#include "core_options.h"
47
CompPlugin::VTable * getCoreVTable ();
52
extern bool restartSignal;
54
extern CompWindow *lastFoundWindow;
55
extern bool useDesktopHints;
57
extern bool inHandleEvent;
59
extern CompScreen *targetScreen;
60
extern CompOutput *targetOutput;
62
extern std::list <CompString> initialPlugins;
65
typedef struct _CompDelayedEdgeSettings
67
CompAction::CallBack initiate;
68
CompAction::CallBack terminate;
73
CompOption::Vector options;
74
} CompDelayedEdgeSettings;
77
#define SCREEN_EDGE_LEFT 0
78
#define SCREEN_EDGE_RIGHT 1
79
#define SCREEN_EDGE_TOP 2
80
#define SCREEN_EDGE_BOTTOM 3
81
#define SCREEN_EDGE_TOPLEFT 4
82
#define SCREEN_EDGE_TOPRIGHT 5
83
#define SCREEN_EDGE_BOTTOMLEFT 6
84
#define SCREEN_EDGE_BOTTOMRIGHT 7
85
#define SCREEN_EDGE_NUM 8
87
struct CompScreenEdge {
97
struct CompStartupSequence {
98
SnStartupSequence *sequence;
99
unsigned int viewportX;
100
unsigned int viewportY;
103
class PrivateScreen :
112
unsigned int modifiers;
119
unsigned int modifiers;
126
friend class CompScreen;
127
friend class SpewScreen;
134
PrivateScreen (CompScreen *screen);
137
bool setOption (const CompString &name, CompOption::Value &value);
139
std::list <XEvent> queueEvents ();
140
void processEvents ();
142
void removeDestroyed ();
144
void updatePassiveGrabs ();
146
void updatePlugins ();
148
bool triggerButtonPressBindings (CompOption::Vector &options,
150
CompOption::Vector &arguments);
152
bool triggerButtonReleaseBindings (CompOption::Vector &options,
154
CompOption::Vector &arguments);
156
bool triggerKeyPressBindings (CompOption::Vector &options,
158
CompOption::Vector &arguments);
160
bool triggerKeyReleaseBindings (CompOption::Vector &options,
162
CompOption::Vector &arguments);
164
bool triggerStateNotifyBindings (CompOption::Vector &options,
165
XkbStateNotifyEvent *event,
166
CompOption::Vector &arguments);
168
bool triggerEdgeEnter (unsigned int edge,
169
CompAction::State state,
170
CompOption::Vector &arguments);
172
void setAudibleBell (bool audible);
174
bool handlePingTimeout ();
176
bool handleActionEvent (XEvent *event);
178
void handleSelectionRequest (XEvent *event);
180
void handleSelectionClear (XEvent *event);
182
bool desktopHintEqual (unsigned long *data,
187
void setDesktopHints ();
189
void setVirtualScreenSize (int hsize, int vsize);
191
void updateOutputDevices ();
193
void detectOutputDevices ();
195
void updateStartupFeedback ();
197
void updateScreenEdges ();
199
void reshape (int w, int h);
201
bool handleStartupSequenceTimeout ();
203
void addSequence (SnStartupSequence *sequence);
205
void removeSequence (SnStartupSequence *sequence);
207
void removeAllSequences ();
209
void setSupportingWmCheck ();
211
void getDesktopHints ();
213
void grabUngrabOneKey (unsigned int modifiers,
218
bool grabUngrabKeys (unsigned int modifiers,
222
bool addPassiveKeyGrab (CompAction::KeyBinding &key);
224
void removePassiveKeyGrab (CompAction::KeyBinding &key);
226
void updatePassiveKeyGrabs ();
228
bool addPassiveButtonGrab (CompAction::ButtonBinding &button);
230
void removePassiveButtonGrab (CompAction::ButtonBinding &button);
232
CompRect computeWorkareaForBox (const CompRect &box);
234
void updateScreenInfo ();
236
Window getActiveWindow (Window root);
238
int getWmState (Window id);
240
void setWmState (int state, Window id);
242
unsigned int windowStateMask (Atom state);
244
static unsigned int windowStateFromString (const char *str);
246
unsigned int getWindowState (Window id);
248
void setWindowState (unsigned int state, Window id);
250
unsigned int getWindowType (Window id);
252
void getMwmHints (Window id,
254
unsigned int *decor);
256
unsigned int getProtocols (Window id);
258
bool readWindowProp32 (Window id,
260
unsigned short *returnValue);
262
void setCurrentOutput (unsigned int outputNum);
264
void configure (XConfigureEvent *ce);
266
void eraseWindowFromMap (Window id);
268
void updateClientList ();
270
CompGroup * addGroup (Window id);
272
void removeGroup (CompGroup *group);
274
CompGroup * findGroup (Window id);
276
void applyStartupProperties (CompWindow *window);
278
Window getTopWindow ();
280
void setNumberOfDesktops (unsigned int nDesktop);
282
void setCurrentDesktop (unsigned int desktop);
284
void setCurrentActiveWindowHistory (int x, int y);
286
void addToCurrentActiveWindowHistory (Window id);
288
void enableEdge (int edge);
290
void disableEdge (int edge);
292
void addScreenActions ();
295
focusTopMostWindow ();
300
void setDefaultWindowAttributes (XWindowAttributes *);
306
Glib::RefPtr <Glib::MainLoop> mainloop;
307
// See https://bugzilla.gnome.org/show_bug.cgi?id=561885
308
// Glib::RefPtr <CompEventSource> source;
309
CompEventSource* source;
310
Glib::RefPtr <CompTimeoutSource> timeout;
311
Glib::RefPtr <Glib::MainContext> ctx;
313
CompFileWatchList fileWatch;
314
CompFileWatchHandle lastFileWatchHandle;
316
std::list<Glib::RefPtr <CompWatchFd> > watchFds;
317
CompWatchFdHandle lastWatchFdHandle;
319
std::map<CompString, CompPrivate> valueMap;
321
xcb_connection_t *connection;
325
int syncEvent, syncError;
328
int randrEvent, randrError;
331
int shapeEvent, shapeError;
334
int xkbEvent, xkbError;
336
bool xineramaExtension;
337
int xineramaEvent, xineramaError;
339
std::vector<XineramaScreenInfo> screenInfo;
341
SnDisplay *snDisplay;
343
unsigned int lastPing;
347
Window nextActiveWindow;
350
char displayString[256];
352
KeyCode escapeKeyCode;
353
KeyCode returnKeyCode;
355
CompTimer autoRaiseTimer;
356
Window autoRaiseWindow;
358
CompTimer edgeDelayTimer;
359
CompDelayedEdgeSettings edgeDelaySettings;
361
CompOption::Value plugin;
362
bool dirtyPluginList;
366
std::list <CoreWindow *> createdWindows;
368
/* Window list last sent to server */
369
CompWindowList serverWindows;
371
/* Window list last recv from server */
372
CompWindowList windows;
373
CompWindowList destroyedWindows;
376
CompWindow::Map windowsMap;
378
std::map <CompWindow *, CompWindow *> detachedFrameWindows;
385
unsigned int nDesktop;
386
unsigned int currentDesktop;
391
XWindowAttributes attrib;
394
int desktopWindowCount;
396
unsigned int activeNum;
398
CompOutput::vector outputDevs;
399
int currentOutputDev;
400
CompOutput fullscreenOutput;
401
bool hasOverlappingOutputs;
403
XRectangle lastViewport;
405
CompActiveWindowHistory history[ACTIVE_WINDOW_HISTORY_NUM];
408
CompScreenEdge screenEdge[SCREEN_EDGE_NUM];
410
SnMonitorContext *snContext;
411
std::list<CompStartupSequence *> startupSequences;
412
CompTimer startupSequenceTimer;
414
std::list<CompGroup *> groups;
416
CompIcon *defaultIcon;
418
Window wmSnSelectionWindow;
424
Cursor invisibleCursor;
426
CompWindowVector clientList; /* clients in mapping order */
427
CompWindowVector clientListStacking; /* clients in stacking order */
429
std::vector<Window> clientIdList; /* client ids in mapping order */
430
std::vector<Window> clientIdListStacking;/* client ids in stacking order */
432
std::list<ButtonGrab> buttonGrabs;
433
std::list<KeyGrab> keyGrabs;
435
std::list<Grab *> grabs;
437
bool grabbed; /* true once we recieve a GrabNotify
438
on FocusOut and false on
439
UngrabNotify from FocusIn */
441
unsigned int pendingDestroys;
445
unsigned int showingDesktopMask;
447
unsigned long *desktopHintData;
466
bool parseArguments (int, char **);
469
static bool initPlugin (CompPlugin *p);
470
static void finiPlugin (CompPlugin *p);
474
std::list <CompString> plugins;