From b780491887cd889e9455c5fb8b529f3dbeb44073 Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Sun, 30 Mar 2008 12:13:16 +0000 Subject: [PATCH] Rewrap more X stuff. SVN revision: 34149 --- src/E.h | 2 +- src/Makefile.am | 1 + src/aclass.c | 6 ++-- src/alert.c | 7 ++-- src/borders.c | 2 +- src/buttons.c | 4 +-- src/comms.c | 2 +- src/desktops.c | 5 ++- src/dialog.c | 6 ++-- src/eimage.c | 24 ++++--------- src/eimage.h | 2 +- src/events.c | 2 +- src/events.h | 4 ++- src/extinitwin.c | 4 +-- src/fx.c | 4 +-- src/gnome.c | 88 ++++++++++++++++++++++++------------------------ src/grabs.c | 1 + src/grabs.h | 4 +-- src/hints.c | 2 +- src/icccm.c | 2 +- src/iclass.c | 14 ++++---- src/ipc.c | 6 ++-- src/lang.c | 1 + src/main.c | 2 +- src/mwm.c | 4 +-- src/pager.c | 4 +-- src/piximg.h | 1 + src/session.c | 4 +-- src/setup.c | 4 +-- src/systray.c | 10 +++--- src/x.c | 85 +++++++++++++++++++++++++++++++++++++++++++--- src/xtypes.h | 28 +++++++++++++++ src/xwin.h | 41 +++++++++++----------- 33 files changed, 236 insertions(+), 140 deletions(-) create mode 100644 src/xtypes.h diff --git a/src/E.h b/src/E.h index 976c560e..0286db92 100644 --- a/src/E.h +++ b/src/E.h @@ -65,7 +65,7 @@ #define USE_GLX 1 #endif -#include "xwin.h" +#include "xtypes.h" #define ENABLE_COLOR_MODIFIERS 0 /* Not functional */ #define ENABLE_DESKRAY 0 /* Not functional */ diff --git a/src/Makefile.am b/src/Makefile.am index a1c938fb..9d102a1a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -106,6 +106,7 @@ e16_SOURCES = \ warp.c \ windowmatch.c windowmatch.h \ x.c xwin.h \ + xtypes.h \ zoom.c \ $(MODULE_SRCS) \ $(SRCS_GNOME) \ diff --git a/src/aclass.c b/src/aclass.c index 171f77c3..ebf095fd 100644 --- a/src/aclass.c +++ b/src/aclass.c @@ -99,7 +99,7 @@ ActionCreate(char event, char anymod, int mod, int anybut, int but, if (!key || !key[0] || (event != EVENT_KEY_DOWN && event != EVENT_KEY_UP)) aa->key = 0; else - aa->key = XKeysymToKeycode(disp, XStringToKeysym(key)); + aa->key = EKeynameToKeycode(key); aa->key_str = (aa->key) ? Estrdup(key) : NULL; aa->tooltipstring = (tooltipstring) ? Estrdup((tooltipstring[0]) ? tooltipstring : "?!?") : @@ -1242,9 +1242,9 @@ IPC_KeybindingsGet(const char *params __UNUSED__) aa = ac->list[i]; if ((aa) && (aa->action) && (aa->event == EVENT_KEY_DOWN)) { - char *key; + const char *key; - key = XKeysymToString(XKeycodeToKeysym(disp, aa->key, 0)); + key = EKeycodeToString(aa->key, 0); if (!key) continue; diff --git a/src/alert.c b/src/alert.c index 3acb25b6..83184d1c 100644 --- a/src/alert.c +++ b/src/alert.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "alert.h" #include "lang.h" #include "session.h" @@ -382,7 +383,7 @@ ShowAlert(const char *title, switch (ev.type) { case KeyPress: - key = XKeysymToKeycode(dd, XStringToKeysym("F1")); + key = XKeysymToKeycode(dd, XK_F1); if (key == ev.xkey.keycode) { DRAW_BOX_IN(dd, gc, b1, 0, 0, mh + 10, fh + 10); @@ -392,7 +393,7 @@ ShowAlert(const char *title, button = 1; break; } - key = XKeysymToKeycode(dd, XStringToKeysym("F2")); + key = XKeysymToKeycode(dd, XK_F2); if (key == ev.xkey.keycode) { DRAW_BOX_IN(dd, gc, b2, 0, 0, mh + 10, fh + 10); @@ -402,7 +403,7 @@ ShowAlert(const char *title, button = 2; break; } - key = XKeysymToKeycode(dd, XStringToKeysym("F3")); + key = XKeysymToKeycode(dd, XK_F3); if (key == ev.xkey.keycode) { DRAW_BOX_IN(dd, gc, b3, 0, 0, mh + 10, fh + 10); diff --git a/src/borders.c b/src/borders.c index 12454c59..859c1a96 100644 --- a/src/borders.c +++ b/src/borders.c @@ -558,7 +558,7 @@ EwinBorderSetTo(EWin * ewin, const Border * b) if (!b->part[i].ontop) wl[j++] = WinGetXwin(ewin->bits[i].win); } - XRestackWindows(disp, wl, j); + EXRestackWindows(wl, j); Efree(wl); } diff --git a/src/buttons.c b/src/buttons.c index 858ee46b..e8bcac0d 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -494,7 +494,7 @@ ButtonEventMouseDown(Button * b, XEvent * ev) Window win = ev->xbutton.window; ev->xbutton.window = b->inside_win; - XSendEvent(disp, b->inside_win, False, ButtonPressMask, ev); + EXSendEvent(b->inside_win, ButtonPressMask, ev); ev->xbutton.window = win; } @@ -522,7 +522,7 @@ ButtonEventMouseUp(Button * b, XEvent * ev) Window win = ev->xbutton.window; ev->xbutton.window = b->inside_win; - XSendEvent(disp, b->inside_win, False, ButtonReleaseMask, ev); + EXSendEvent(b->inside_win, ButtonReleaseMask, ev); ev->xbutton.window = win; } diff --git a/src/comms.c b/src/comms.c index c70d1727..29dd6bae 100644 --- a/src/comms.c +++ b/src/comms.c @@ -327,7 +327,7 @@ CommsDoSend(Window win, const char *s) ss[20] = 0; for (k = 0; k < 20; k++) ev.xclient.data.b[k] = ss[k]; - XSendEvent(disp, win, False, 0, (XEvent *) & ev); + EXSendEvent(win, 0, (XEvent *) & ev); } } diff --git a/src/desktops.c b/src/desktops.c index ae422107..c5c7bcdb 100644 --- a/src/desktops.c +++ b/src/desktops.c @@ -1439,7 +1439,7 @@ DeskRestack(Desk * dsk) EXWindowGetParent(wl[i])); } - XRestackWindows(disp, wl, tot); + EXRestackWindows(wl, tot); Efree(wl); @@ -1737,8 +1737,7 @@ static void ButtonProxySendEvent(XEvent * ev) { if (Mode.button_proxy_win) - XSendEvent(disp, Mode.button_proxy_win, False, SubstructureNotifyMask, - ev); + EXSendEvent(Mode.button_proxy_win, SubstructureNotifyMask, ev); } static void diff --git a/src/dialog.c b/src/dialog.c index 20700356..e78b62c4 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -213,8 +213,7 @@ DialogBindKey(Dialog * d, const char *key, DialogCallbackFunc * func, int val, d->keybindings[d->num_bindings - 1].val = val; d->keybindings[d->num_bindings - 1].func = func; d->keybindings[d->num_bindings - 1].data = data; - d->keybindings[d->num_bindings - 1].key = - XKeysymToKeycode(disp, XStringToKeysym(key)); + d->keybindings[d->num_bindings - 1].key = EKeynameToKeycode(key); } void @@ -1734,8 +1733,7 @@ DialogUpdate(Dialog * d) if (d->item) DialogDrawItem(d, d->item); if (d->xu1 < d->xu2 && d->yu1 < d->yu2) - EClearArea(d->win, d->xu1, d->yu1, d->xu2 - d->xu1, d->yu2 - d->yu1, - False); + EClearArea(d->win, d->xu1, d->yu1, d->xu2 - d->xu1, d->yu2 - d->yu1); d->update = 0; d->xu1 = d->yu1 = 99999; d->xu2 = d->yu2 = 0; diff --git a/src/eimage.c b/src/eimage.c index 3e266f2a..af8f5e4f 100644 --- a/src/eimage.c +++ b/src/eimage.c @@ -28,27 +28,17 @@ #include #endif -static Window _default_draw; -static Visual *_default_vis; -static Colormap _default_cmap; - void EImageInit(void) { - Display *dpy = disp; - imlib_set_cache_size(2048 * 1024); imlib_set_font_cache_size(512 * 1024); imlib_set_color_usage(128); - _default_draw = DefaultRootWindow(dpy); - _default_vis = DefaultVisual(dpy, DefaultScreen(dpy)); - _default_cmap = DefaultColormap(dpy, DefaultScreen(dpy)); - - imlib_context_set_display(dpy); - imlib_context_set_visual(_default_vis); - imlib_context_set_colormap(_default_cmap); + imlib_context_set_display(disp); + imlib_context_set_visual(WinGetVisual(VROOT)); + imlib_context_set_colormap(WinGetCmap(VROOT)); #ifdef HAVE_IMLIB_CONTEXT_SET_MASK_ALPHA_THRESHOLD imlib_context_set_mask_alpha_threshold(Conf.testing.mask_alpha_threshold); @@ -402,7 +392,7 @@ EImageGrabDrawableScaled(Win win, Drawable draw, Pixmap mask, get_mask_from_shape); if (vis) - imlib_context_set_visual(_default_vis); + imlib_context_set_visual(WinGetVisual(VROOT)); return im; } @@ -426,7 +416,7 @@ EImageRenderOnDrawable(EImage * im, Win win, Drawable draw, int flags, _EImageFlagsReset(); if (vis) - imlib_context_set_visual(_default_vis); + imlib_context_set_visual(WinGetVisual(VROOT)); } void @@ -437,7 +427,7 @@ EImageRenderPixmaps(EImage * im, Win win, int flags, Pixmap m; imlib_context_set_image(im); - imlib_context_set_drawable((win) ? WinGetXwin(win) : _default_draw); + imlib_context_set_drawable((win) ? WinGetXwin(win) : WinGetXwin(VROOT)); vis = (win) ? WinGetVisual(win) : NULL; if (vis) imlib_context_set_visual(vis); @@ -458,7 +448,7 @@ EImageRenderPixmaps(EImage * im, Win win, int flags, _EImageFlagsReset(); if (vis) - imlib_context_set_visual(_default_vis); + imlib_context_set_visual(WinGetVisual(VROOT)); } void diff --git a/src/eimage.h b/src/eimage.h index 10678af3..923a1414 100644 --- a/src/eimage.h +++ b/src/eimage.h @@ -24,7 +24,7 @@ #define _EIMAGE_H_ #include -#include "xwin.h" +#include "xtypes.h" typedef void EImage; typedef void EImageColorModifier; diff --git a/src/events.c b/src/events.c index 10988bb1..004aca1c 100644 --- a/src/events.c +++ b/src/events.c @@ -313,7 +313,7 @@ HandleEvent(XEvent * ev) CurrentTime); ESync(); ev->xkey.time = CurrentTime; - XSendEvent(disp, ev->xkey.root, False, 0, ev); + EXSendEvent(ev->xkey.root, 0, ev); return; } #endif diff --git a/src/events.h b/src/events.h index cf654a6f..794c9252 100644 --- a/src/events.h +++ b/src/events.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2006-2007 Kim Woelders + * Copyright (C) 2006-2008 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -23,6 +23,8 @@ #ifndef _EVENTS_H_ #define _EVENTS_H_ +#include + /* Re-mapped X-events */ #define EX_EVENT_CREATE_GONE 64 #define EX_EVENT_UNMAP_GONE 65 diff --git a/src/extinitwin.c b/src/extinitwin.c index fd24d621..b8433ded 100644 --- a/src/extinitwin.c +++ b/src/extinitwin.c @@ -72,7 +72,7 @@ ExtInitWinMain(void) XFreePixmap(disp, pmap); XFreeGC(disp, gc); - a = XInternAtom(disp, "ENLIGHTENMENT_RESTART_SCREEN", False); + a = EInternAtom("ENLIGHTENMENT_RESTART_SCREEN"); ecore_x_window_prop_window_set(WinGetXwin(VROOT), a, &win, 1); XSelectInput(disp, win, StructureNotifyMask); @@ -160,7 +160,7 @@ ExtInitWinCreate(void) if (EDebug(EDBUG_TYPE_SESSION)) Eprintf("ExtInitWinCreate\n"); - a = XInternAtom(disp, "ENLIGHTENMENT_RESTART_SCREEN", False); + a = EInternAtom("ENLIGHTENMENT_RESTART_SCREEN"); ESync(0); if (fork()) diff --git a/src/fx.c b/src/fx.c index cd9c96bf..a99be0f0 100644 --- a/src/fx.c +++ b/src/fx.c @@ -139,7 +139,7 @@ FX_Ripple_Quit(void) { RemoveTimerEvent("FX_RIPPLE_TIMEOUT"); EClearArea(fx_ripple_win, 0, WinGetH(VROOT) - fx_ripple_waterh, - WinGetW(VROOT), fx_ripple_waterh, False); + WinGetW(VROOT), fx_ripple_waterh); } static void @@ -579,7 +579,7 @@ FX_Waves_Quit(void) { RemoveTimerEvent("FX_WAVE_TIMEOUT"); EClearArea(fx_wave_win, 0, WinGetH(VROOT) - FX_WAVE_WATERH, - WinGetW(VROOT), FX_WAVE_WATERH, False); + WinGetW(VROOT), FX_WAVE_WATERH); } static void diff --git a/src/gnome.c b/src/gnome.c index 26147fc0..8f07b335 100644 --- a/src/gnome.c +++ b/src/gnome.c @@ -249,7 +249,7 @@ * * xev.type = ClientMessage; * xev.window = client_window; - * xev.message_type = XInternAtom(disp, XA_WIN_LAYER, False); + * xev.message_type = EInternAtom(XA_WIN_LAYER); * xev.format = 32; * xev.data.l[0] = new_layer; * xev.data.l[1] = CurrentTime; @@ -263,7 +263,7 @@ * * xev.type = ClientMessage; * xev.window = client_window; - * xev.message_type = XInternAtom(disp, XA_WIN_STATE, False); + * xev.message_type = EInternAtom(XA_WIN_STATE); * xev.format = 32; * xev.data.l[0] = mask_of_members_to_change; * xev.data.l[1] = new_members; @@ -278,7 +278,7 @@ * * xev.type = ClientMessage; * xev.window = client_window; - * xev.message_type = XInternAtom(disp, XA_WIN_WORKSPACE, False); + * xev.message_type = EInternAtom(XA_WIN_WORKSPACE); * xev.format = 32; * xev.data.l[0] = new_desktop_number; * xev.data.l[2] = CurrentTimep; @@ -299,7 +299,7 @@ GNOME_GetHintIcons(EWin * ewin, Atom atom_change) return; if (!atom_get) - atom_get = XInternAtom(disp, XA_WIN_ICONS, False); + atom_get = EInternAtom(XA_WIN_ICONS); if ((atom_change) && (atom_change != atom_get)) return; @@ -328,7 +328,7 @@ GNOME_GetHintLayer(EWin * ewin, Atom atom_change) return; if (!atom_get) - atom_get = XInternAtom(disp, XA_WIN_LAYER, False); + atom_get = EInternAtom(XA_WIN_LAYER); if ((atom_change) && (atom_change != atom_get)) return; @@ -352,7 +352,7 @@ GNOME_GetHintState(EWin * ewin, Atom atom_change) return; if (!atom_get) - atom_get = XInternAtom(disp, XA_WIN_STATE, False); + atom_get = EInternAtom(XA_WIN_STATE); if ((atom_change) && (atom_change != atom_get)) return; @@ -385,7 +385,7 @@ GNOME_GetHintAppState(EWin * ewin, Atom atom_change) return; if (!atom_get) - atom_get = XInternAtom(disp, XA_WIN_APP_STATE, False); + atom_get = EInternAtom(XA_WIN_APP_STATE); if ((atom_change) && (atom_change != atom_get)) return; @@ -407,7 +407,7 @@ GNOME_GetHintDesktop(EWin * ewin, Atom atom_change) return; if (!atom_get) - atom_get = XInternAtom(disp, XA_WIN_WORKSPACE, False); + atom_get = EInternAtom(XA_WIN_WORKSPACE); if ((atom_change) && (atom_change != atom_get)) return; @@ -431,7 +431,7 @@ GNOME_GetHint(EWin * ewin, Atom atom_change) return; if (!atom_get) - atom_get = XInternAtom(disp, XA_WIN_HINTS, False); + atom_get = EInternAtom(XA_WIN_HINTS); if ((atom_change) && (atom_change != atom_get)) return; @@ -461,7 +461,7 @@ GNOME_SetHint(const EWin * ewin) if ((ewin->type == EWIN_TYPE_MENU) || (ewin->type == EWIN_TYPE_PAGER)) return; if (!atom_set) - atom_set = XInternAtom(disp, XA_WIN_STATE, False); + atom_set = EInternAtom(XA_WIN_STATE); val = 0; if (EoIsSticky(ewin)) val |= WIN_STATE_STICKY; @@ -481,7 +481,7 @@ GNOME_SetEwinArea(const EWin * ewin) if ((ewin->type == EWIN_TYPE_MENU) || (ewin->type == EWIN_TYPE_PAGER)) return; if (!atom_set) - atom_set = XInternAtom(disp, XA_WIN_AREA, False); + atom_set = EInternAtom(XA_WIN_AREA); val[0] = ewin->area_x; val[1] = ewin->area_y; ecore_x_window_prop_card32_set(EwinGetClientXwin(ewin), atom_set, val, 2); @@ -496,7 +496,7 @@ GNOME_SetEwinDesk(const EWin * ewin) if ((ewin->type == EWIN_TYPE_MENU) || (ewin->type == EWIN_TYPE_PAGER)) return; if (!atom_set) - atom_set = XInternAtom(disp, XA_WIN_WORKSPACE, False); + atom_set = EInternAtom(XA_WIN_WORKSPACE); val = EoGetDeskNum(ewin); ecore_x_window_prop_card32_set(EwinGetClientXwin(ewin), atom_set, &val, 1); } @@ -513,7 +513,7 @@ GNOME_GetExpandedSize(EWin * ewin, Atom atom_change) return; if (!atom_get) - atom_get = XInternAtom(disp, XA_WIN_EXPANDED_SIZE, False); + atom_get = EInternAtom(XA_WIN_EXPANDED_SIZE); if ((atom_change) && (atom_change != atom_get)) return; @@ -538,17 +538,17 @@ GNOME_SetUsedHints(void) Ecore_X_Atom list[10]; if (!atom_set) - atom_set = XInternAtom(disp, XA_WIN_PROTOCOLS, False); - list[0] = XInternAtom(disp, XA_WIN_LAYER, False); - list[1] = XInternAtom(disp, XA_WIN_STATE, False); - list[2] = XInternAtom(disp, XA_WIN_HINTS, False); - list[3] = XInternAtom(disp, XA_WIN_APP_STATE, False); - list[4] = XInternAtom(disp, XA_WIN_EXPANDED_SIZE, False); - list[5] = XInternAtom(disp, XA_WIN_ICONS, False); - list[6] = XInternAtom(disp, XA_WIN_WORKSPACE, False); - list[7] = XInternAtom(disp, XA_WIN_WORKSPACE_COUNT, False); - list[8] = XInternAtom(disp, XA_WIN_WORKSPACE_NAMES, False); - list[9] = XInternAtom(disp, XA_WIN_CLIENT_LIST, False); + atom_set = EInternAtom(XA_WIN_PROTOCOLS); + list[0] = EInternAtom(XA_WIN_LAYER); + list[1] = EInternAtom(XA_WIN_STATE); + list[2] = EInternAtom(XA_WIN_HINTS); + list[3] = EInternAtom(XA_WIN_APP_STATE); + list[4] = EInternAtom(XA_WIN_EXPANDED_SIZE); + list[5] = EInternAtom(XA_WIN_ICONS); + list[6] = EInternAtom(XA_WIN_WORKSPACE); + list[7] = EInternAtom(XA_WIN_WORKSPACE_COUNT); + list[8] = EInternAtom(XA_WIN_WORKSPACE_NAMES); + list[9] = EInternAtom(XA_WIN_CLIENT_LIST); ecore_x_window_prop_atom_set(WinGetXwin(VROOT), atom_set, list, 10); } @@ -560,7 +560,7 @@ GNOME_SetCurrentArea(void) int ax, ay; if (!atom_set) - atom_set = XInternAtom(disp, XA_WIN_AREA, False); + atom_set = EInternAtom(XA_WIN_AREA); DeskCurrentGetArea(&ax, &ay); val[0] = ax; val[1] = ay; @@ -574,7 +574,7 @@ GNOME_SetCurrentDesk(void) unsigned int val; if (!atom_set) - atom_set = XInternAtom(disp, XA_WIN_WORKSPACE, False); + atom_set = EInternAtom(XA_WIN_WORKSPACE); val = DesksGetCurrentNum(); ecore_x_window_prop_card32_set(WinGetXwin(VROOT), atom_set, &val, 1); } @@ -586,7 +586,7 @@ GNOME_SetWMCheck(Window win_wm_check) unsigned int val; if (!atom_set) - atom_set = XInternAtom(disp, XA_WIN_SUPPORTING_WM_CHECK, False); + atom_set = EInternAtom(XA_WIN_SUPPORTING_WM_CHECK); val = win_wm_check; ecore_x_window_prop_card32_set(WinGetXwin(VROOT), atom_set, &val, 1); ecore_x_window_prop_card32_set(win_wm_check, atom_set, &val, 1); @@ -599,7 +599,7 @@ GNOME_SetDeskCount(void) unsigned int val; if (!atom_set) - atom_set = XInternAtom(disp, XA_WIN_WORKSPACE_COUNT, False); + atom_set = EInternAtom(XA_WIN_WORKSPACE_COUNT); val = DesksGetNumber(); ecore_x_window_prop_card32_set(WinGetXwin(VROOT), atom_set, &val, 1); } @@ -612,7 +612,7 @@ GNOME_SetAreaCount(void) unsigned int val[2]; if (!atom_set) - atom_set = XInternAtom(disp, XA_WIN_AREA_COUNT, False); + atom_set = EInternAtom(XA_WIN_AREA_COUNT); DesksGetAreaSize(&ax, &ay); val[0] = ax; val[1] = ay; @@ -627,7 +627,7 @@ GNOME_SetDeskNames(void) int i, n_desks; if (!atom_set) - atom_set = XInternAtom(disp, XA_WIN_WORKSPACE_NAMES, False); + atom_set = EInternAtom(XA_WIN_WORKSPACE_NAMES); n_desks = DesksGetNumber(); names = EMALLOC(char *, n_desks); @@ -658,7 +658,7 @@ GNOME_SetClientList(void) EWin *const *lst; if (!atom_set) - atom_set = XInternAtom(disp, XA_WIN_CLIENT_LIST, False); + atom_set = EInternAtom(XA_WIN_CLIENT_LIST); lst = EwinListOrderGet(&num); wl = NULL; @@ -683,11 +683,11 @@ GNOME_SetWMNameVer(void) static Atom atom_set = 0, atom_set2 = 0; if (!atom_set) - atom_set = XInternAtom(disp, XA_WIN_WM_NAME, False); + atom_set = EInternAtom(XA_WIN_WM_NAME); ecore_x_window_prop_string_set(WinGetXwin(VROOT), atom_set, e_wm_name); if (!atom_set2) - atom_set2 = XInternAtom(disp, XA_WIN_WM_VERSION, False); + atom_set2 = EInternAtom(XA_WIN_WM_VERSION); ecore_x_window_prop_string_set(WinGetXwin(VROOT), atom_set2, e_wm_version); } @@ -699,12 +699,12 @@ GNOME_DelHints(const EWin * ewin) if (!atom_get[0]) { - atom_get[0] = XInternAtom(disp, XA_WIN_WORKSPACE, False); - atom_get[1] = XInternAtom(disp, XA_WIN_LAYER, False); - atom_get[2] = XInternAtom(disp, XA_WIN_STATE, False); - atom_get[3] = XInternAtom(disp, XA_WIN_HINTS, False); - atom_get[4] = XInternAtom(disp, XA_WIN_APP_STATE, False); - atom_get[5] = XInternAtom(disp, XA_WIN_AREA, False); + atom_get[0] = EInternAtom(XA_WIN_WORKSPACE); + atom_get[1] = EInternAtom(XA_WIN_LAYER); + atom_get[2] = EInternAtom(XA_WIN_STATE); + atom_get[3] = EInternAtom(XA_WIN_HINTS); + atom_get[4] = EInternAtom(XA_WIN_APP_STATE); + atom_get[5] = EInternAtom(XA_WIN_AREA); } win = EwinGetClientXwin(ewin); @@ -740,7 +740,7 @@ GNOME_SetHints(Window win_wm_check) Atom atom_set; unsigned int val; - atom_set = XInternAtom(disp, "_WIN_DESKTOP_BUTTON_PROXY", False); + atom_set = EInternAtom("_WIN_DESKTOP_BUTTON_PROXY"); Mode.button_proxy_win = XCreateSimpleWindow(disp, WinGetXwin(VROOT), -80, -80, 24, 24, 0, 0, 0); @@ -756,9 +756,9 @@ GNOME_ProcessClientClientMessage(EWin * ewin, XClientMessageEvent * event) static Atom a4 = 0, a5 = 0; if (!a4) - a4 = XInternAtom(disp, "_WIN_LAYER", False); + a4 = EInternAtom("_WIN_LAYER"); if (!a5) - a5 = XInternAtom(disp, "_WIN_STATE", False); + a5 = EInternAtom("_WIN_STATE"); if (event->message_type == a4) { @@ -810,9 +810,9 @@ GNOME_ProcessRootClientMessage(XClientMessageEvent * event) static Atom a2 = 0, a3 = 0; if (!a2) - a2 = XInternAtom(disp, "_WIN_AREA", False); + a2 = EInternAtom("_WIN_AREA"); if (!a3) - a3 = XInternAtom(disp, "_WIN_WORKSPACE", False); + a3 = EInternAtom("_WIN_WORKSPACE"); if (event->message_type == a2) { diff --git a/src/grabs.c b/src/grabs.c index 9ac5a10c..ab143adc 100644 --- a/src/grabs.c +++ b/src/grabs.c @@ -24,6 +24,7 @@ #include "E.h" #include "cursors.h" #include "grabs.h" +#include "xwin.h" int GrabKeyboardSet(Win win) diff --git a/src/grabs.h b/src/grabs.h index de1960ea..28978e62 100644 --- a/src/grabs.h +++ b/src/grabs.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors - * Copyright (C) 2006-2007 Kim Woelders + * Copyright (C) 2006-2008 Kim Woelders * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to @@ -24,7 +24,7 @@ #ifndef _GRABS_H_ #define _GRABS_H_ -#include "xwin.h" +#include "xtypes.h" int GrabKeyboardSet(Win win); int GrabKeyboardRelease(void); diff --git a/src/hints.c b/src/hints.c index 3ef502a9..45828a82 100644 --- a/src/hints.c +++ b/src/hints.c @@ -588,7 +588,7 @@ SelectionAcquire(const char *name, EventCallbackFunc * func, void *data) Esnprintf(buf, sizeof(buf), "%s%d", name, Dpy.screen); - sel->atom = XInternAtom(disp, buf, False); + sel->atom = EInternAtom(buf); sel->time = EGetTimestamp(); sel->win = ECreateEventWindow(VROOT, -100, -100, 1, 1); diff --git a/src/icccm.c b/src/icccm.c index 5d21a2b4..3984fe74 100644 --- a/src/icccm.c +++ b/src/icccm.c @@ -291,7 +291,7 @@ ICCCM_Configure(EWin * ewin) ev.xconfigure.border_width = 0; ev.xconfigure.above = EoGetXwin(ewin); ev.xconfigure.override_redirect = False; - XSendEvent(disp, EwinGetClientXwin(ewin), False, StructureNotifyMask, &ev); + EXSendEvent(EwinGetClientXwin(ewin), StructureNotifyMask, &ev); } void diff --git a/src/iclass.c b/src/iclass.c index 218dd1c9..5f7169b9 100644 --- a/src/iclass.c +++ b/src/iclass.c @@ -840,24 +840,24 @@ pt_type_to_flags(int image_type) } static EImage * -pt_get_bg_image(Window win, int w, int h, int use_root) +pt_get_bg_image(Win win, int w, int h, int use_root) { EImage *ii = NULL; - Window cr, dummy; + Win cr; Drawable bg; int xx, yy; bg = DeskGetBackgroundPixmap(DesksGetCurrent()); if (use_root || bg == None) { - cr = WinGetXwin(VROOT); + cr = VROOT; bg = WinGetXwin(VROOT); } else { - cr = EoGetXwin(DesksGetCurrent()); + cr = EoGetWin(DesksGetCurrent()); } - XTranslateCoordinates(disp, win, cr, 0, 0, &xx, &yy, &dummy); + ETranslateCoordinates(win, cr, 0, 0, &xx, &yy, NULL); #if 0 Eprintf("pt_get_bg_image %#lx %d %d %d %d\n", win, xx, yy, w, h); #endif @@ -890,7 +890,7 @@ ImageclassGetImageBlended(ImageClass * ic, Win win, int w, int h, int active, flags = pt_type_to_flags(image_type); if (flags != ICLASS_ATTR_OPAQUE) { - bg = pt_get_bg_image(WinGetXwin(win), w, h, flags & ICLASS_ATTR_GLASS); + bg = pt_get_bg_image(win, w, h, flags & ICLASS_ATTR_GLASS); if (bg) { EImageBlendCM(bg, im, (flags & ICLASS_ATTR_USE_CM) ? icm : NULL); @@ -932,7 +932,7 @@ ImagestateMakePmapMask(ImageState * is, Win win, PmapMask * pmm, if (flags != ICLASS_ATTR_OPAQUE) { - ii = pt_get_bg_image(WinGetXwin(win), w, h, flags & ICLASS_ATTR_GLASS); + ii = pt_get_bg_image(win, w, h, flags & ICLASS_ATTR_GLASS); } else { diff --git a/src/ipc.c b/src/ipc.c index e78cd89a..3d117745 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -1375,12 +1375,12 @@ IPC_InsertKeys(const char *params, Client * c __UNUSED__) continue; i += strlen(ks[j].ch) - 1; - ev.keycode = XKeysymToKeycode(disp, XStringToKeysym(ks[j].sym)); + ev.keycode = EKeynameToKeycode(ks[j].sym); ev.state = ks[j].state; ev.type = KeyPress; - XSendEvent(disp, win, False, 0, (XEvent *) & ev); + EXSendEvent(win, 0, (XEvent *) & ev); ev.type = KeyRelease; - XSendEvent(disp, win, False, 0, (XEvent *) & ev); + EXSendEvent(win, 0, (XEvent *) & ev); break; } } diff --git a/src/lang.c b/src/lang.c index c74e6850..d7ad6a58 100644 --- a/src/lang.c +++ b/src/lang.c @@ -24,6 +24,7 @@ #include "E.h" #include "emodule.h" #include "lang.h" +#include #ifdef HAVE_LOCALE_H #include diff --git a/src/main.c b/src/main.c index ea6ab6c8..be1be8e0 100644 --- a/src/main.c +++ b/src/main.c @@ -322,7 +322,7 @@ EExit(int exitcode) /* XSetInputFocus(disp, None, RevertToParent, CurrentTime); */ /* I think this is a better way to release the grabs: (felix) */ XSetInputFocus(disp, PointerRoot, RevertToPointerRoot, CurrentTime); - XSelectInput(disp, WinGetXwin(VROOT), 0); + ESelectInput(VROOT, 0); EDisplayClose(); } diff --git a/src/mwm.c b/src/mwm.c index 60a4d125..2639ba05 100644 --- a/src/mwm.c +++ b/src/mwm.c @@ -80,7 +80,7 @@ MWM_GetHints(EWin * ewin, Atom atom_change) return; if (!_MOTIF_WM_HINTS) - _MOTIF_WM_HINTS = XInternAtom(disp, "_MOTIF_WM_HINTS", False); + _MOTIF_WM_HINTS = EInternAtom("_MOTIF_WM_HINTS"); if (atom_change && atom_change != _MOTIF_WM_HINTS) return; @@ -183,7 +183,7 @@ MWM_SetInfo(void) Window win; } mwminfo; - a1 = XInternAtom(disp, "_MOTIF_WM_INFO", False); + a1 = EInternAtom("_MOTIF_WM_INFO"); mwminfo.flags = 2; mwminfo.win = WinGetXwin(VROOT); XChangeProperty(disp, WinGetXwin(VROOT), a1, a1, 32, PropModeReplace, diff --git a/src/pager.c b/src/pager.c index 8c2d1bac..b7983ca6 100644 --- a/src/pager.c +++ b/src/pager.c @@ -238,7 +238,7 @@ PagerScanTimeout(int val __UNUSED__, void *data) ScaleRect(VROOT, WinGetXwin(VROOT), p->win, WinGetPmap(p->win), 0, y2, WinGetW(VROOT), WinGetH(VROOT) / hh, xx, yy + y, ww, 1, HIQ); - EClearArea(p->win, xx, yy + y, ww, 1, False); + EClearArea(p->win, xx, yy + y, ww, 1); y2 = p->h; #else y = ((phase & 0xfffffff8) + offsets[phase % 8]) % ww; @@ -246,7 +246,7 @@ PagerScanTimeout(int val __UNUSED__, void *data) ScaleRect(VROOT, WinGetXwin(VROOT), p->win, WinGetPmap(p->win), y2, 0, WinGetW(VROOT) / ww, WinGetH(VROOT), xx + y, yy, 1, hh, HIQ); - EClearArea(p->win, xx + y, yy, 1, hh, False); + EClearArea(p->win, xx + y, yy, 1, hh); y2 = p->w; #endif p->update_phase++; diff --git a/src/piximg.h b/src/piximg.h index ce4f60f5..0b2f6b52 100644 --- a/src/piximg.h +++ b/src/piximg.h @@ -23,6 +23,7 @@ #ifndef _PIXIMG_H_ #define _PIXIMG_H_ +#include #include typedef struct _PixImg { diff --git a/src/session.c b/src/session.c index 0d980ad8..37997f33 100644 --- a/src/session.c +++ b/src/session.c @@ -424,7 +424,7 @@ SessionInit(void) return; #if 0 /* Unused */ - atom_sm_client_id = XInternAtom(disp, "SM_CLIENT_ID", False); + atom_sm_client_id = EInternAtom("SM_CLIENT_ID"); #endif #if USE_SM @@ -514,7 +514,7 @@ doSMExit(int mode, const char *params) { /* We may get here from HandleXIOError */ EwinsSetFree(); - XSelectInput(disp, WinGetXwin(VROOT), 0); + ESelectInput(VROOT, 0); ExtInitWinKill(); ESync(0); diff --git a/src/setup.c b/src/setup.c index 3724951d..6d2bc64f 100644 --- a/src/setup.c +++ b/src/setup.c @@ -191,8 +191,8 @@ SetupX(const char *dstr) numlock = scrollock = 0; mod = XGetModifierMapping(disp); - nl = XKeysymToKeycode(disp, XK_Num_Lock); - sl = XKeysymToKeycode(disp, XK_Scroll_Lock); + nl = EKeysymToKeycode(XK_Num_Lock); + sl = EKeysymToKeycode(XK_Scroll_Lock); if ((mod) && (mod->max_keypermod > 0)) { for (i = 0; i < (8 * mod->max_keypermod); i++) diff --git a/src/systray.c b/src/systray.c index c6d9503f..68fbcc82 100644 --- a/src/systray.c +++ b/src/systray.c @@ -423,12 +423,10 @@ SystrayInit(Container * ct) Esnprintf(buf, sizeof(buf), "_NET_SYSTEM_TRAY_S%d", Dpy.screen); - E_XA__XEMBED = XInternAtom(disp, "_XEMBED", False); - E_XA__XEMBED_INFO = XInternAtom(disp, "_XEMBED_INFO", False); - _NET_SYSTEM_TRAY_OPCODE = - XInternAtom(disp, "_NET_SYSTEM_TRAY_OPCODE", False); - _NET_SYSTEM_TRAY_MESSAGE_DATA = - XInternAtom(disp, "_NET_SYSTEM_TRAY_MESSAGE_DATA", False); + E_XA__XEMBED = EInternAtom("_XEMBED"); + E_XA__XEMBED_INFO = EInternAtom("_XEMBED_INFO"); + _NET_SYSTEM_TRAY_OPCODE = EInternAtom("_NET_SYSTEM_TRAY_OPCODE"); + _NET_SYSTEM_TRAY_MESSAGE_DATA = EInternAtom("_NET_SYSTEM_TRAY_MESSAGE_DATA"); /* Acquire selection */ if (systray_sel) diff --git a/src/x.c b/src/x.c index 0e81fdc0..9a722582 100644 --- a/src/x.c +++ b/src/x.c @@ -1071,11 +1071,58 @@ ESetWindowBackground(Win win, unsigned int col) XSetWindowBackground(disp, win->xwin, col); } +void +ESelectInput(Win win, unsigned int event_mask) +{ + XSelectInput(disp, win->xwin, event_mask); +} + +void +EChangeWindowAttributes(Win win, unsigned int mask, XSetWindowAttributes * attr) +{ + XChangeWindowAttributes(disp, win->xwin, mask, attr); +} + +void +ESetWindowBorderWidth(Win win, unsigned int bw) +{ + XSetWindowBorderWidth(disp, win->xwin, bw); +} + +void +ERaiseWindow(Win win) +{ + XRaiseWindow(disp, win->xwin); +} + +void +ELowerWindow(Win win) +{ + XLowerWindow(disp, win->xwin); +} + +void +EXRestackWindows(Window * windows, int nwindows) +{ + XRestackWindows(disp, windows, nwindows); +} + +void +EClearWindow(Win win) +{ + XClearWindow(disp, win->xwin); +} + +void +EClearArea(Win win, int x, int y, unsigned int w, unsigned int h) +{ + XClearArea(disp, win->xwin, x, y, w, h, False); +} + int -ETranslateCoordinates(Win src_w, Win dst_w, - int src_x, int src_y, - int *dest_x_return, - int *dest_y_return, Window * child_return) +ETranslateCoordinates(Win src_w, Win dst_w, int src_x, int src_y, + int *dest_x_return, int *dest_y_return, + Window * child_return) { Window child; @@ -1156,6 +1203,30 @@ EDrawableCheck(Drawable draw, int grab) return ok; } +KeyCode +EKeysymToKeycode(KeySym keysym) +{ + return XKeysymToKeycode(disp, keysym); +} + +KeyCode +EKeynameToKeycode(const char *name) +{ + return XKeysymToKeycode(disp, XStringToKeysym(name)); +} + +const char * +EKeycodeToString(KeyCode keycode, int ix) +{ + return XKeysymToString(XKeycodeToKeysym(disp, keycode, ix)); +} + +Atom +EInternAtom(const char *name) +{ + return XInternAtom(disp, name, False); +} + #define DEBUG_SHAPE_OPS 0 #define DEBUG_SHAPE_PROPAGATE 0 @@ -1629,6 +1700,12 @@ EXFreeGC(GC gc) return XFreeGC(disp, gc); } +void +EXSendEvent(Window xwin, long event_mask, XEvent * ev) +{ + XSendEvent(disp, xwin, False, event_mask, ev); +} + void EAllocColor(Colormap cmap, EColor * pec) { diff --git a/src/xtypes.h b/src/xtypes.h new file mode 100644 index 00000000..b7b06898 --- /dev/null +++ b/src/xtypes.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2008 Kim Woelders + * + * 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. + */ +#ifndef _XTYPES_H_ +#define _XTYPES_H_ + +typedef struct _xwin *Win; + +#endif /* _XTYPES_H_ */ diff --git a/src/xwin.h b/src/xwin.h index bd286630..ab811184 100644 --- a/src/xwin.h +++ b/src/xwin.h @@ -27,8 +27,7 @@ #include #include #include "util.h" - -typedef struct _xwin *Win; +#include "xtypes.h" typedef struct { Display *disp; @@ -206,23 +205,15 @@ int ETranslateCoordinates(Win src_w, Win dst_w, Window * child_return); int EDrawableCheck(Drawable draw, int grab); -#define ESelectInput(win, event_mask) \ - XSelectInput(disp, WinGetXwin(win), event_mask) - -#define EChangeWindowAttributes(win, mask, attr) \ - XChangeWindowAttributes(disp, WinGetXwin(win), mask, attr) -#define ESetWindowBorderWidth(win, bw) \ - XSetWindowBorderWidth(disp, WinGetXwin(win), bw) - -#define ERaiseWindow(win) \ - XRaiseWindow(disp, WinGetXwin(win)) -#define ELowerWindow(win) \ - XLowerWindow(disp, WinGetXwin(win)) - -#define EClearWindow(win) \ - XClearWindow(disp, WinGetXwin(win)) -#define EClearArea(win, x, y, w, h, exp) \ - XClearArea(disp, WinGetXwin(win), x, y, w, h, exp) +void ESelectInput(Win win, unsigned int event_mask); +void EChangeWindowAttributes(Win win, unsigned int mask, + XSetWindowAttributes * attr); +void ESetWindowBorderWidth(Win win, unsigned int bw); +void ERaiseWindow(Win win); +void ELowerWindow(Win win); +void EClearWindow(Win win); +void EClearArea(Win win, int x, int y, + unsigned int w, unsigned int h); Pixmap ECreatePixmap(Win win, unsigned int width, unsigned int height, unsigned int depth); @@ -264,8 +255,8 @@ Window EXWindowGetParent(Window xwin); int EXGetGeometry(Window xwin, Window * root_return, int *x, int *y, int *w, int *h, int *bw, int *depth); -#define EXGetWindowAttributes(win, xwa) \ - XGetWindowAttributes(disp, WinGetXwin(win), xwa) + +void EXRestackWindows(Window * windows, int nwindows); void EXCopyArea(Drawable src, Drawable dst, int sx, int sy, unsigned int w, unsigned int h, int dx, int dy); @@ -283,6 +274,14 @@ GC EXCreateGC(Drawable draw, unsigned long mask, XGCValues * val); int EXFreeGC(GC gc); +void EXSendEvent(Window xwin, long event_mask, XEvent * ev); + +KeyCode EKeysymToKeycode(KeySym keysym); +KeyCode EKeynameToKeycode(const char *name); +const char *EKeycodeToString(KeyCode keycode, int index); + +Atom EInternAtom(const char *name); + typedef struct { char type; Pixmap pmap;