2 * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
3 * Copyright (C) 2004-2008 Kim Woelders
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies of the Software, its documentation and marketing & publicity
14 * materials, and acknowledgment shall be given in the documentation, materials
15 * and software packages that this Software was used.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #include "e16-ecore_hints.h"
28 #include <X11/Xutil.h>
29 #include <X11/extensions/shape.h>
40 XSetWindowAttributes attr;
42 if (EDebug(EDBUG_TYPE_SESSION))
43 Eprintf("ExtInitWinMain enter\n");
45 err = EDisplayOpen(NULL, -1);
53 attr.backing_store = NotUseful;
54 attr.override_redirect = True;
55 attr.colormap = WinGetCmap(VROOT);
56 attr.border_pixel = 0;
57 attr.background_pixel = 0;
58 attr.save_under = True;
59 win = XCreateWindow(disp, WinGetXwin(VROOT),
60 0, 0, WinGetW(VROOT), WinGetH(VROOT),
61 0, CopyFromParent, InputOutput, CopyFromParent,
62 CWOverrideRedirect | CWSaveUnder | CWBackingStore |
63 CWColormap | CWBackPixel | CWBorderPixel, &attr);
65 pmap = XCreatePixmap(disp, win,
66 WinGetW(VROOT), WinGetH(VROOT), WinGetDepth(VROOT));
67 gcv.subwindow_mode = IncludeInferiors;
68 gc = XCreateGC(disp, win, GCSubwindowMode, &gcv);
69 XCopyArea(disp, WinGetXwin(VROOT), pmap, gc,
70 0, 0, WinGetW(VROOT), WinGetH(VROOT), 0, 0);
71 XSetWindowBackgroundPixmap(disp, win, pmap);
72 XMapRaised(disp, win);
73 XFreePixmap(disp, pmap);
76 a = EInternAtom("ENLIGHTENMENT_RESTART_SCREEN");
77 ecore_x_window_prop_window_set(WinGetXwin(VROOT), a, &win, 1);
79 XSelectInput(disp, win, StructureNotifyMask);
92 XWindowAttributes xwa;
94 w2 = XCreateWindow(disp, win, 0, 0, 32, 32, 0, CopyFromParent,
95 InputOutput, CopyFromParent,
96 CWOverrideRedirect | CWBackingStore | CWColormap |
97 CWBackPixel | CWBorderPixel, &attr);
99 pmap = XCreatePixmap(disp, w2, 16, 16, 1);
100 gc = XCreateGC(disp, pmap, 0, NULL);
101 XSetForeground(disp, gc, 0);
102 XFillRectangle(disp, pmap, gc, 0, 0, 16, 16);
105 mask = XCreatePixmap(disp, w2, 16, 16, 1);
106 gc = XCreateGC(disp, mask, 0, NULL);
107 XSetForeground(disp, gc, 0);
108 XFillRectangle(disp, mask, gc, 0, 0, 16, 16);
111 cs = XCreatePixmapCursor(disp, pmap, mask, &cl, &cl, 0, 0);
112 XDefineCursor(disp, win, cs);
113 XDefineCursor(disp, w2, cs);
120 /* If we get unmapped we are done */
121 XGetWindowAttributes(disp, win, &xwa);
122 if (xwa.map_state == IsUnmapped)
125 Esnprintf(s, sizeof(s), "pix/wait%i.png", i);
126 if (EDebug(EDBUG_TYPE_SESSION) > 1)
127 Eprintf("ExtInitWinCreate - child %s\n", s);
129 im = ThemeImageLoad(s);
132 EImageRenderPixmaps(im, NULL, 0, &pmap, &mask, 0, 0);
133 EImageGetSize(im, &w, &h);
134 XShapeCombineMask(disp, w2, ShapeBounding, 0, 0, mask,
136 XSetWindowBackgroundPixmap(disp, w2, pmap);
137 EImagePixmapsFree(pmap, mask);
138 XClearWindow(disp, w2);
139 XQueryPointer(disp, win, &ww, &ww, &dd, &dd, &x, &y, &mm);
140 XMoveResizeWindow(disp, w2, x - w / 2, y - h / 2, w, h);
141 XMapWindow(disp, w2);
149 if (EDebug(EDBUG_TYPE_SESSION))
150 Eprintf("ExtInitWinMain exit\n");
158 ExtInitWinCreate(void)
160 Ecore_X_Window win_ex; /* Hmmm.. */
164 if (EDebug(EDBUG_TYPE_SESSION))
165 Eprintf("ExtInitWinCreate\n");
167 a = EInternAtom("ENLIGHTENMENT_RESTART_SCREEN");
177 if (EDebug(EDBUG_TYPE_SESSION))
178 Eprintf("ExtInitWinCreate - parent\n");
180 /* Hack to give the child some space. Not foolproof. */
183 if (ecore_x_window_prop_window_get
184 (WinGetXwin(VROOT), a, &win_ex, 1) > 0)
189 if (EDebug(EDBUG_TYPE_SESSION))
190 Eprintf("ExtInitWinCreate - parent - %#lx\n", win);
195 /* Child - Create the init window */
197 if (EDebug(EDBUG_TYPE_SESSION))
198 Eprintf("ExtInitWinCreate - child\n");
200 /* Clean up inherited stuff */
205 EDisplayDisconnect();
209 /* We will never get here */
213 static Window init_win_ext = None;
216 ExtInitWinSet(Window win)
230 if (!disp || init_win_ext == None)
233 if (EDebug(EDBUG_TYPE_SESSION))
234 Eprintf("Kill init window %#lx\n", init_win_ext);
235 XUnmapWindow(disp, init_win_ext);