From 5bebde59c93312d0cef33b7e62f37dd3bc939ce0 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 8 Mar 2017 18:31:29 -0800 Subject: overlays: encapsulate global overlays state Introduce vwm_overlays_t and create/destroy functions, use in vwm_startup() and vwm_shutdown(). Supply to methods operating on the global overlays state vwm_overlays_update(), vwm_overlays_rate_increase(), vwm_overlays_rate_decrease(). This is a fairly minimal adoption of these changes with vwm_t still being supplyed to the overlay functions. A future commit will further cleanup the interactions and cease all knowledge of vwm_t in overlays.c, but for now everything overlay-oriented still accesses the overlays_t instance via vwm_t. Instead of supplying the vwm_t to vwm_overlays_create() the bare vwm_xserver_t will be supplied, as this is the future shared component across vmon and vwm (in addition to overlays). --- src/vwm.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/vwm.c') diff --git a/src/vwm.c b/src/vwm.c index 9424c04..979824a 100644 --- a/src/vwm.c +++ b/src/vwm.c @@ -42,6 +42,7 @@ #include "desktop.h" #include "launch.h" #include "logo.h" +#include "overlays.h" #include "vwm.h" #include "xevent.h" #include "xwindow.h" @@ -78,15 +79,20 @@ static vwm_t * vwm_startup(void) goto _err_free; } + if (!(vwm->overlays = vwm_overlays_create(vwm))) { + VWM_ERROR("Failed to create overlays"); + goto _err_xclose; + } + /* query the needed X extensions */ if (!XQueryExtension(VWM_XDISPLAY(vwm), COMPOSITE_NAME, &composite_opcode, &composite_event, &composite_error)) { VWM_ERROR("No composite extension available"); - goto _err_xclose; + goto _err_overlays; } if (!XDamageQueryExtension(VWM_XDISPLAY(vwm), &vwm->damage_event, &vwm->damage_error)) { VWM_ERROR("No damage extension available"); - goto _err_xclose; + goto _err_overlays; } if (XSyncQueryExtension(VWM_XDISPLAY(vwm), &sync_event, &sync_error)) { @@ -105,7 +111,7 @@ static vwm_t * vwm_startup(void) /* get our scheduling priority, clients are launched with a priority LAUNCHED_RELATIVE_PRIORITY nicer than this */ if ((vwm->priority = getpriority(PRIO_PROCESS, getpid())) == -1) { VWM_ERROR("Cannot get scheduling priority"); - goto _err_xclose; + goto _err_overlays; } vwm->wm_delete_atom = XInternAtom(VWM_XDISPLAY(vwm), "WM_DELETE_WINDOW", False); @@ -155,6 +161,8 @@ static vwm_t * vwm_startup(void) return vwm; +_err_overlays: + vwm_overlays_destroy(vwm->overlays); _err_xclose: vwm_xserver_close(vwm->xserver); @@ -172,6 +180,7 @@ void vwm_shutdown(vwm_t *vwm) char *quit_console_args[] = {"/bin/sh", "-c", "screen -dr " CONSOLE_SESSION_STRING " -X quit", NULL}; vwm_launch(vwm, quit_console_args, VWM_LAUNCH_MODE_FG); + vwm_overlays_destroy(vwm->overlays); vwm_xserver_close(vwm->xserver); /* TODO there's more shit to cleanup here, but we're exiting anyways. */ free(vwm); @@ -302,7 +311,8 @@ int main(int argc, char *argv[]) do { int delay; - vwm_overlay_update(vwm, &delay); + vwm_overlays_update(vwm->overlays, &delay); + XFlush(VWM_XDISPLAY(vwm)); if (!XPending(VWM_XDISPLAY(vwm))) { -- cgit v1.2.3