2004-12-28 15:46:49 -08:00
|
|
|
/*
|
2007-01-13 11:14:29 -08:00
|
|
|
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
|
2008-03-22 07:51:24 -07:00
|
|
|
* Copyright (C) 2004-2008 Kim Woelders
|
2004-12-28 15:46:49 -08:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to
|
|
|
|
* deal in the Software without restriction, including without limitation the
|
|
|
|
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
* sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies of the Software, its documentation and marketing & publicity
|
|
|
|
* materials, and acknowledgment shall be given in the documentation, materials
|
|
|
|
* and software packages that this Software was used.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
#include "E.h"
|
2006-02-18 01:50:17 -08:00
|
|
|
#include "e16-ecore_hints.h"
|
2006-03-29 11:13:17 -08:00
|
|
|
#include "eimage.h"
|
2005-07-16 09:57:45 -07:00
|
|
|
#include "xwin.h"
|
2008-06-05 01:55:21 -07:00
|
|
|
#include <X11/extensions/shape.h>
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
static Window
|
|
|
|
ExtInitWinMain(void)
|
|
|
|
{
|
2008-03-29 03:48:45 -07:00
|
|
|
int i, err;
|
2005-02-12 08:16:29 -08:00
|
|
|
Ecore_X_Window win;
|
2004-12-28 15:46:49 -08:00
|
|
|
XGCValues gcv;
|
|
|
|
GC gc;
|
|
|
|
Pixmap pmap, mask;
|
|
|
|
Atom a;
|
|
|
|
XSetWindowAttributes attr;
|
|
|
|
|
2006-11-19 13:55:52 -08:00
|
|
|
if (EDebug(EDBUG_TYPE_SESSION))
|
2004-12-28 15:46:49 -08:00
|
|
|
Eprintf("ExtInitWinMain enter\n");
|
|
|
|
|
2008-03-29 03:48:45 -07:00
|
|
|
err = EDisplayOpen(NULL, -1);
|
|
|
|
if (err)
|
|
|
|
return None;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-05-07 04:20:02 -07:00
|
|
|
EGrabServer();
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2008-03-24 01:57:50 -07:00
|
|
|
EImageInit();
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
attr.backing_store = NotUseful;
|
|
|
|
attr.override_redirect = True;
|
2008-03-24 04:12:40 -07:00
|
|
|
attr.colormap = WinGetCmap(VROOT);
|
2004-12-28 15:46:49 -08:00
|
|
|
attr.border_pixel = 0;
|
|
|
|
attr.background_pixel = 0;
|
|
|
|
attr.save_under = True;
|
2008-03-24 04:12:40 -07:00
|
|
|
win = XCreateWindow(disp, WinGetXwin(VROOT),
|
|
|
|
0, 0, WinGetW(VROOT), WinGetH(VROOT),
|
|
|
|
0, CopyFromParent, InputOutput, CopyFromParent,
|
2004-12-28 15:46:49 -08:00
|
|
|
CWOverrideRedirect | CWSaveUnder | CWBackingStore |
|
|
|
|
CWColormap | CWBackPixel | CWBorderPixel, &attr);
|
|
|
|
|
2008-03-24 04:12:40 -07:00
|
|
|
pmap = XCreatePixmap(disp, win,
|
|
|
|
WinGetW(VROOT), WinGetH(VROOT), WinGetDepth(VROOT));
|
2004-12-28 15:46:49 -08:00
|
|
|
gcv.subwindow_mode = IncludeInferiors;
|
|
|
|
gc = XCreateGC(disp, win, GCSubwindowMode, &gcv);
|
2008-03-24 04:12:40 -07:00
|
|
|
XCopyArea(disp, WinGetXwin(VROOT), pmap, gc,
|
|
|
|
0, 0, WinGetW(VROOT), WinGetH(VROOT), 0, 0);
|
2004-12-28 15:46:49 -08:00
|
|
|
XSetWindowBackgroundPixmap(disp, win, pmap);
|
|
|
|
XMapRaised(disp, win);
|
2005-02-22 13:45:25 -08:00
|
|
|
XFreePixmap(disp, pmap);
|
|
|
|
XFreeGC(disp, gc);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2008-03-30 05:13:16 -07:00
|
|
|
a = EInternAtom("ENLIGHTENMENT_RESTART_SCREEN");
|
2008-03-24 04:12:40 -07:00
|
|
|
ecore_x_window_prop_window_set(WinGetXwin(VROOT), a, &win, 1);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
XSelectInput(disp, win, StructureNotifyMask);
|
|
|
|
|
2005-05-07 04:20:02 -07:00
|
|
|
EUngrabServer();
|
2008-02-13 13:31:29 -08:00
|
|
|
ESync(0);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
{
|
|
|
|
Window w2, ww;
|
2005-07-17 05:55:13 -07:00
|
|
|
char s[1024];
|
2006-03-29 11:13:17 -08:00
|
|
|
EImage *im;
|
|
|
|
int dd, x, y, w, h;
|
2004-12-28 15:46:49 -08:00
|
|
|
unsigned int mm;
|
|
|
|
Cursor cs = 0;
|
|
|
|
XColor cl;
|
2008-06-16 14:20:42 -07:00
|
|
|
XWindowAttributes xwa;
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-03-02 11:20:27 -08:00
|
|
|
w2 = XCreateWindow(disp, win, 0, 0, 32, 32, 0, CopyFromParent,
|
|
|
|
InputOutput, CopyFromParent,
|
2004-12-28 15:46:49 -08:00
|
|
|
CWOverrideRedirect | CWBackingStore | CWColormap |
|
|
|
|
CWBackPixel | CWBorderPixel, &attr);
|
|
|
|
|
2005-02-22 13:45:25 -08:00
|
|
|
pmap = XCreatePixmap(disp, w2, 16, 16, 1);
|
|
|
|
gc = XCreateGC(disp, pmap, 0, NULL);
|
2004-12-28 15:46:49 -08:00
|
|
|
XSetForeground(disp, gc, 0);
|
|
|
|
XFillRectangle(disp, pmap, gc, 0, 0, 16, 16);
|
2005-02-22 13:45:25 -08:00
|
|
|
XFreeGC(disp, gc);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
2005-02-22 13:45:25 -08:00
|
|
|
mask = XCreatePixmap(disp, w2, 16, 16, 1);
|
|
|
|
gc = XCreateGC(disp, mask, 0, NULL);
|
2004-12-28 15:46:49 -08:00
|
|
|
XSetForeground(disp, gc, 0);
|
|
|
|
XFillRectangle(disp, mask, gc, 0, 0, 16, 16);
|
2005-02-22 13:45:25 -08:00
|
|
|
XFreeGC(disp, gc);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
cs = XCreatePixmapCursor(disp, pmap, mask, &cl, &cl, 0, 0);
|
|
|
|
XDefineCursor(disp, win, cs);
|
|
|
|
XDefineCursor(disp, w2, cs);
|
|
|
|
|
|
|
|
for (i = 1;; i++)
|
|
|
|
{
|
|
|
|
if (i > 12)
|
|
|
|
i = 1;
|
|
|
|
|
2008-06-16 14:20:42 -07:00
|
|
|
/* If we get unmapped we are done */
|
|
|
|
XGetWindowAttributes(disp, win, &xwa);
|
|
|
|
if (xwa.map_state == IsUnmapped)
|
|
|
|
break;
|
|
|
|
|
2004-12-28 15:46:49 -08:00
|
|
|
Esnprintf(s, sizeof(s), "pix/wait%i.png", i);
|
2007-12-08 06:01:27 -08:00
|
|
|
if (EDebug(EDBUG_TYPE_SESSION) > 1)
|
2004-12-28 15:46:49 -08:00
|
|
|
Eprintf("ExtInitWinCreate - child %s\n", s);
|
|
|
|
|
2006-12-28 09:44:42 -08:00
|
|
|
im = ThemeImageLoad(s);
|
2004-12-28 15:46:49 -08:00
|
|
|
if (im)
|
|
|
|
{
|
2007-04-06 15:20:07 -07:00
|
|
|
EImageRenderPixmaps(im, NULL, 0, &pmap, &mask, 0, 0);
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageGetSize(im, &w, &h);
|
2005-02-02 09:12:07 -08:00
|
|
|
XShapeCombineMask(disp, w2, ShapeBounding, 0, 0, mask,
|
2004-12-28 15:46:49 -08:00
|
|
|
ShapeSet);
|
2005-02-02 09:12:07 -08:00
|
|
|
XSetWindowBackgroundPixmap(disp, w2, pmap);
|
2007-12-15 08:29:22 -08:00
|
|
|
EImagePixmapsFree(pmap, mask);
|
2004-12-28 15:46:49 -08:00
|
|
|
XClearWindow(disp, w2);
|
|
|
|
XQueryPointer(disp, win, &ww, &ww, &dd, &dd, &x, &y, &mm);
|
2006-03-29 11:13:17 -08:00
|
|
|
XMoveResizeWindow(disp, w2, x - w / 2, y - h / 2, w, h);
|
2005-02-02 09:12:07 -08:00
|
|
|
XMapWindow(disp, w2);
|
2006-03-29 11:13:17 -08:00
|
|
|
EImageFree(im);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
2008-06-16 14:20:42 -07:00
|
|
|
usleep(50000);
|
2008-02-13 13:31:29 -08:00
|
|
|
ESync(0);
|
2004-12-28 15:46:49 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-19 13:55:52 -08:00
|
|
|
if (EDebug(EDBUG_TYPE_SESSION))
|
2004-12-28 15:46:49 -08:00
|
|
|
Eprintf("ExtInitWinMain exit\n");
|
|
|
|
|
2005-05-07 04:20:02 -07:00
|
|
|
EDisplayClose();
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
Window
|
|
|
|
ExtInitWinCreate(void)
|
|
|
|
{
|
2005-02-12 08:16:29 -08:00
|
|
|
Ecore_X_Window win_ex; /* Hmmm.. */
|
2004-12-28 15:46:49 -08:00
|
|
|
Window win;
|
|
|
|
Atom a;
|
|
|
|
|
2006-11-19 13:55:52 -08:00
|
|
|
if (EDebug(EDBUG_TYPE_SESSION))
|
2004-12-28 15:46:49 -08:00
|
|
|
Eprintf("ExtInitWinCreate\n");
|
|
|
|
|
2008-03-30 05:13:16 -07:00
|
|
|
a = EInternAtom("ENLIGHTENMENT_RESTART_SCREEN");
|
2008-02-13 13:31:29 -08:00
|
|
|
ESync(0);
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
if (fork())
|
|
|
|
{
|
|
|
|
/* Parent */
|
2005-05-07 04:20:02 -07:00
|
|
|
EUngrabServer();
|
2004-12-28 15:46:49 -08:00
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
2006-11-19 13:55:52 -08:00
|
|
|
if (EDebug(EDBUG_TYPE_SESSION))
|
2004-12-28 15:46:49 -08:00
|
|
|
Eprintf("ExtInitWinCreate - parent\n");
|
|
|
|
|
|
|
|
/* Hack to give the child some space. Not foolproof. */
|
|
|
|
sleep(1);
|
|
|
|
|
2008-03-24 04:12:40 -07:00
|
|
|
if (ecore_x_window_prop_window_get
|
|
|
|
(WinGetXwin(VROOT), a, &win_ex, 1) > 0)
|
2004-12-28 15:46:49 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-02-12 08:16:29 -08:00
|
|
|
win = win_ex;
|
2006-11-19 13:55:52 -08:00
|
|
|
if (EDebug(EDBUG_TYPE_SESSION))
|
2004-12-28 15:46:49 -08:00
|
|
|
Eprintf("ExtInitWinCreate - parent - %#lx\n", win);
|
|
|
|
|
|
|
|
return win;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Child - Create the init window */
|
|
|
|
|
2006-11-19 13:55:52 -08:00
|
|
|
if (EDebug(EDBUG_TYPE_SESSION))
|
2004-12-28 15:46:49 -08:00
|
|
|
Eprintf("ExtInitWinCreate - child\n");
|
|
|
|
|
|
|
|
/* Clean up inherited stuff */
|
|
|
|
|
|
|
|
SignalsRestore();
|
|
|
|
|
2008-09-18 10:39:13 -07:00
|
|
|
EImageExit(0);
|
2004-12-28 15:46:49 -08:00
|
|
|
EDisplayDisconnect();
|
|
|
|
|
|
|
|
ExtInitWinMain();
|
|
|
|
|
|
|
|
/* We will never get here */
|
|
|
|
return None;
|
|
|
|
}
|
2005-04-23 06:35:37 -07:00
|
|
|
|
|
|
|
static Window init_win_ext = None;
|
|
|
|
|
|
|
|
void
|
|
|
|
ExtInitWinSet(Window win)
|
|
|
|
{
|
|
|
|
init_win_ext = win;
|
|
|
|
}
|
|
|
|
|
|
|
|
Window
|
|
|
|
ExtInitWinGet(void)
|
|
|
|
{
|
|
|
|
return init_win_ext;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ExtInitWinKill(void)
|
|
|
|
{
|
|
|
|
if (!disp || init_win_ext == None)
|
|
|
|
return;
|
|
|
|
|
2006-11-19 13:55:52 -08:00
|
|
|
if (EDebug(EDBUG_TYPE_SESSION))
|
2005-04-23 06:35:37 -07:00
|
|
|
Eprintf("Kill init window %#lx\n", init_win_ext);
|
2008-06-16 14:20:42 -07:00
|
|
|
XUnmapWindow(disp, init_win_ext);
|
2005-04-23 06:35:37 -07:00
|
|
|
init_win_ext = None;
|
|
|
|
}
|