Nested E. Maybe not really useful (yet?) but good for debugging and fun toy.

SVN revision: 10650
This commit is contained in:
Kim Woelders 2004-06-30 13:04:18 +00:00
parent 64ff89be92
commit a68bf02ad8
13 changed files with 185 additions and 49 deletions

View File

@ -24,12 +24,20 @@
#include "E.h"
char waitonly;
Window root_win;
void
CommsSetup()
{
char *str;
EDBUG(5, "CommsSetup");
my_win = XCreateSimpleWindow(disp, root.win, -100, -100, 5, 5, 0, 0, 0);
str = getenv("ENL_WM_ROOT");
root_win = (str) ? strtoul(str, NULL, 0) : root.win;
my_win = XCreateSimpleWindow(disp, root_win, -100, -100, 5, 5, 0, 0, 0);
EDBUG_RETURN_;
}
@ -49,7 +57,7 @@ CommsFindCommsWindow()
if (a != None)
{
s = NULL;
XGetWindowProperty(disp, root.win, a, 0, 14, False, AnyPropertyType,
XGetWindowProperty(disp, root_win, a, 0, 14, False, AnyPropertyType,
&ar, &format, &num, &after, &s);
if (s)
{

20
src/E.h
View File

@ -643,7 +643,7 @@ typedef struct _client
}
Client;
typedef struct _root
typedef struct
{
Window win;
Visual *vis;
@ -652,7 +652,18 @@ typedef struct _root
int scr;
int w, h;
}
Root;
RealRoot;
typedef struct
{
Window win;
Visual *vis;
int depth;
Colormap cmap;
int scr;
int w, h;
}
VirtRoot;
typedef struct _modcurve
{
@ -1301,6 +1312,7 @@ typedef struct
{
char master; /* We are the master E */
char single; /* No slaves */
char window; /* Running in virtual root window */
pid_t master_pid;
int master_screen;
char startup;
@ -1785,6 +1797,7 @@ EWin *AddInternalToFamily(Window win, const char *bname, int type,
void (*init) (EWin * ewin, void *ptr));
void HonorIclass(char *s, int id);
void EwinWithdraw(EWin * ewin);
void EwinReparent(EWin * ewin, Window parent);
void SyncBorderToEwin(EWin * ewin);
void BorderWinpartChange(EWin * ewin, int i, int force);
void EwinBorderUpdateInfo(EWin * ewin);
@ -2874,7 +2887,8 @@ extern Imlib_Context *prImlib_Context;
extern FnlibData *pFnlibData;
#endif
extern List *lists;
extern Root VRoot;
extern RealRoot RRoot;
extern VirtRoot VRoot;
extern EConf Conf;
extern EMode Mode;
extern Desktops desks;

View File

@ -1427,6 +1427,8 @@ EwinDestroy(EWin * ewin)
EwinListDelete(&EwinListStack, ewin);
EwinListDelete(&EwinListFocus, ewin);
XSelectInput(disp, ewin->client.win, 0);
HintsSetClientList();
UnmatchEwinToSnapInfo(ewin);
@ -1434,8 +1436,6 @@ EwinDestroy(EWin * ewin)
if (ewin->iconified > 0)
RemoveMiniIcon(ewin);
HintsDelWindowHints(ewin);
lst = EwinListTransientFor(ewin, &num);
for (i = 0; i < num; i++)
{
@ -1499,6 +1499,14 @@ EwinWithdraw(EWin * ewin)
ewin->client.y);
ICCCM_Withdraw(ewin);
HintsDelWindowHints(ewin);
EwinDestroy(ewin);
}
void
EwinReparent(EWin * ewin, Window parent)
{
EReparentWindow(disp, ewin->client.win, parent, 0, 0);
EwinDestroy(ewin);
}
@ -3489,8 +3497,6 @@ BorderWinpartEventMouseDown(XEvent * ev, EWin * ewin, int j)
static void
BorderWinpartEventMouseUp(XEvent * ev, EWin * ewin, int j)
{
Window win2;
if ((ewin->bits[j].state == STATE_CLICKED) && (!ewin->bits[j].left))
ewin->bits[j].state = STATE_HILITED;
else
@ -3498,8 +3504,7 @@ BorderWinpartEventMouseUp(XEvent * ev, EWin * ewin, int j)
ewin->bits[j].left = 0;
BorderWinpartChange(ewin, j, 0);
win2 = WindowAtXY(ev->xbutton.x_root, ev->xbutton.y_root);
if (win2 == Mode.context_win && (ewin->border->part[j].aclass))
if (ewin->bits[j].win == Mode.context_win && ewin->border->part[j].aclass)
EventAclass(ev, ewin, ewin->border->part[j].aclass);
}

View File

@ -22,17 +22,14 @@
*/
#include "E.h"
static ToolTip *ttip = NULL;
static void ToolTipTimeout(int val, void *data);
static char sentpress = 0;
static ToolTip *ttip = NULL;
static void
ToolTipTimeout(int val, void *data)
{
int x, y, dum;
unsigned int mask;
Window win, rt, ch;
ActionClass *ac;
@ -42,12 +39,14 @@ ToolTipTimeout(int val, void *data)
/* In the case of multiple screens, check to make sure
* the root window is still where the mouse is... */
if (False ==
XQueryPointer(disp, VRoot.win, &rt, &ch, &x, &y, &dum, &dum, &mask))
XQueryPointer(disp, VRoot.win, &rt, &ch, &dum, &dum, &x, &y, &mask))
EDBUG_RETURN_;
/* dont pop up tooltip is mouse button down */
if (mask &
(Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask))
EDBUG_RETURN_;
win = WindowAtXY(x, y);
ac = FindActionClass(win);
if (!ac)
@ -92,6 +91,23 @@ TooltipsHandleEvent(void)
DoIn("TOOLTIP_TIMEOUT", Conf.tooltips.delay, ToolTipTimeout, 0, NULL);
}
static void
ModeGetXY(Window rwin, int rx, int ry)
{
Window child;
if (Mode.wm.window)
{
XTranslateCoordinates(disp, rwin, VRoot.win,
rx, ry, &Mode.x, &Mode.y, &child);
}
else
{
Mode.x = rx;
Mode.y = ry;
}
}
void
HandleKeyPress(XEvent * ev)
{
@ -167,8 +183,7 @@ HandleMouseDown(XEvent * ev)
Mode.last_button = ev->xbutton.button;
Mode.last_bpress = win;
Mode.x = ev->xbutton.x_root;
Mode.y = ev->xbutton.y_root;
ModeGetXY(ev->xbutton.root, ev->xbutton.x_root, ev->xbutton.y_root);
desk_click = -1;
for (i = 0; i < Conf.desks.num; i++)
@ -256,8 +271,7 @@ HandleMouseUp(XEvent * ev)
TooltipsHandleEvent();
UnGrabTheButtons();
Mode.x = ev->xbutton.x_root;
Mode.y = ev->xbutton.y_root;
ModeGetXY(ev->xbutton.root, ev->xbutton.x_root, ev->xbutton.y_root);
pslideout = Mode.slideout;
@ -344,10 +358,11 @@ HandleMotion(XEvent * ev)
TooltipsHandleEvent();
EdgeHandleMotion(ev);
Mode.px = Mode.x;
Mode.py = Mode.y;
Mode.x = ev->xmotion.x_root;
Mode.y = ev->xmotion.y_root;
ModeGetXY(ev->xmotion.root, ev->xmotion.x_root, ev->xmotion.y_root);
desks.current = DesktopAt(Mode.x, Mode.y);
if ((!(ev->xmotion.state

View File

@ -42,7 +42,8 @@ Drawable vIcDrw;
FnlibData *pFnlibData;
#endif
List *lists;
Root VRoot;
RealRoot RRoot;
VirtRoot VRoot;
EConf Conf;
EMode Mode;
Desktops desks;

View File

@ -296,7 +296,7 @@ void
HintsProcessPropertyChange(EWin * ewin, Atom atom_change)
{
EDBUG(6, "HintsHandlePropertyChange");
#if ENABLE_GNOME
#if 0 /* No! - ENABLE_GNOME */
GNOME_GetHints(ewin, atom_change);
#endif
#if ENABLE_EWMH

View File

@ -62,12 +62,19 @@ ICCCM_Init(void)
E_XA_WM_HINTS = XInternAtom(disp, "WM_HINTS", False);
E_XA_WM_CLIENT_LEADER = XInternAtom(disp, "WM_CLIENT_LEADER", False);
E_XA_WM_TRANSIENT_FOR = XInternAtom(disp, "WM_TRANSIENT_FOR", False);
if (Mode.wm.window)
{
Atom wm_props[1] = { E_XA_WM_DELETE_WINDOW };
XSetWMProtocols(disp, VRoot.win, wm_props, 1);
}
}
void
ICCCM_ProcessClientMessage(XClientMessageEvent * event)
{
EWin *ewin;
Atom a;
if (event->message_type == E_XA_WM_CHANGE_STATE)
{
@ -81,6 +88,12 @@ ICCCM_ProcessClientMessage(XClientMessageEvent * event)
IconifyEwin(ewin);
}
}
else if (event->message_type == E_XA_WM_PROTOCOLS)
{
a = event->data.l[0];
if (a == E_XA_WM_DELETE_WINDOW)
SessionExit(NULL);
}
}
void
@ -318,6 +331,7 @@ ICCCM_Configure(EWin * ewin)
XEvent ev;
XWindowChanges xwc;
int d;
Window child;
EDBUG(6, "ICCCM_Configure");
@ -358,6 +372,10 @@ ICCCM_Configure(EWin * ewin)
ev.xconfigure.window = ewin->client.win;
ev.xconfigure.x = desks.desk[d].x + ewin->client.x;
ev.xconfigure.y = desks.desk[d].y + ewin->client.y;
if (Mode.wm.window)
XTranslateCoordinates(disp, VRoot.win, RRoot.win,
ev.xconfigure.x, ev.xconfigure.y,
&ev.xconfigure.x, &ev.xconfigure.y, &child);
ev.xconfigure.width = ewin->client.w;
ev.xconfigure.height = ewin->client.h;
ev.xconfigure.border_width = 0;

View File

@ -5873,6 +5873,26 @@ IPC_MiscInfo(const char *params __UNUSED__, Client * c)
CommsSend(c, buf);
}
static void
IPC_Reparent(const char *params, Client * c __UNUSED__)
{
char param1[FILEPATH_LEN_MAX];
char param2[FILEPATH_LEN_MAX];
EWin *ewin, *enew;
if (params == NULL)
return;
sscanf(params, "%100s %100s", param1, param2);
ewin = IpcFindEwin(param1);
enew = IpcFindEwin(param2);
if (!ewin || !enew)
IpcPrintf("No matching client or target EWin found\n");
else
EwinReparent(ewin, enew->client.win);
}
/* the IPC Array */
/* the format of an IPC member of the IPC array is as follows:
@ -6383,6 +6403,11 @@ IPCStruct IPCArray[] = {
IPC_EwinInfo2, "win_info", "wi", "Show client window info", NULL},
{
IPC_MiscInfo, "dump_info", NULL, "TBD", NULL},
{
IPC_Reparent,
"reparent", "rep",
"Reparent window",
"usage:\n" " reparent <windowid> <new parent>"},
};
/* The IPC Handler */

View File

@ -151,6 +151,12 @@ main(int argc, char **argv)
{
no_overwrite = 1;
}
else if ((!strcmp("-window", argv[j])) && (argc - j > 1))
{
sscanf(argv[++j], "%dx%d", &VRoot.w, &VRoot.h);
Mode.wm.window = 1;
Mode.wm.single = 1;
}
else if ((!strcmp("-h", argv[j])) || (!strcmp("-help", argv[j])) ||
(!strcmp("-?", argv[j])) || (!strcmp("--help", argv[j])))
{

View File

@ -262,15 +262,6 @@ MenuShow(Menu * m, char noshow)
GetWinWH(m->items[0]->win, &w, &h);
GetWinWH(m->win, &mw, &mh);
if (!Mode.button)
{
int dum;
Window rt, ch;
XQueryPointer(disp, m->win, &rt, &ch, &(Mode.x), &(Mode.y), &dum, &dum,
(unsigned int *)&dum);
}
wx = 0;
wy = 0;
if (Conf.menusonscreen)

View File

@ -24,7 +24,7 @@
#include "E.h"
#ifdef HAS_XINERAMA
char xinerama_active;
char xinerama_active = 0;
static XineramaScreenInfo *screens = NULL;
static int num_screens = 0;
#endif
@ -32,6 +32,8 @@ static int num_screens = 0;
void
ScreenInit(void)
{
if (Mode.wm.window)
return;
#ifdef HAS_XINERAMA
xinerama_active = XineramaIsActive(disp);
Conf.extra_head = 0;

View File

@ -133,14 +133,17 @@ static char *
default_save_prefix(void)
{
static char *def_prefix = NULL;
char s[1024];
if (!def_prefix)
{
char s[1024];
if (def_prefix)
return def_prefix;
if (Mode.wm.window)
Esnprintf(s, sizeof(s), "%s/...e_session-window", EDirUser());
else
Esnprintf(s, sizeof(s), "%s/...e_session-XXXXXX", EDirUser());
def_prefix = Estrdup(s);
Esnprintf(s, sizeof(s), "%s/...e_session-XXXXXX", EDirUser());
def_prefix = Estrdup(s);
}
return def_prefix;
}

View File

@ -111,10 +111,13 @@ MapUnmap(int start)
EDBUG_RETURN_;
}
/*
* This function sets up all of our connections to X
*/
void
SetupX(void)
{
/* This function sets up all of our connections to X */
char buf[128];
EDBUG(6, "SetupX");
@ -209,13 +212,58 @@ SetupX(void)
XSetIOErrorHandler((XIOErrorHandler) HandleXIOError);
/* Root defaults */
VRoot.scr = DefaultScreen(disp);
VRoot.win = DefaultRootWindow(disp);
VRoot.vis = DefaultVisual(disp, VRoot.scr);
VRoot.depth = DefaultDepth(disp, VRoot.scr);
VRoot.cmap = DefaultColormap(disp, VRoot.scr);
VRoot.w = DisplayWidth(disp, VRoot.scr);
VRoot.h = DisplayHeight(disp, VRoot.scr);
RRoot.scr = DefaultScreen(disp);
RRoot.win = DefaultRootWindow(disp);
RRoot.vis = DefaultVisual(disp, RRoot.scr);
RRoot.depth = DefaultDepth(disp, RRoot.scr);
RRoot.cmap = DefaultColormap(disp, RRoot.scr);
RRoot.w = DisplayWidth(disp, RRoot.scr);
RRoot.h = DisplayHeight(disp, RRoot.scr);
VRoot.win = RRoot.win;
VRoot.vis = RRoot.vis;
VRoot.depth = RRoot.depth;
VRoot.cmap = RRoot.cmap;
if (Mode.wm.window)
{
XSetWindowAttributes attr;
XClassHint *xch;
XTextProperty xtp;
/* Running E in its own virtual root window */
attr.backing_store = NotUseful;
attr.override_redirect = False;
attr.colormap = VRoot.cmap;
attr.border_pixel = 0;
attr.background_pixel = 0;
attr.save_under = True;
VRoot.win = XCreateWindow(disp, RRoot.win, 0, 0, VRoot.w, VRoot.h, 0,
VRoot.depth, InputOutput, VRoot.vis,
CWOverrideRedirect | CWSaveUnder |
CWBackingStore | CWColormap | CWBackPixel |
CWBorderPixel, &attr);
xtp.encoding = XA_STRING;
xtp.format = 8;
xtp.value = (unsigned char *)("Enlightenment");
xtp.nitems = strlen((char *)(xtp.value));
XSetWMName(disp, VRoot.win, &xtp);
xch = XAllocClassHint();
xch->res_name = (char *)"Virtual-Root";
xch->res_class = (char *)"Enlightenment";
XSetClassHint(disp, VRoot.win, xch);
XFree(xch);
}
else
{
/* Running E normally on the root window */
VRoot.w = RRoot.w;
VRoot.h = RRoot.h;
}
Esnprintf(buf, sizeof(buf), "%#lx", VRoot.win);
Esetenv("ENL_WM_ROOT", buf, 1);
/* initialise imlib */
#if USE_IMLIB2