Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bar possibly attaching to stack, updated XCBInitAtoms + override redirect flag #129

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions dwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ int ISALWAYSONTOP(Client *c) { return c->wstateflags & _STATE_ABOVE; }
int ISALWAYSONBOTTOM(Client *c) { return c->wstateflags & _STATE_BELOW; }
int WASFLOATING(Client *c) { return c->flags & _FSTATE_WASFLOATING; }
int ISFLOATING(Client *c) { return c->flags & _FSTATE_FLOATING; }
int ISOVERRIDEREDIRECT(Client *c) { return c->flags & _FSTATE_OVERRIDE_REDIRECT; }
int ISFAKEFLOATING(Client *c) { return c->flags & _FSTATE_FLOATING || c->desktop->layout == Floating; }

int WASDOCKEDVERT(Client *c) { const i16 wy = c->desktop->mon->wy;
Expand Down Expand Up @@ -443,7 +444,8 @@ arrangedesktop(Desktop *desk)

/* Macro helper */
#define __attach_helper(STRUCT, HEAD, NEXT, PREV, LAST) do \
{ STRUCT->NEXT = STRUCT->HEAD; \
{ \
STRUCT->NEXT = STRUCT->HEAD; \
STRUCT->HEAD = STRUCT; \
if(STRUCT->NEXT) \
{ STRUCT->NEXT->PREV = STRUCT; \
Expand Down Expand Up @@ -505,6 +507,9 @@ arrangedesktop(Desktop *desk)
void
attach(Client *c)
{
if(ISOVERRIDEREDIRECT(c))
{ return;
}
__attach_helper(c, desktop->clients, next, prev, desktop->clast);
}

Expand Down Expand Up @@ -537,24 +542,36 @@ attachdesktoplast(Monitor *m, Desktop *desk)
void
attachstack(Client *c)
{
if(ISOVERRIDEREDIRECT(c))
{ return;
}
__attach_helper(c, desktop->stack, snext, sprev, desktop->slast);
}

void
attachrestack(Client *c)
{
if(ISOVERRIDEREDIRECT(c))
{ return;
}
__attach_helper(c, desktop->rstack, rnext, rprev, desktop->rlast);
}

void
attachfocus(Client *c)
{
if(ISOVERRIDEREDIRECT(c))
{ return;
}
__attach_helper(c, desktop->focus, fnext, fprev, desktop->flast);
}

void
attachfocusafter(Client *start, Client *after)
{
if(ISOVERRIDEREDIRECT(after))
{ return;
}
Desktop *desk = start->desktop;
detachfocus(after);
__attach_after(start, after, fnext, fprev, desk->focus, desk->slast);
Expand All @@ -563,6 +580,9 @@ attachfocusafter(Client *start, Client *after)
void
attachfocusbefore(Client *start, Client *after)
{
if(ISOVERRIDEREDIRECT(after))
{ return;
}
Desktop *desk = start->desktop;
detachfocus(after);
__attach_before(start, after, fnext, fprev, desk->focus, desk->slast, attachfocus);
Expand Down Expand Up @@ -1077,6 +1097,9 @@ createdecoration(void)
decor->h = 0;
decor->win = 0;
}
/*
_NET_WM_FRAME_DRAWN, _NET_WM_FRAME_TIMINGS, _NET_WM_WINDOW_OPACITY, _NET_RESTACK_WINDOW, _GTK_FRAME_EXTENTS, _GTK_SHOW_WINDOW_MENU, _GTK_EDGE_CONSTRAINTS, _GTK_WORKAREAS
*/
return decor;
}

Expand Down Expand Up @@ -1593,6 +1616,7 @@ managereply(XCBWindow win, XCBCookie requests[MANAGE_CLIENT_COOKIE_COUNT])
{
detachcompletely(c);
setborderwidth(c, 0);
setoverrideredirect(c, 1);
configure(c);
c->desktop->mon->bar = c;
c = NULL;
Expand Down Expand Up @@ -1924,6 +1948,7 @@ restoresession(void)
}
}
}
focus(NULL);
arrangemons();
/* No need to flush run() syncs for us */
/* XCBFlush(_wm.dpy) */
Expand Down Expand Up @@ -2527,7 +2552,6 @@ scan(void)
else
{ DEBUG0("Failed to scan for clients.");
}
focus(NULL);
/* restore session covers this after */
/* arrangemons(); */
}
Expand Down Expand Up @@ -2931,6 +2955,11 @@ setmondesktop(Monitor *m, Desktop *desk)
{
m->desksel = desk;
}
void
setoverrideredirect(Client *c, uint8_t state)
{
SETFLAG(c->flags, _FSTATE_OVERRIDE_REDIRECT, !!state);
}

void
setsticky(Client *c, u8 state)
Expand Down Expand Up @@ -2974,7 +3003,12 @@ setup(void)
setupcursors();
setupcfg();
XCBCookie motifcookie = XCBInternAtomCookie(_wm.dpy, "_MOTIF_WM_HINTS", False);
XCBInitAtoms(_wm.dpy, wmatom, netatom);
XCBCookie wmcookie[WMLast];
XCBCookie netcookie[NetLast];
XCBInitWMAtomsCookie(_wm.dpy, (XCBCookie *)wmcookie);
XCBInitNetWMAtomsCookie(_wm.dpy, (XCBCookie *)netcookie);
XCBInitWMAtomsReply(_wm.dpy, wmcookie, wmatom);
XCBInitNetWMAtomsReply(_wm.dpy, netcookie, netatom);
motifatom = XCBInternAtomReply(_wm.dpy, motifcookie);
/* supporting window for NetWMCheck */
_wm.wmcheckwin = XCBCreateSimpleWindow(_wm.dpy, _wm.root, 0, 0, 1, 1, 0, 0, 0);
Expand Down
13 changes: 9 additions & 4 deletions dwm.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
#define MANAGE_CLIENT_COOKIE_COUNT 16 + 1

/* Client struct flags */
#define _FSTATE_FLOATING ((1 << 0))
#define _FSTATE_WASFLOATING ((1 << 1))
#define _FSTATE_SHOW_DECOR ((1 << 2))

#define _FSTATE_FLOATING ((1 << 0))
#define _FSTATE_WASFLOATING ((1 << 1))
#define _FSTATE_SHOW_DECOR ((1 << 2))
#define _FSTATE_OVERRIDE_REDIRECT ((1 << 3))
/* EWMH window types */
#define _TYPE_DESKTOP ((1 << 0))
#define _TYPE_DOCK ((1 << 1))
Expand Down Expand Up @@ -728,6 +728,10 @@ void setshaded(Client *c, uint8_t state);
void setmodal(Client *c, uint8_t state);
/* Sets the monitors currently selected desktop. */
void setmondesktop(Monitor *m, Desktop *desk);
/* Sets override redirect flag, which disallows attaching to any linked list for a desktop
* But still allows a client to be found using wintoclient()
*/
void setoverrideredirect(Client *c, uint8_t state);
/* Replaces the Clients state with the sticky state, and sets IS sticky Flag. */
void setsticky(Client *c, uint8_t state);
/* Vital checks and data setup before any other action is performed. */
Expand Down Expand Up @@ -869,6 +873,7 @@ int ISALWAYSONTOP(Client *c);
int ISALWAYSONBOTTOM(Client *c);
int WASFLOATING(Client *c);
int ISFLOATING(Client *c);
int ISOVERRIDEREDIRECT(Client *c);
int ISFAKEFLOATING(Client *c);
int DOCKEDVERT(Client *c);
int DOCKEDHORZ(Client *c);
Expand Down