diff options
author | okan <okan> | 2019-03-11 15:25:46 +0000 |
---|---|---|
committer | okan <okan> | 2019-03-11 15:25:46 +0000 |
commit | 85d88f33042f7c397b75513e1561b361815caad7 (patch) | |
tree | 5ce311934b167cd4b8514edf062923fd2910eb84 /screen.c | |
parent | 412b0c9ef4429d48c200910ffcc8a18b60f815ea (diff) | |
parent | 9a7528f5b99bd234f724aa229cbf75fb6a813282 (diff) | |
download | cwm-85d88f33042f7c397b75513e1561b361815caad7.tar.gz cwm-85d88f33042f7c397b75513e1561b361815caad7.tar.xz cwm-85d88f33042f7c397b75513e1561b361815caad7.zip |
cvsimport
* refs/heads/master: (23 commits) Check the atom type on propertynotify before iterating. use screen_find() for xrandr crtc changes Find the managed screen from the parent window for client_current(). Print window id in hex; while here, remove unnecessary newline. Similar to keypress event, fetch the screen from the event root window in the buttonpress handler; bail if we don't manage the screen. Allows us to find the current client based on the screen/event root. extend verbose logging for key/button events [keypress event] turns out we've been checking the wrong window for a matching client thus always falling back to client_current(); while the current client is problaby right in most cases, use event's subwindow (not window) to find the client. Bail early if this event came to us from a screen we don't manage. This is result of us grabing all keybindings off the root window instead of selectively. add parans for readibility Teach client_current() to use a screen to find the current client instead of iterating over all (fallback if no screen provided for now). Initially convert trivial uses of client_current(). check cc->gc directly zip extra lines gc clientq inside groups, instead use the better maintained one per-screen shuffle deck chairs: rename group actions to match intent for clarity same thing as screen_find() Separate out the menu window from the client resize/move geom window; in each case, create and destroy on-demand. Isolate more menu specific code. fix a few misplaced (and misnamed) ewmh root window functions _NET_WORKAREA needs ngroups, so screen_update_geometry() needs to come after conf_group(). simplify xftcolor config Tie group number and name together during config. Move the group index (desktop number) check to the only 2 callers that require checking due to ewmh. ...
Diffstat (limited to 'screen.c')
-rw-r--r-- | screen.c | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/screen.c b/screen.c index 2c0b8c1..7565703 100644 --- a/screen.c +++ b/screen.c @@ -24,6 +24,7 @@ #include <err.h> #include <errno.h> #include <limits.h> +#include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -40,7 +41,6 @@ screen_init(int which) Window *wins, w0, w1, active = None; XSetWindowAttributes rootattr; unsigned int nwins, w; - int i; sc = xmalloc(sizeof(*sc)); @@ -60,14 +60,11 @@ screen_init(int which) xu_ewmh_net_supported(sc); xu_ewmh_net_supported_wm_check(sc); + conf_group(sc); screen_update_geometry(sc); - for (i = 0; i < Conf.ngroups; i++) - group_init(sc, i); - xu_ewmh_net_desktop_names(sc); - xu_ewmh_net_wm_desktop_viewport(sc); - xu_ewmh_net_wm_number_of_desktops(sc); + xu_ewmh_net_number_of_desktops(sc); xu_ewmh_net_showing_desktop(sc); xu_ewmh_net_virtual_roots(sc); active = xu_ewmh_get_net_active_window(sc); @@ -106,7 +103,7 @@ screen_find(Window win) if (sc->rootwin == win) return(sc); } - warnx("%s: failure win 0x%lu\n", __func__, win); + warnx("%s: failure win 0x%lx", __func__, win); return(NULL); } @@ -217,6 +214,7 @@ screen_update_geometry(struct screen_ctx *sc) } xu_ewmh_net_desktop_geometry(sc); + xu_ewmh_net_desktop_viewport(sc); xu_ewmh_net_workarea(sc); } @@ -253,3 +251,47 @@ screen_assert_clients_within(struct screen_ctx *sc) } } } + +void +screen_prop_win_create(struct screen_ctx *sc, Window win) +{ + sc->prop.win = XCreateSimpleWindow(X_Dpy, win, 0, 0, 1, 1, 0, + sc->xftcolor[CWM_COLOR_MENU_BG].pixel, + sc->xftcolor[CWM_COLOR_MENU_BG].pixel); + sc->prop.xftdraw = XftDrawCreate(X_Dpy, sc->prop.win, + sc->visual, sc->colormap); + + XMapWindow(X_Dpy, sc->prop.win); +} + +void +screen_prop_win_destroy(struct screen_ctx *sc) +{ + XftDrawDestroy(sc->prop.xftdraw); + XDestroyWindow(X_Dpy, sc->prop.win); +} + +void +screen_prop_win_draw(struct screen_ctx *sc, const char *fmt, ...) +{ + va_list ap; + int i; + char *text; + XGlyphInfo extents; + + va_start(ap, fmt); + i = vasprintf(&text, fmt, ap); + va_end(ap); + if (i < 0 || text == NULL) + err(1, "vasprintf"); + + XftTextExtentsUtf8(X_Dpy, sc->xftfont, (const FcChar8*)text, + strlen(text), &extents); + XResizeWindow(X_Dpy, sc->prop.win, extents.xOff, sc->xftfont->height); + XClearWindow(X_Dpy, sc->prop.win); + XftDrawStringUtf8(sc->prop.xftdraw, &sc->xftcolor[CWM_COLOR_MENU_FONT], + sc->xftfont, 0, sc->xftfont->ascent + 1, + (const FcChar8*)text, strlen(text)); + + free(text); +} |