From: Mike Lowis Date: Thu, 15 Aug 2024 20:13:47 +0000 (-0400) Subject: start responding to client messages X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=e107fd2bd88aae285c03cf65222d843750b94f17;p=proto%2Fanvil.git start responding to client messages --- diff --git a/client.c b/client.c index e31c328..78afc3d 100644 --- a/client.c +++ b/client.c @@ -5,6 +5,10 @@ #define LIST_FOR_EACH(val,list) \ for (val = list; (val != NULL); val = val->next) +static int UpdateStateFlag(Client* c, int op, Atom prop); +static void UpdateHiddenState(Client* c, int op); +static void UpdateFullscreenState(Client* c, int op); + static void ReadProps(Client* c); static void Redraw(Client* c); static void LayerWindows(void); @@ -81,37 +85,40 @@ Client* Client_Create(Window win) void Client_Show(Client* c) { - /* position it with relative coords */ - Monitor* mon = &Monitors[Workspaces[c->wspace].monitor]; - c->x = mon->x + c->rel_x; - c->y = mon->y + c->rel_y; - Client_MoveResize(c); - - /* set mouse to titlebar if mapping for first time */ - if (!(c->wm_flags & F_MAPPED_ONCE)) - { - int mon = Monitors_GetActiveMonitor(); - c->wspace = Monitors[mon].wspace; - c->x = Monitors[mon].midx - c->w/2; - c->y = Monitors[mon].midy - c->h/2; - Client_MoveResize(c); - Mouse_ToTitle(c); - c->wm_flags |= F_MAPPED_ONCE; - } - - /* update, map and redraw */ - ReadProps(c); - SetWMState(c, NormalState); - XMapWindow(X.disp, c->frame); - XMapWindow(X.disp, c->win); - Redraw(c); +// /* position it with relative coords */ +// Monitor* mon = &Monitors[Workspaces[c->wspace].monitor]; +// c->x = mon->x + c->rel_x; +// c->y = mon->y + c->rel_y; +// Client_MoveResize(c); +// +// /* set mouse to titlebar if mapping for first time */ +// if (!(c->wm_flags & F_MAPPED_ONCE)) +// { +// int mon = Monitors_GetActiveMonitor(); +// c->wspace = Monitors[mon].wspace; +// c->x = Monitors[mon].midx - c->w/2; +// c->y = Monitors[mon].midy - c->h/2; +// Client_MoveResize(c); +// Mouse_ToTitle(c); +// c->wm_flags |= F_MAPPED_ONCE; +// } +// +// /* update, map and redraw */ +// ReadProps(c); +// SetWMState(c, NormalState); +// XMapWindow(X.disp, c->frame); +// XMapWindow(X.disp, c->win); +// Redraw(c); + + UpdateHiddenState(c, CLR_FLAG); } void Client_Hide(Client* c) { - SetWMState(c, HiddenState); - XUnmapWindow(X.disp, c->frame); - XUnmapWindow(X.disp, c->win); +// SetWMState(c, HiddenState); +// XUnmapWindow(X.disp, c->frame); +// XUnmapWindow(X.disp, c->win); + UpdateHiddenState(c, SET_FLAG); } void Client_Destroy(Client* c) @@ -278,50 +285,93 @@ void Client_UpdateAll(void) } } -void Client_UpdateWindowState(Client* c, int op, Atom prop) +static int UpdateStateFlag(Client* c, int op, Atom prop) { - (void)c, (void)op; - if (prop == _NET_WM_STATE_HIDDEN) + int setting = 0; + int id = EWMH_GetFlagId(WindowState, nelem(WindowState), prop); + assert(id >= 0); + if (op == 2) { -// UpdateHiddenState(c, op); + setting = ((c->wm_state & (1 << id)) == 0); } - else if (prop == _NET_WM_STATE_FULLSCREEN) + + if (setting) { -// UpdateFullscreenState(c, op); + c->wm_state |= (1 << id); + } + else + { + c->wm_state &= ~(1 << id); } - - - -// int id = EWMH_GetFlagId(WindowState, nelem(WindowState), prop); -// if (id >= 0) -// { -// int clearing = 0; -// if (op == 2) -// { -// clearing = ((c->wm_state & (1 << id)) != 0); -// } -// -// if (clearing) -// { -// c->wm_state &= ~(1 << id); -// } -// else -// { -// c->wm_state |= (1 << id); -// } -// } + return setting; } +static void UpdateHiddenState(Client* c, int op) +{ + if (UpdateStateFlag(c, op, _NET_WM_STATE_HIDDEN)) + { + SetWMState(c, HiddenState); + XUnmapWindow(X.disp, c->frame); + XUnmapWindow(X.disp, c->win); + } + else + { + /* position it with relative coords */ + Monitor* mon = &Monitors[Workspaces[c->wspace].monitor]; + c->x = mon->x + c->rel_x; + c->y = mon->y + c->rel_y; + Client_MoveResize(c); + /* set mouse to titlebar if mapping for first time */ + if (!(c->wm_flags & F_MAPPED_ONCE)) + { + int mon = Monitors_GetActiveMonitor(); + c->wspace = Monitors[mon].wspace; + c->x = Monitors[mon].midx - c->w/2; + c->y = Monitors[mon].midy - c->h/2; + Client_MoveResize(c); + Mouse_ToTitle(c); + c->wm_flags |= F_MAPPED_ONCE; + } + /* update, map and redraw */ + ReadProps(c); + SetWMState(c, NormalState); + XMapWindow(X.disp, c->frame); + XMapWindow(X.disp, c->win); + Redraw(c); + } +} +static void UpdateFullscreenState(Client* c, int op) +{ + if (UpdateStateFlag(c, op, _NET_WM_STATE_FULLSCREEN)) + { + // mark it as fullscreen on workspace + // unmap or shrink frame + // move/resize to full workspace + } + else + { + // mark it as fullscreen on workspace + // map or grow frame + // move/resize to original location + } +} - - - - - +void Client_UpdateWindowState(Client* c, int op, Atom prop) +{ + (void)c, (void)op; + if (prop == _NET_WM_STATE_HIDDEN) + { + UpdateHiddenState(c, op); + } + else if (prop == _NET_WM_STATE_FULLSCREEN) + { + UpdateFullscreenState(c, op); + } +} //void client_shade(Client* c) //{