1 /* vim:tabstop=4:expandtab:shiftwidth=4 2 * 3 * Idesk -- XDesktopContainer.h 4 * 5 * Copyright (c) 2002, Chris (nikon) (nikon@sc.rr.com) 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are met: 10 * 11 * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 14 * Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * Neither the name of the <ORGANIZATION> nor the names of its 19 * contributors may be used to endorse or promote products derived from 20 * this software without specific prior written permission. 21 * 22 * (See the included file COPYING / BSD ) 23 */ 24 25 #ifndef XDESKTOP_CONTAINER_CLASS 26 #define XDESKTOP_CONTAINER_CLASS 27 28 #include <sys/wait.h> 29 #ifdef HAVE_STARTUP_NOTIFICATION 30 #include <libsn/sn.h> 31 #include <assert.h> 32 #define G_USEC_PER_SEC 1000000 33 #endif /* HAVE_STARTUP_NOTIFICATION */ 34 35 #ifndef TRUE 36 #define TRUE 1 37 #endif 38 39 #ifndef FALSE 40 #define FALSE 0 41 #endif 42 43 #include <X11/Xlib.h> 44 #include <Imlib2.h> 45 46 #include "DesktopContainer.h" 47 #include "DesktopConfig.h" 48 #include "ActionConfig.h" 49 50 51 static int error_trap_depth = 0; 52 53 class XIcon; 54 class Timer; 55 class XImlib2Background; 56 57 58 59 class XDesktopContainer : public DesktopContainer 60 { 61 private: 62 Timer *timer; 63 public: 64 Window rootWindow; 65 XImlib2Background * bg; 66 Atom stop; 67 68 protected: 69 Display* display; 70 71 #ifdef HAVE_STARTUP_NOTIFICATION 72 SnDisplay *sn_display; 73 SnLauncherContext *sn_context; 74 #endif /* HAVE_STARTUP_NOTIFICATION */ 75 76 XEvent event; 77 78 unsigned int times[3]; 79 unsigned int numClicks[3]; 80 public: 81 XDesktopContainer(AbstractApp * a); 82 ~XDesktopContainer(); 83 84 void destroy(); 85 void create(); 86 87 void run(); 88 void parseEvent(); 89 90 void initXWin(); 91 void initImlib(); 92 void getRootImage(); 93 void configure(); 94 95 void addIcon(AbstractIcon *); 96 void addXIcon(const string & file, const string & pictureFile, 97 const string & captionText, const string & command, 98 int xCord, int yCord, 99 const string & fontName, int fontSize, 100 const string & color, 101 Imlib_Image * spareRoot); 102 103 void eventLoop(); 104 void parseNonIconEvents(); 105 XIcon * parseIconEvents(); 106 void exeCurrentAction(XIcon * icon); 107 108 virtual void setEventState(); 109 virtual void translateButtonRelease(int button); 110 111 void saveState(); 112 void saveIcon(AbstractIcon *); 113 void reloadState(); 114 getDisplay()115 Display * getDisplay() { return display; } getRootWindow()116 Window getRootWindow() { return rootWindow; } 117 118 void loadIcons(); 119 void arrangeIcons(); 120 void updateIcons(); 121 XIcon * findIcon(Window window); 122 void addIcon( const string & file, const string & pictureFile, 123 const string & captionText, const string & command, 124 int xCord, int yCord ) ; 125 126 void runCommand(const string & command); 127 128 virtual int widthOfScreen(); 129 virtual int heightOfScreen(); 130 131 #ifdef HAVE_STARTUP_NOTIFICATION 132 void startup_timeout(SnLauncherContext * sn_context); 133 error_trap_push(SnDisplay * display,Display * xdisplay)134 static void error_trap_push (SnDisplay *display, Display *xdisplay){ ++error_trap_depth;} 135 error_trap_pop(SnDisplay * display,Display * xdisplay)136 static void error_trap_pop (SnDisplay *display, Display *xdisplay){ 137 if (error_trap_depth == 0) 138 { 139 fprintf (stderr, "Error trap underflow!\n"); 140 exit (1); 141 } 142 143 XSync (xdisplay, False); /* get all errors out of the queue */ 144 --error_trap_depth; 145 } 146 #endif /* HAVE_STARTUP_NOTIFICATION */ 147 148 }; 149 150 #endif 151