Fixed Container.Background support. We can have that support or not.
[idesk.git] / src / XDesktopContainer.h
blob48adad554fee1e396f109c1eff495673ab5859c6
1 /* vim:tabstop=4:expandtab:shiftwidth=4
2 *
3 * Idesk -- XDesktopContainer.h
5 * Copyright (c) 2002, Chris (nikon) (nikon@sc.rr.com)
6 * All rights reserved.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are met:
11 * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
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.
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.
22 * (See the included file COPYING / BSD )
25 #ifndef XDESKTOP_CONTAINER_CLASS
26 #define XDESKTOP_CONTAINER_CLASS
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 */
35 #ifndef TRUE
36 #define TRUE 1
37 #endif
39 #ifndef FALSE
40 #define FALSE 0
41 #endif
43 #include <X11/Xlib.h>
44 #include <Imlib2.h>
46 #include "DesktopContainer.h"
47 #include "DesktopConfig.h"
48 #include "ActionConfig.h"
51 static int error_trap_depth = 0;
53 class XIcon;
54 class Timer;
55 class XImlib2Background;
59 class XDesktopContainer : public DesktopContainer
61 private:
62 Timer *timer;
63 int x, y, width, height, depth;
64 public:
65 Window rootWindow;
66 XImlib2Background * bg;
67 Atom stop;
69 protected:
70 Display* display;
72 #ifdef HAVE_STARTUP_NOTIFICATION
73 SnDisplay *sn_display;
74 SnLauncherContext *sn_context;
75 #endif /* HAVE_STARTUP_NOTIFICATION */
77 XEvent event;
78 Window window;
80 unsigned int times[3];
81 unsigned int numClicks[3];
82 Imlib_Image bgImage, blended_bgImage;
83 Pixmap bgPixmap;
85 public:
86 XDesktopContainer(AbstractApp * a);
87 ~XDesktopContainer();
89 void destroy();
90 void create();
92 void run();
93 void parseEvent();
95 void initXWin();
96 void initImlib();
97 void getRootImage();
98 void configure();
99 void createWindow();
100 void setContainerBackground();
101 Imlib_Image createCropImage(int x, int y, int width, int height);
102 Window getWindow() {
103 if(window)
104 return window;
105 else
106 return rootWindow;
110 void addIcon(AbstractIcon *);
111 void addXIcon(const string & file, const string & pictureFile,
112 const string & captionText, const string & command,
113 int xCord, int yCord,
114 const string & fontName, int fontSize,
115 const string & color,
116 Imlib_Image * spareRoot);
118 void eventLoop();
119 void parseNonIconEvents();
120 XIcon * parseIconEvents();
121 void exeCurrentAction(XIcon * icon);
123 virtual void setEventState();
124 virtual void translateButtonRelease(int button);
126 void saveState();
127 void saveIcon(AbstractIcon *);
128 void reloadState();
130 Display * getDisplay() { return display; }
131 Window getRootWindow() { return rootWindow; }
133 void loadIcons();
134 void arrangeIcons();
135 void updateIcons();
136 XIcon * findIcon(Window window);
137 void addIcon( const string & file, const string & pictureFile,
138 const string & captionText, const string & command,
139 int xCord, int yCord ) ;
141 void runCommand(const string & command);
143 virtual int widthOfScreen();
144 virtual int heightOfScreen();
146 #ifdef HAVE_STARTUP_NOTIFICATION
147 void startup_timeout(SnLauncherContext * sn_context);
149 static void error_trap_push (SnDisplay *display, Display *xdisplay){ ++error_trap_depth;}
151 static void error_trap_pop (SnDisplay *display, Display *xdisplay){
152 if (error_trap_depth == 0)
154 fprintf (stderr, "Error trap underflow!\n");
155 exit (1);
158 XSync (xdisplay, False); /* get all errors out of the queue */
159 --error_trap_depth;
161 #endif /* HAVE_STARTUP_NOTIFICATION */
165 #endif