00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef _COMPSCREEN_H
00029 #define _COMPSCREEN_H
00030
00031 #include <core/window.h>
00032 #include <core/output.h>
00033 #include <core/session.h>
00034 #include <core/plugin.h>
00035 #include <core/match.h>
00036 #include <core/pluginclasses.h>
00037 #include <core/region.h>
00038 #include <core/modifierhandler.h>
00039
00040 class CompScreen;
00041 class PrivateScreen;
00042 typedef std::list<CompWindow *> CompWindowList;
00043 typedef std::vector<CompWindow *> CompWindowVector;
00044
00045 extern char *backgroundImage;
00046 extern bool replaceCurrentWm;
00047 extern bool indirectRendering;
00048 extern bool noDetection;
00049 extern bool debugOutput;
00050
00051 extern CompScreen *screen;
00052 extern ModifierHandler *modHandler;
00053
00054 extern int lastPointerX;
00055 extern int lastPointerY;
00056 extern int pointerX;
00057 extern int pointerY;
00058
00059 #define NOTIFY_CREATE_MASK (1 << 0)
00060 #define NOTIFY_DELETE_MASK (1 << 1)
00061 #define NOTIFY_MOVE_MASK (1 << 2)
00062 #define NOTIFY_MODIFY_MASK (1 << 3)
00063
00064 typedef boost::function<void (short int)> FdWatchCallBack;
00065 typedef boost::function<void (const char *)> FileWatchCallBack;
00066
00067 typedef int CompFileWatchHandle;
00068 typedef int CompWatchFdHandle;
00069
00073 struct CompFileWatch {
00074 CompString path;
00075 int mask;
00076 FileWatchCallBack callBack;
00077 CompFileWatchHandle handle;
00078 };
00079 typedef std::list<CompFileWatch *> CompFileWatchList;
00080
00081 #define ACTIVE_WINDOW_HISTORY_SIZE 64
00082 #define ACTIVE_WINDOW_HISTORY_NUM 32
00083
00087 struct CompActiveWindowHistory {
00088 Window id[ACTIVE_WINDOW_HISTORY_SIZE];
00089 int x;
00090 int y;
00091 int activeNum;
00092 };
00093
00097 class ScreenInterface : public WrapableInterface<CompScreen, ScreenInterface> {
00098 public:
00099 virtual void fileWatchAdded (CompFileWatch *fw);
00100 virtual void fileWatchRemoved (CompFileWatch *fw);
00101
00102 virtual bool initPluginForScreen (CompPlugin *p);
00103 virtual void finiPluginForScreen (CompPlugin *p);
00104
00105 virtual bool setOptionForPlugin (const char *plugin,
00106 const char *name,
00107 CompOption::Value &v);
00108
00109 virtual void sessionEvent (CompSession::Event event,
00110 CompOption::Vector &options);
00111
00112 virtual void handleEvent (XEvent *event);
00113 virtual void handleCompizEvent (const char * plugin, const char *event,
00114 CompOption::Vector &options);
00115
00116 virtual bool fileToImage (CompString &path, CompSize &size,
00117 int &stride, void *&data);
00118 virtual bool imageToFile (CompString &path, CompString &format,
00119 CompSize &size, int stride, void *data);
00120
00121 virtual CompMatch::Expression *matchInitExp (const CompString& value);
00122
00123 virtual void matchExpHandlerChanged ();
00124 virtual void matchPropertyChanged (CompWindow *window);
00125
00126 virtual void logMessage (const char *componentName,
00127 CompLogLevel level,
00128 const char *message);
00129
00130 virtual void enterShowDesktopMode ();
00131 virtual void leaveShowDesktopMode (CompWindow *window);
00132
00133 virtual void outputChangeNotify ();
00134 virtual void addSupportedAtoms (std::vector<Atom>& atoms);
00135 };
00136
00141 class CompScreen :
00142 public CompSize,
00143 public WrapableHandler<ScreenInterface, 18>,
00144 public PluginClassStorage,
00145 public CompOption::Class
00146 {
00147
00148 public:
00149 typedef void* GrabHandle;
00150
00151 public:
00152 CompScreen ();
00153 ~CompScreen ();
00154
00155 bool init (const char *name);
00156
00157 void eventLoop ();
00158
00159 CompFileWatchHandle addFileWatch (const char *path,
00160 int mask,
00161 FileWatchCallBack callBack);
00162
00163 void removeFileWatch (CompFileWatchHandle handle);
00164
00165 const CompFileWatchList& getFileWatches () const;
00166
00167 CompWatchFdHandle addWatchFd (int fd,
00168 short int events,
00169 FdWatchCallBack callBack);
00170
00171 void removeWatchFd (CompWatchFdHandle handle);
00172
00173 void storeValue (CompString key, CompPrivate value);
00174 bool hasValue (CompString key);
00175 CompPrivate getValue (CompString key);
00176 void eraseValue (CompString key);
00177
00178 Display * dpy ();
00179
00180 CompOption::Vector & getOptions ();
00181
00182 bool setOption (const CompString &name, CompOption::Value &value);
00183
00184 bool XRandr ();
00185
00186 int randrEvent ();
00187
00188 bool XShape ();
00189
00190 int shapeEvent ();
00191
00192 int syncEvent ();
00193
00194 SnDisplay * snDisplay ();
00195
00196 Window activeWindow ();
00197
00198 Window autoRaiseWindow ();
00199
00200 const char * displayString ();
00201
00202
00203 CompWindow * findWindow (Window id);
00204
00205 CompWindow * findTopLevelWindow (Window id,
00206 bool override_redirect = false);
00207
00208 bool readImageFromFile (CompString &name,
00209 CompSize &size,
00210 void *&data);
00211
00212 bool writeImageToFile (CompString &path,
00213 const char *format,
00214 CompSize &size,
00215 void *data);
00216
00217 unsigned int getWindowProp (Window id,
00218 Atom property,
00219 unsigned int defaultValue);
00220
00221
00222 void setWindowProp (Window id,
00223 Atom property,
00224 unsigned int value);
00225
00226
00227 unsigned short getWindowProp32 (Window id,
00228 Atom property,
00229 unsigned short defaultValue);
00230
00231
00232 void setWindowProp32 (Window id,
00233 Atom property,
00234 unsigned short value);
00235
00236 Window root ();
00237
00238 int xkbEvent ();
00239
00240 XWindowAttributes attrib ();
00241
00242 int screenNum ();
00243
00244 CompWindowList & windows ();
00245
00246 void warpPointer (int dx, int dy);
00247
00248 Time getCurrentTime ();
00249
00250 Window selectionWindow ();
00251
00252 void forEachWindow (CompWindow::ForEach);
00253
00254 void focusDefaultWindow ();
00255
00256 void insertWindow (CompWindow *w, Window aboveId);
00257
00258 void unhookWindow (CompWindow *w);
00259
00260 Cursor normalCursor ();
00261
00262 Cursor invisibleCursor ();
00263
00264 GrabHandle pushGrab (Cursor cursor, const char *name);
00265
00266 void updateGrab (GrabHandle handle, Cursor cursor);
00267
00268 void removeGrab (GrabHandle handle, CompPoint *restorePointer);
00269
00270 bool otherGrabExist (const char *, ...);
00271
00272 bool grabExist (const char *);
00273
00274 const CompWindowVector & clientList (bool stackingOrder = true);
00275
00276 bool addAction (CompAction *action);
00277
00278 void removeAction (CompAction *action);
00279
00280 void updateWorkarea ();
00281
00282 void toolkitAction (Atom toolkitAction,
00283 Time eventTime,
00284 Window window,
00285 long data0,
00286 long data1,
00287 long data2);
00288
00289 void runCommand (CompString command);
00290
00291 void moveViewport (int tx, int ty, bool sync);
00292
00293 void sendWindowActivationRequest (Window id);
00294
00295 int outputDeviceForPoint (int x, int y);
00296 int outputDeviceForPoint (const CompPoint &point);
00297
00298 CompRect getCurrentOutputExtents ();
00299
00300 const CompRect & getWorkareaForOutput (unsigned int outputNum) const;
00301
00302 void viewportForGeometry (const CompWindow::Geometry &gm,
00303 CompPoint &viewport);
00304
00305 int outputDeviceForGeometry (const CompWindow::Geometry& gm);
00306
00307 CompPoint vp ();
00308
00309 CompSize vpSize ();
00310
00311 int desktopWindowCount ();
00312 unsigned int activeNum () const;
00313
00314 CompOutput::vector & outputDevs ();
00315 CompOutput & currentOutputDev () const;
00316
00317 const CompRect & workArea () const;
00318
00319 unsigned int currentDesktop ();
00320
00321 unsigned int nDesktop ();
00322
00323 CompActiveWindowHistory *currentHistory ();
00324
00325 bool shouldSerializePlugins () ;
00326
00327 const CompRegion & region () const;
00328
00329 bool hasOverlappingOutputs ();
00330
00331 CompOutput & fullscreenOutput ();
00332
00333 std::vector<XineramaScreenInfo> & screenInfo ();
00334
00335 CompIcon *defaultIcon () const;
00336
00337 bool updateDefaultIcon ();
00338
00339 void updateSupportedWmHints ();
00340
00341 static unsigned int allocPluginClassIndex ();
00342 static void freePluginClassIndex (unsigned int index);
00343
00344 WRAPABLE_HND (0, ScreenInterface, void, fileWatchAdded, CompFileWatch *)
00345 WRAPABLE_HND (1, ScreenInterface, void, fileWatchRemoved, CompFileWatch *)
00346
00347 WRAPABLE_HND (2, ScreenInterface, bool, initPluginForScreen,
00348 CompPlugin *)
00349 WRAPABLE_HND (3, ScreenInterface, void, finiPluginForScreen,
00350 CompPlugin *)
00351
00352 WRAPABLE_HND (4, ScreenInterface, bool, setOptionForPlugin,
00353 const char *, const char *, CompOption::Value &)
00354
00355 WRAPABLE_HND (5, ScreenInterface, void, sessionEvent, CompSession::Event,
00356 CompOption::Vector &)
00357 WRAPABLE_HND (6, ScreenInterface, void, handleEvent, XEvent *event)
00358 WRAPABLE_HND (7, ScreenInterface, void, handleCompizEvent,
00359 const char *, const char *, CompOption::Vector &)
00360
00361 WRAPABLE_HND (8, ScreenInterface, bool, fileToImage, CompString &,
00362 CompSize &, int &, void *&);
00363 WRAPABLE_HND (9, ScreenInterface, bool, imageToFile, CompString &,
00364 CompString &, CompSize &, int, void *);
00365
00366 WRAPABLE_HND (10, ScreenInterface, CompMatch::Expression *,
00367 matchInitExp, const CompString&);
00368 WRAPABLE_HND (11, ScreenInterface, void, matchExpHandlerChanged)
00369 WRAPABLE_HND (12, ScreenInterface, void, matchPropertyChanged,
00370 CompWindow *)
00371
00372 WRAPABLE_HND (13, ScreenInterface, void, logMessage, const char *,
00373 CompLogLevel, const char*)
00374 WRAPABLE_HND (14, ScreenInterface, void, enterShowDesktopMode);
00375 WRAPABLE_HND (15, ScreenInterface, void, leaveShowDesktopMode,
00376 CompWindow *);
00377
00378 WRAPABLE_HND (16, ScreenInterface, void, outputChangeNotify);
00379 WRAPABLE_HND (17, ScreenInterface, void, addSupportedAtoms,
00380 std::vector<Atom>& atoms);
00381
00382 friend class CompTimer;
00383 friend class CompWindow;
00384 friend class PrivateWindow;
00385 friend class ModifierHandler;
00386
00387 private:
00388 PrivateScreen *priv;
00389
00390 public :
00391
00392 static bool showDesktop (CompAction *action,
00393 CompAction::State state,
00394 CompOption::Vector &options);
00395
00396 static bool windowMenu (CompAction *action,
00397 CompAction::State state,
00398 CompOption::Vector &options);
00399
00400 static bool closeWin (CompAction *action,
00401 CompAction::State state,
00402 CompOption::Vector &options);
00403
00404 static bool unmaximizeWin (CompAction *action,
00405 CompAction::State state,
00406 CompOption::Vector &options);
00407
00408 static bool minimizeWin (CompAction *action,
00409 CompAction::State state,
00410 CompOption::Vector &options);
00411
00412 static bool maximizeWin (CompAction *action,
00413 CompAction::State state,
00414 CompOption::Vector &options);
00415
00416 static bool maximizeWinHorizontally (CompAction *action,
00417 CompAction::State state,
00418 CompOption::Vector &options);
00419
00420 static bool maximizeWinVertically (CompAction *action,
00421 CompAction::State state,
00422 CompOption::Vector &options);
00423
00424 static bool raiseWin (CompAction *action,
00425 CompAction::State state,
00426 CompOption::Vector &options);
00427
00428 static bool lowerWin (CompAction *action,
00429 CompAction::State state,
00430 CompOption::Vector &options);
00431
00432 static bool toggleWinMaximized (CompAction *action,
00433 CompAction::State state,
00434 CompOption::Vector &options);
00435
00436 static bool toggleWinMaximizedHorizontally (CompAction *action,
00437 CompAction::State state,
00438 CompOption::Vector &options);
00439
00440 static bool toggleWinMaximizedVertically (CompAction *action,
00441 CompAction::State state,
00442 CompOption::Vector &options);
00443
00444 static bool shadeWin (CompAction *action,
00445 CompAction::State state,
00446 CompOption::Vector &options);
00447
00448 static void
00449 compScreenSnEvent (SnMonitorEvent *event,
00450 void *userData);
00451
00452 static int checkForError (Display *dpy);
00453 };
00454
00455 #endif