From: Michael D. Lowis Date: Thu, 15 Aug 2024 02:54:57 +0000 (-0400) Subject: start adding hooks for handling state messages X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=f6eea23829ad1b145911a66a5ebada687080f6e8;p=proto%2Fanvil.git start adding hooks for handling state messages --- diff --git a/anvil.c b/anvil.c index ba98d6f..26bdebf 100644 --- a/anvil.c +++ b/anvil.c @@ -162,10 +162,17 @@ static void XClientMsg(XEvent* e) } else if (ev->message_type == _NET_WM_STATE) { - printf(" %ld\n", ev->data.l[0]); - printf(" %s\n", XGetAtomName(X.disp, ev->data.l[1])); - EWMH_UpdateWindowStateFlags( - ev->window, ev->data.l[0], ev->data.l[1]); + Client* c = Client_Find(ev->window); + if (c) + { + Client_UpdateWindowState(c, ev->data.l[0], ev->data.l[1]); + } + + +// printf(" %ld\n", ev->data.l[0]); +// printf(" %s\n", XGetAtomName(X.disp, ev->data.l[1])); +// EWMH_UpdateWindowStateFlags( +// ev->window, ev->data.l[0], ev->data.l[1]); } /* @@ -174,8 +181,6 @@ static void XClientMsg(XEvent* e) * handle active window (set urgency) */ - - } static void XPropNotify(XEvent* e) diff --git a/anvil.h b/anvil.h index 77e0b8d..0847494 100644 --- a/anvil.h +++ b/anvil.h @@ -166,6 +166,7 @@ void Client_Focus(Client* client); void Client_Close(Client* client); void Client_UpdateAll(void); void Client_Place(Client* c); +void Client_UpdateWindowState(Client* c, int op, Atom prop); /* mouse.c */ void Mouse_Down(XButtonEvent* ev); @@ -190,6 +191,9 @@ int EWMH_GetWindowTypeFlags(Window w); int EWMH_GetWindowStateFlags(Window w); void EWMH_SetWindowStateFlags(Window w, int flags); void EWMH_UpdateWindowStateFlags(Window w, int op, Atom prop); + +int EWMH_GetFlagId(Atom* atoms, size_t natoms, Atom prop); + //void EWMH_GetWindowStrut(Strut* strut); int EWMH_GetWindowPid(Window w); void EWMH_SetWindowFrameExtents(Window w, int left, int right, int top, int bottom); diff --git a/client.c b/client.c index 629abfc..e31c328 100644 --- a/client.c +++ b/client.c @@ -278,6 +278,51 @@ void Client_UpdateAll(void) } } +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); + } + + + + +// 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); +// } +// } +} + + + + + + + + + + + //void client_shade(Client* c) //{ // client_setshade(c, ((c->flags & F_SHADED) ? 0 : 1)); @@ -508,11 +553,12 @@ static void* ListDelete(void* list, void* node) } } -static void UpdateState(Client* c) -{ - int frame_shown = 1; - int window_shown = 1; - int save_size_and_pos = 1; +//static void UpdateState(Client* c) +//{ +// (void)c; +// int frame_shown = 1; +// int window_shown = 1; +// int save_size_and_pos = 1; /* if (fullscreen) @@ -573,5 +619,5 @@ static void UpdateState(Client* c) redraw */ -} +//} diff --git a/ewmh.c b/ewmh.c index 1d63ddb..1ce691b 100644 --- a/ewmh.c +++ b/ewmh.c @@ -129,7 +129,7 @@ void EWMH_SetWindowStateFlags(Window w, int flags) WriteFlagHint(w, _NET_WM_STATE, WindowState, nelem(WindowState), flags); } -static int GetFlagId(Atom* atoms, size_t natoms, Atom prop) +int EWMH_GetFlagId(Atom* atoms, size_t natoms, Atom prop) { int id = -1; for (size_t i = 0; i < natoms; i++) @@ -143,31 +143,31 @@ static int GetFlagId(Atom* atoms, size_t natoms, Atom prop) return id; } -void EWMH_UpdateWindowStateFlags(Window w, int op, Atom prop) -{ - Client* c = Client_Find(w); - if (c) - { - int id = 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); - } - } - } -} +//void EWMH_UpdateWindowStateFlags(Window w, int op, Atom prop) +//{ +// Client* c = Client_Find(w); +// if (c) +// { +// int id = 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); +// } +// } +// } +//} //void EWMH_GetWindowStrut(Strut* strut) //{ diff --git a/mouse.c b/mouse.c index 8ce657b..ac420c8 100644 --- a/mouse.c +++ b/mouse.c @@ -43,19 +43,6 @@ static void shade_client(Client* client) // client_shade(client); } -static void lower_client(Client* client) -{ - (void)client; -// mons_lower(loc->monitor, loc->client); - Client_Lower(client); -} - -static void raise_client(Client* client) -{ - Client_Raise(client); -// mons_raise(loc->monitor, loc->client); -} - //static void stack_clients(Client* client) //{ // (void)client; @@ -73,8 +60,6 @@ MouseAct Floating[] = { { MODKEY|ShiftMask, Button2, ButtonPress, toggle_float }, { MODKEY, Button2, ButtonPress, close_client }, { 0, Button3, ButtonPress, shade_client }, - { 0, Button4, ButtonPress, lower_client }, - { 0, Button5, ButtonPress, raise_client } }; // //MouseAct Stacked[] = {