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>
38
#include <glibmm/main.h>
40
#include "core_options.h"
42
CompPlugin::VTable * getCoreVTable ();
45
extern bool restartSignal;
47
typedef struct _CompWatchFd {
49
FdWatchCallBack callBack;
50
CompWatchFdHandle handle;
53
extern CompWindow *lastFoundWindow;
54
extern bool useDesktopHints;
56
extern bool inHandleEvent;
58
extern CompScreen *targetScreen;
59
extern CompOutput *targetOutput;
62
typedef struct _CompDelayedEdgeSettings
64
CompAction::CallBack initiate;
65
CompAction::CallBack terminate;
70
CompOption::Vector options;
71
} CompDelayedEdgeSettings;
74
#define SCREEN_EDGE_LEFT 0
75
#define SCREEN_EDGE_RIGHT 1
76
#define SCREEN_EDGE_TOP 2
77
#define SCREEN_EDGE_BOTTOM 3
78
#define SCREEN_EDGE_TOPLEFT 4
79
#define SCREEN_EDGE_TOPRIGHT 5
80
#define SCREEN_EDGE_BOTTOMLEFT 6
81
#define SCREEN_EDGE_BOTTOMRIGHT 7
82
#define SCREEN_EDGE_NUM 8
84
#define TIMEVALDIFF(tv1, tv2) \
85
((tv1)->tv_sec == (tv2)->tv_sec || (tv1)->tv_usec >= (tv2)->tv_usec) ? \
86
((((tv1)->tv_sec - (tv2)->tv_sec) * 1000000) + \
87
((tv1)->tv_usec - (tv2)->tv_usec)) / 1000 : \
88
((((tv1)->tv_sec - 1 - (tv2)->tv_sec) * 1000000) + \
89
(1000000 + (tv1)->tv_usec - (tv2)->tv_usec)) / 1000
91
struct CompScreenEdge {
101
struct CompStartupSequence {
102
SnStartupSequence *sequence;
103
unsigned int viewportX;
104
unsigned int viewportY;
107
class CompEventSource:
113
Glib::RefPtr <CompEventSource> create ();
115
sigc::connection connect (const sigc::slot <bool> &slot);
119
bool prepare (int &timeout);
121
bool dispatch (sigc::slot_base *slot);
124
explicit CompEventSource ();
125
virtual ~CompEventSource ();
130
Glib::PollFD mPollFD;
134
class PrivateScreen : public CoreOptions {
140
unsigned int modifiers;
147
unsigned int modifiers;
154
friend class CompScreen;
161
PrivateScreen (CompScreen *screen);
164
bool setOption (const CompString &name, CompOption::Value &value);
166
void processEvents ();
168
void removeDestroyed ();
170
void updatePassiveGrabs ();
172
int doPoll (int timeout);
174
void handleTimers (struct timeval *tv);
176
void addTimer (CompTimer *timer);
177
void removeTimer (CompTimer *timer);
179
void updatePlugins ();
181
bool triggerButtonPressBindings (CompOption::Vector &options,
183
CompOption::Vector &arguments);
185
bool triggerButtonReleaseBindings (CompOption::Vector &options,
187
CompOption::Vector &arguments);
189
bool triggerKeyPressBindings (CompOption::Vector &options,
191
CompOption::Vector &arguments);
193
bool triggerKeyReleaseBindings (CompOption::Vector &options,
195
CompOption::Vector &arguments);
197
bool triggerStateNotifyBindings (CompOption::Vector &options,
198
XkbStateNotifyEvent *event,
199
CompOption::Vector &arguments);
201
bool triggerEdgeEnter (unsigned int edge,
202
CompAction::State state,
203
CompOption::Vector &arguments);
205
void setAudibleBell (bool audible);
207
bool handlePingTimeout ();
209
bool handleActionEvent (XEvent *event);
211
void handleSelectionRequest (XEvent *event);
213
void handleSelectionClear (XEvent *event);
215
bool desktopHintEqual (unsigned long *data,
220
void setDesktopHints ();
222
void setVirtualScreenSize (int hsize, int vsize);
224
void updateOutputDevices ();
226
void detectOutputDevices ();
228
void updateStartupFeedback ();
230
void updateScreenEdges ();
232
void reshape (int w, int h);
234
bool handleStartupSequenceTimeout ();
236
void addSequence (SnStartupSequence *sequence);
238
void removeSequence (SnStartupSequence *sequence);
240
void removeAllSequences ();
242
void setSupportingWmCheck ();
244
void getDesktopHints ();
246
void grabUngrabOneKey (unsigned int modifiers,
251
bool grabUngrabKeys (unsigned int modifiers,
255
bool addPassiveKeyGrab (CompAction::KeyBinding &key);
257
void removePassiveKeyGrab (CompAction::KeyBinding &key);
259
void updatePassiveKeyGrabs ();
261
bool addPassiveButtonGrab (CompAction::ButtonBinding &button);
263
void removePassiveButtonGrab (CompAction::ButtonBinding &button);
265
CompRect computeWorkareaForBox (const CompRect &box);
267
void updateScreenInfo ();
269
Window getActiveWindow (Window root);
271
int getWmState (Window id);
273
void setWmState (int state, Window id);
275
unsigned int windowStateMask (Atom state);
277
static unsigned int windowStateFromString (const char *str);
279
unsigned int getWindowState (Window id);
281
void setWindowState (unsigned int state, Window id);
283
unsigned int getWindowType (Window id);
285
void getMwmHints (Window id,
287
unsigned int *decor);
289
unsigned int getProtocols (Window id);
291
bool readWindowProp32 (Window id,
293
unsigned short *returnValue);
295
void setCurrentOutput (unsigned int outputNum);
297
void configure (XConfigureEvent *ce);
299
void eraseWindowFromMap (Window id);
301
void updateClientList ();
303
CompGroup * addGroup (Window id);
305
void removeGroup (CompGroup *group);
307
CompGroup * findGroup (Window id);
309
void applyStartupProperties (CompWindow *window);
311
Window getTopWindow ();
313
void setNumberOfDesktops (unsigned int nDesktop);
315
void setCurrentDesktop (unsigned int desktop);
317
void setCurrentActiveWindowHistory (int x, int y);
319
void addToCurrentActiveWindowHistory (Window id);
321
void enableEdge (int edge);
323
void disableEdge (int edge);
325
void addScreenActions ();
328
focusTopMostWindow ();
334
Glib::RefPtr <Glib::MainLoop> mainloop;
335
Glib::RefPtr <CompEventSource> source;
336
Glib::RefPtr <Glib::MainContext> ctx;
338
CompFileWatchList fileWatch;
339
CompFileWatchHandle lastFileWatchHandle;
341
std::list<CompTimer *> timers;
342
struct timeval lastTimeout;
344
std::list<CompWatchFd *> watchFds;
345
CompWatchFdHandle lastWatchFdHandle;
346
struct pollfd *watchPollFds;
349
std::map<CompString, CompPrivate> valueMap;
351
xcb_connection_t *connection;
355
int syncEvent, syncError;
358
int randrEvent, randrError;
361
int shapeEvent, shapeError;
364
int xkbEvent, xkbError;
366
bool xineramaExtension;
367
int xineramaEvent, xineramaError;
369
std::vector<XineramaScreenInfo> screenInfo;
371
SnDisplay *snDisplay;
373
unsigned int lastPing;
379
char displayString[256];
381
KeyCode escapeKeyCode;
382
KeyCode returnKeyCode;
384
CompTimer autoRaiseTimer;
385
Window autoRaiseWindow;
387
CompTimer edgeDelayTimer;
388
CompDelayedEdgeSettings edgeDelaySettings;
390
CompOption::Value plugin;
391
bool dirtyPluginList;
395
CompWindowList windows;
396
CompWindow::Map windowsMap;
403
unsigned int nDesktop;
404
unsigned int currentDesktop;
409
XWindowAttributes attrib;
412
int desktopWindowCount;
414
unsigned int activeNum;
416
CompOutput::vector outputDevs;
417
int currentOutputDev;
418
CompOutput fullscreenOutput;
419
bool hasOverlappingOutputs;
421
XRectangle lastViewport;
423
CompActiveWindowHistory history[ACTIVE_WINDOW_HISTORY_NUM];
426
CompScreenEdge screenEdge[SCREEN_EDGE_NUM];
428
SnMonitorContext *snContext;
429
std::list<CompStartupSequence *> startupSequences;
430
CompTimer startupSequenceTimer;
432
std::list<CompGroup *> groups;
434
CompIcon *defaultIcon;
436
Window wmSnSelectionWindow;
442
Cursor invisibleCursor;
444
CompWindowVector clientList; /* clients in mapping order */
445
CompWindowVector clientListStacking; /* clients in stacking order */
447
std::vector<Window> clientIdList; /* client ids in mapping order */
448
std::vector<Window> clientIdListStacking;/* client ids in stacking order */
450
std::list<ButtonGrab> buttonGrabs;
451
std::list<KeyGrab> keyGrabs;
453
std::list<Grab *> grabs;
455
bool grabbed; /* true once we recieve a GrabNotify
456
on FocusOut and false on
457
UngrabNotify from FocusIn */
459
unsigned int pendingDestroys;
463
unsigned int showingDesktopMask;
465
unsigned long *desktopHintData;