From: Michael D. Lowis Date: Mon, 9 Mar 2020 14:12:19 +0000 (-0400) Subject: removed EWMH remnants X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=4d77df252de4e781acf4938a1d949060474598be;p=proto%2Flwm.git removed EWMH remnants --- diff --git a/client.c b/client.c index 9189d38..61bf15e 100644 --- a/client.c +++ b/client.c @@ -136,7 +136,6 @@ Client_Add(Window w, Window root) { c->internal_state = INormal; c->name = 0; c->cursor = ENone; - c->wtype = WTypeNone; c->flags |= F_ACCEPT_FOCUS; c->next = clients; @@ -174,8 +173,6 @@ Client_Remove(Client *c) { if (c->name != 0) free(c->name); free(c); - - ewmh_set_client_list(screen); } @@ -301,7 +298,6 @@ Client_OpaquePrimitive(Client *c, Edge edge) { start_x = ox; start_y = oy; mode = wm_reshaping; - ewmh_set_client_list(c->screen); } void @@ -311,7 +307,6 @@ Client_Lower(Client *c) XLowerWindow(dpy, c->window); if (c->framed) XLowerWindow(dpy, c->parent); - ewmh_set_client_list(c->screen); } void @@ -331,8 +326,6 @@ Client_Raise(Client *c) if (trans->framed) XRaiseWindow(dpy, trans->parent); XRaiseWindow(dpy, trans->window); } - - ewmh_set_client_list(c->screen); } void @@ -389,8 +382,6 @@ extern void Client_Focus(Client *c, Time time) { if (current) { Client_SetActive(current, 0, 0L); - XDeleteProperty(dpy, current->screen->root, - ewmh_atom[_NET_ACTIVE_WINDOW]); } if (!c && current) { @@ -401,10 +392,6 @@ Client_Focus(Client *c, Time time) { current = c; if (c) { Client_SetActive(current, 1, time); - XChangeProperty(dpy, current->screen->root, - ewmh_atom[_NET_ACTIVE_WINDOW], - XA_WINDOW, 32, PropModeReplace, - (unsigned char *)¤t->window, 1); } } diff --git a/disp.c b/disp.c index e9f2c87..7d06329 100644 --- a/disp.c +++ b/disp.c @@ -251,7 +251,6 @@ maprequest(XEvent *ev) { Client_SetState(c, NormalState); break; } - ewmh_set_client_list(c->screen); } static void @@ -410,109 +409,9 @@ static void clientmessage(XEvent *ev) { Client * c; XClientMessageEvent * e = &ev->xclient; - c = Client_Get(e->window); if (c == 0) return; - if (e->message_type == ewmh_atom[_NET_ACTIVE_WINDOW] && - e->format == 32) { - /* An EWMH enabled application has asked for this client - * to be made the active window. The window is raised, and - * focus given if the focus mode is click (focusing on a - * window other than the one the pointer is in makes no - * sense when the focus mode is enter). - */ - XMapWindow(dpy, c->parent); - Client_Raise(c); - return; - } - if (e->message_type == ewmh_atom[_NET_CLOSE_WINDOW] && - e->format == 32) { - Client_Close(c); - return; - } - if (e->message_type == ewmh_atom[_NET_MOVERESIZE_WINDOW] && - e->format == 32) { - XEvent ev; - - /* FIXME: ok, so this is a bit of a hack */ - ev.xconfigurerequest.window = e->window; - ev.xconfigurerequest.x = e->data.l[1]; - ev.xconfigurerequest.y = e->data.l[2]; - ev.xconfigurerequest.width = e->data.l[3]; - ev.xconfigurerequest.height = e->data.l[4]; - ev.xconfigurerequest.value_mask = 0; - if (e->data.l[0] & (1 << 8)) - ev.xconfigurerequest.value_mask |= CWX; - if (e->data.l[0] & (1 << 9)) - ev.xconfigurerequest.value_mask |= CWY; - if (e->data.l[0] & (1 << 10)) - ev.xconfigurerequest.value_mask |= CWWidth; - if (e->data.l[0] & (1 << 11)) - ev.xconfigurerequest.value_mask |= CWHeight; - configurereq(&ev); - return; - } - if (e->message_type == ewmh_atom[_NET_WM_MOVERESIZE] && - e->format == 32) { - Edge edge = E_LAST; - EWMHDirection direction = e->data.l[2]; - - /* before we can do any resizing, make the window visible */ - XMapWindow(dpy, c->parent); - Client_Raise(c); - /* FIXME: we're ignorning x_root, y_root and button! */ - switch (direction) { - case DSizeTopLeft: - edge = ETopLeft; - break; - case DSizeTop: - edge = ETop; - break; - case DSizeTopRight: - edge = ETopRight; - break; - case DSizeRight: - edge = ERight; - break; - case DSizeBottomRight: - edge = EBottomRight; - break; - case DSizeBottom: - edge = EBottom; - break; - case DSizeBottomLeft: - edge = EBottomLeft; - break; - case DSizeLeft: - edge = ELeft; - break; - case DMove: - edge = ENone; - break; - case DSizeKeyboard: - /* FIXME: don't know how to deal with this */ - edge = E_LAST; - break; - case DMoveKeyboard: - edge = E_LAST; - break; - default: - edge = E_LAST; - fprintf(stderr, "%s: received _NET_WM_MOVERESIZE" - " with bad direction", argv0); - break; - } - switch (edge) { - case E_LAST: - break; - case ENone: - Client_Move(c); - break; - default: - Client_ReshapeEdge(c, edge); - break; - } - } + // TODO: Should handle some messages here... } static void diff --git a/ewmh.c b/ewmh.c index 54f1b74..6b0b696 100644 --- a/ewmh.c +++ b/ewmh.c @@ -29,215 +29,17 @@ #include "lwm.h" #include "ewmh.h" -Atom ewmh_atom[EWMH_ATOM_LAST]; -Atom utf8_string; - -void -ewmh_init(void) { - /* build half a million EWMH atoms */ - ewmh_atom[_NET_SUPPORTED] = - XInternAtom(dpy, "_NET_SUPPORTED", False); - ewmh_atom[_NET_CLIENT_LIST] = - XInternAtom(dpy, "_NET_CLIENT_LIST", False); - ewmh_atom[_NET_CLIENT_LIST_STACKING] = - XInternAtom(dpy, "_NET_CLIENT_LIST_STACKING", False); - ewmh_atom[_NET_NUMBER_OF_DESKTOPS] = - XInternAtom(dpy, "_NET_NUMBER_OF_DESKTOPS", False); - ewmh_atom[_NET_DESKTOP_GEOMETRY] = - XInternAtom(dpy, "_NET_DESKTOP_GEOMETRY", False); - ewmh_atom[_NET_DESKTOP_VIEWPORT] = - XInternAtom(dpy, "_NET_DESKTOP_VIEWPORT", False); - ewmh_atom[_NET_CURRENT_DESKTOP] = - XInternAtom(dpy, "_NET_CURRENT_DESKTOP", False); - ewmh_atom[_NET_ACTIVE_WINDOW] = - XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False); - ewmh_atom[_NET_WORKAREA] = - XInternAtom(dpy, "_NET_WORKAREA", False); - ewmh_atom[_NET_SUPPORTING_WM_CHECK] = - XInternAtom(dpy, "_NET_SUPPORTING_WM_CHECK", False); - ewmh_atom[_NET_CLOSE_WINDOW] = - XInternAtom(dpy, "_NET_CLOSE_WINDOW", False); - ewmh_atom[_NET_MOVERESIZE_WINDOW] = - XInternAtom(dpy, "_NET_MOVERESIZE_WINDOW", False); - ewmh_atom[_NET_WM_MOVERESIZE] = - XInternAtom(dpy, "_NET_WM_MOVERESIZE", False); - ewmh_atom[_NET_WM_NAME] = - XInternAtom(dpy, "_NET_WM_NAME", False); - ewmh_atom[_NET_WM_WINDOW_TYPE] = - XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False); - ewmh_atom[_NET_WM_STATE] = - XInternAtom(dpy, "_NET_WM_STATE", False); - ewmh_atom[_NET_WM_ALLOWED_ACTIONS] = - XInternAtom(dpy, "_NET_WM_ALLOWED_ACTIONS", False); - ewmh_atom[_NET_WM_STRUT] = - XInternAtom(dpy, "_NET_WM_STRUT", False); - ewmh_atom[_NET_WM_WINDOW_TYPE_DESKTOP] = - XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DESKTOP", False); - ewmh_atom[_NET_WM_WINDOW_TYPE_DOCK] = - XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DOCK", False); - ewmh_atom[_NET_WM_WINDOW_TYPE_TOOLBAR] = - XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_TOOLBAR", False); - ewmh_atom[_NET_WM_WINDOW_TYPE_MENU] = - XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_MENU", False); - ewmh_atom[_NET_WM_WINDOW_TYPE_UTILITY] = - XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_UTILITY", False); - ewmh_atom[_NET_WM_WINDOW_TYPE_SPLASH] = - XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_SPLASH", False); - ewmh_atom[_NET_WM_WINDOW_TYPE_DIALOG] = - XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DIALOG", False); - ewmh_atom[_NET_WM_WINDOW_TYPE_NORMAL] = - XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_NORMAL", False); - ewmh_atom[_NET_WM_STATE_SKIP_TASKBAR] = - XInternAtom(dpy, "_NET_WM_STATE_SKIP_TASKBAR", False); - ewmh_atom[_NET_WM_STATE_SKIP_PAGER] = - XInternAtom(dpy, "_NET_WM_STATE_SKIP_PAGER", False); - ewmh_atom[_NET_WM_STATE_HIDDEN] = - XInternAtom(dpy, "_NET_WM_STATE_HIDDEN", False); - ewmh_atom[_NET_WM_STATE_FULLSCREEN] = - XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN", False); - ewmh_atom[_NET_WM_ACTION_MOVE] = - XInternAtom(dpy, "_NET_WM_ACTION_MOVE", False); - ewmh_atom[_NET_WM_ACTION_RESIZE] = - XInternAtom(dpy, "_NET_WM_ACTION_RESIZE", False); - ewmh_atom[_NET_WM_ACTION_FULLSCREEN] = - XInternAtom(dpy, "_NET_WM_ACTION_FULLSCREEN", False); - ewmh_atom[_NET_WM_ACTION_CLOSE] = - XInternAtom(dpy, "_NET_WM_ACTION_CLOSE", False); - utf8_string = XInternAtom(dpy, "UTF8_STRING", False); -} - -void -ewmh_init_screens(void) { - int i; - unsigned long data[4]; - - /* announce EWMH compatibility on all acreens */ - for (i = 0; i < screen_count; i++) { - screens[i].ewmh_set_client_list = False; - screens[i].ewmh_compat = XCreateSimpleWindow(dpy, - screens[i].root, - -200, -200, 1, 1, - 0, 0, 0); - XChangeProperty(dpy, screens[i].ewmh_compat, - ewmh_atom[_NET_WM_NAME], - utf8_string, 8, PropModeReplace, - (unsigned char*)"lwm", 3); - - /* set root window properties */ - XChangeProperty(dpy, screens[i].root, - ewmh_atom[_NET_SUPPORTED], - XA_ATOM, 32, PropModeReplace, - (unsigned char *)ewmh_atom, EWMH_ATOM_LAST); - - XChangeProperty(dpy, screens[i].root, - ewmh_atom[_NET_SUPPORTING_WM_CHECK], - XA_WINDOW, 32, PropModeReplace, - (unsigned char *)&screens[i].ewmh_compat, 1); - - data[0] = 1; - XChangeProperty(dpy, screens[i].root, - ewmh_atom[_NET_NUMBER_OF_DESKTOPS], - XA_CARDINAL, 32, PropModeReplace, - (unsigned char*)data, 1); - - data[0] = screens[i].display_width; - data[1] = screens[i].display_height; - XChangeProperty(dpy, screens[i].root, - ewmh_atom[_NET_DESKTOP_GEOMETRY], - XA_CARDINAL, 32, PropModeReplace, - (unsigned char*)data, 2); - - data[0] = 0; - data[1] = 0; - XChangeProperty(dpy, screens[i].root, - ewmh_atom[_NET_DESKTOP_VIEWPORT], - XA_CARDINAL, 32, PropModeReplace, - (unsigned char*)data, 2); - - data[0] = 0; - XChangeProperty(dpy, screens[i].root, - ewmh_atom[_NET_CURRENT_DESKTOP], - XA_CARDINAL, 32, PropModeReplace, - (unsigned char*)data, 1); - - ewmh_set_client_list(&screens[i]); - } -} - -EWMHWindowType -ewmh_get_window_type(Window w) { - Atom rt; - Atom *type; - int fmt; - unsigned long n; - unsigned long extra; - int i; - EWMHWindowType ret; - - i = XGetWindowProperty(dpy, w, - ewmh_atom[_NET_WM_WINDOW_TYPE], - 0, 100, False, XA_ATOM, &rt, &fmt, &n, &extra, - (unsigned char **)&type); - if (i != Success || type == NULL) - return WTypeNone; - ret = WTypeNone; - for (; n; n--) { - if (type[n - 1] == - ewmh_atom[_NET_WM_WINDOW_TYPE_DESKTOP]) { - ret = WTypeDesktop; - break; - } - if (type[n - 1] == - ewmh_atom[_NET_WM_WINDOW_TYPE_DOCK]) { - ret = WTypeDock; - break; - } - if (type[n - 1] == - ewmh_atom[_NET_WM_WINDOW_TYPE_TOOLBAR]) { - ret = WTypeToolbar; - break; - } - if (type[n - 1] == - ewmh_atom[_NET_WM_WINDOW_TYPE_MENU]) { - ret = WTypeMenu; - break; - } - if (type[n - 1] == - ewmh_atom[_NET_WM_WINDOW_TYPE_UTILITY]) { - ret = WTypeUtility; - break; - } - if (type[n - 1] == - ewmh_atom[_NET_WM_WINDOW_TYPE_SPLASH]) { - ret = WTypeSplash; - break; - } - if (type[n - 1] == - ewmh_atom[_NET_WM_WINDOW_TYPE_DIALOG]) { - ret = WTypeDialog; - break; - } - if (type[n - 1] == - ewmh_atom[_NET_WM_WINDOW_TYPE_NORMAL]) { - ret = WTypeNormal; - break; - } - } - XFree(type); - return ret; -} - - Bool ewmh_get_window_name(Client *c) { - Atom rt; + Atom rt, utf8_string; char *name; int fmt; unsigned long n; unsigned long extra; int i; + utf8_string = XInternAtom(dpy, "UTF8_STRING", False); i = XGetWindowProperty(dpy, c->window, - ewmh_atom[_NET_WM_NAME], + XInternAtom(dpy, "_NET_WM_NAME", False), 0, 100, False, utf8_string, &rt, &fmt, &n, &extra, (unsigned char **)&name); if (i != Success || name == NULL) @@ -246,124 +48,3 @@ Bool ewmh_get_window_name(Client *c) { XFree(name); return True; } - -Bool -ewmh_hasframe(Client *c) { - switch (c->wtype) { - case WTypeDesktop: - case WTypeDock: - case WTypeMenu: - case WTypeSplash: - return False; - default: - return True; - } -} - -static Bool -new_state(unsigned long action, Bool current) -{ - enum Action {remove, add, toggle}; - - switch (action) { - case remove: - return False; - case add: - return True; - case toggle: - if (current == True) return False; else return True; - } - fprintf(stderr,"%s: bad action in _NET_WM_STATE (%d)\n", - argv0, (int) action); - return current; -} - -void -ewmh_set_allowed(Client *c) -{ -/* FIXME: this is dumb - the allowed actions should be calculuated - * but for now, anything goes. - */ - Atom action[4]; - - action[0] = ewmh_atom[_NET_WM_ACTION_MOVE]; - action[1] = ewmh_atom[_NET_WM_ACTION_RESIZE]; - action[2] = ewmh_atom[_NET_WM_ACTION_FULLSCREEN]; - action[3] = ewmh_atom[_NET_WM_ACTION_CLOSE]; - XChangeProperty(dpy, c->window, ewmh_atom[_NET_WM_ALLOWED_ACTIONS], - XA_ATOM, 32, PropModeReplace, (unsigned char *)action, 4); -} - -static Bool -valid_for_client_list(ScreenInfo *screen, Client *c) { - if (c->screen != screen) return False; - if (c->state == WithdrawnState) return False; - return True; -} - -/* -* update_client_list updates the properties on the root window used by -* task lists and pagers. -* -* it should be called whenever the window stack is modified, or when clients -* are hidden or unhidden. -*/ -void -ewmh_set_client_list(ScreenInfo *screen) { - int no_clients=0; - Window *client_list=NULL; - Window *stacked_client_list=NULL; - Client *c; - - if (screen == NULL || screen->ewmh_set_client_list == True) return; - screen->ewmh_set_client_list = True; - for (c = Client_List(); c; c = c->next) { - if (valid_for_client_list(screen, c) == True) no_clients++; - } - if (no_clients > 0) { - int i; - Window dw1; - Window dw2; - Window *wins; - unsigned int win; - unsigned int nwins; - - client_list = malloc(sizeof(Window) * no_clients); - i = no_clients - 1; /* array starts with oldest */ - for (c = Client_List(); c; c = c->next) { - if (valid_for_client_list(screen, c) == True) { - client_list[i] = c->window; - i--; - if (i < 0) break; - } - } - - stacked_client_list = malloc(sizeof(Window) * no_clients); - i = 0; - XQueryTree(dpy, screen->root, &dw1, &dw2, &wins, &nwins); - for (win = 0; win < nwins; win++) { - c = Client_Get(wins[win]); - if (!c) continue; - if (valid_for_client_list(screen, c) == True) { - stacked_client_list[i] = c->window; - i++; - if (i >= no_clients) break; - } - } - if ( nwins > 0 ) XFree(wins); - - } - XChangeProperty(dpy, screen->root, - ewmh_atom[_NET_CLIENT_LIST], - XA_WINDOW, 32, PropModeReplace, - (unsigned char*)client_list, no_clients); - XChangeProperty(dpy, screen->root, - ewmh_atom[_NET_CLIENT_LIST_STACKING], - XA_WINDOW, 32, PropModeReplace, - (unsigned char*)stacked_client_list, no_clients); - if (no_clients > 0 ) { - free(client_list); - free(stacked_client_list); - } - screen->ewmh_set_client_list = False; -} diff --git a/lwm b/lwm deleted file mode 100755 index b02fcae..0000000 Binary files a/lwm and /dev/null differ diff --git a/lwm.c b/lwm.c index 64359ec..713de18 100644 --- a/lwm.c +++ b/lwm.c @@ -87,7 +87,6 @@ main(int argc, char *argv[]) { wm_take_focus = XInternAtom(dpy, "WM_TAKE_FOCUS", False); wm_colormaps = XInternAtom(dpy, "WM_COLORMAP_WINDOWS", False); compound_text = XInternAtom(dpy, "COMPOUND_TEXT", False); - ewmh_init(); /* * Get fonts for our titlebar and our popup window. We try to @@ -115,7 +114,6 @@ main(int argc, char *argv[]) { } initScreens(); - ewmh_init_screens(); /* * Initialisation is finished, but we start off not interacting with the @@ -222,6 +220,7 @@ initScreens(void) { /* Find out how many screens we've got, and allocate space for their info. */ screen_count = ScreenCount(dpy); + printf("screens: %d\n", screen_count); screens = (ScreenInfo *) malloc(screen_count * sizeof(ScreenInfo)); /* Go through the screens one-by-one, initialising them. */ diff --git a/lwm.h b/lwm.h index 8bba70b..9789bcc 100644 --- a/lwm.h +++ b/lwm.h @@ -59,17 +59,6 @@ typedef enum { DSizeKeyboard, DMoveKeyboard } EWMHDirection; -/** -* EWMH window type. See section 5.6 of the EWMH specification (1.2). -* WTypeNone indicates that no EWMH window type as been set and MOTIF -* hints should be used instead. -*/ -typedef enum { - WTypeDesktop, WTypeDock, WTypeToolbar, - WTypeMenu, WTypeUtility, WTypeSplash, - WTypeDialog, WTypeNormal, WTypeNone -} EWMHWindowType; - /** * Screen information. */ @@ -92,6 +81,7 @@ struct ScreenInfo { /* Client flags for EWMH protocols and window behavior */ enum { +// F_FRAMED = (1 << 0), F_ACCEPT_FOCUS = (1 << 0), F_EWMH_DELETE = (1 << 1), F_EWMH_TAKE_FOCUS = (1 << 2), @@ -112,7 +102,6 @@ typedef struct Client { Edge cursor; /* indicates which cursor is being used for parent window */ IState internal_state; ScreenInfo * screen; - EWMHWindowType wtype; } Client; /* @@ -191,11 +180,5 @@ extern void manage(Client *, int); extern void getMousePosition(int *, int *); /* ewmh.c */ -extern Atom ewmh_atom[]; extern void ewmh_init(void); -extern void ewmh_init_screens(void); -extern EWMHWindowType ewmh_get_window_type(Window w); extern Bool ewmh_get_window_name(Client *c); -extern Bool ewmh_hasframe(Client *c); -extern void ewmh_set_allowed(Client *c); -extern void ewmh_set_client_list(ScreenInfo *screen); diff --git a/manage.c b/manage.c index 9558033..efa7165 100644 --- a/manage.c +++ b/manage.c @@ -50,12 +50,8 @@ manage(Client * c, int mapped) static int auto_x = 100; static int auto_y = 100; - /* get the EWMH window type, as this might overrule some hints */ - c->wtype = ewmh_get_window_type(c->window); - /* set EWMH allowable actions, now we intend to manage this window */ - ewmh_set_allowed(c); /* is this window to have a frame? */ - c->framed = ewmh_hasframe(c); + c->framed = True; /* * Get the hints, window name, and normal hints (see ICCCM