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

Manage helper SHOULDMANAGE() #471

Merged
merged 2 commits into from
Nov 7, 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
1 change: 1 addition & 0 deletions include/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ uint32_t DOCKEDINITIAL(Client *c);
uint32_t WASDOCKEDVERT(Client *c);
uint32_t WASDOCKEDHORZ(Client *c);
uint32_t WASDOCKED(Client *c);
uint32_t SHOULDMANAGE(const XCBWindow window);
uint32_t ISFIXED(Client *c);
uint32_t ISURGENT(Client *c);
/* flag */
Expand Down
31 changes: 25 additions & 6 deletions src/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,28 @@ u32 DOCKEDINITIAL(Client *c) { Monitor *m = c->desktop->mon;
;
}

u32 SHOULDMANAGE(const XCBWindow window)
{
Client *c = wintoclient(window);
XCBWindow already_managed_window = c ? c->win : 0;
const XCBWindow INVALID_WINDOW[] =
{
XCB_NONE,
_wm.root,
_wm.wmcheckwin,
already_managed_window,
};

int i;
for(i = 0; i < LENGTH(INVALID_WINDOW); ++i)
{
if(window == INVALID_WINDOW[i])
{ return 0;
}
}

return 1;
}
u32 ISFIXED(Client *c) { return (c->minw != 0) && (c->minh != 0) && (c->minw == c->maxw) && (c->minh == c->maxh); }
u32 ISURGENT(Client *c) { return c->ewmhflags & WStateFlagDemandAttention; }
/* flag */
Expand Down Expand Up @@ -1483,14 +1505,11 @@ manage(XCBWindow win, void *replies[ManageClientLAST])
Monitor *m = NULL;
Client *c = NULL;
/* checks */
if(win == _wm.root)
{ Debug("%s", "Cannot manage() root window.");
if(!SHOULDMANAGE(win))
{
Debug("Cannot manage(): [%u]", win);
goto FAILURE;
}
else if(wintoclient(win))
{ Debug("Window already managed????: [%u]", win);
goto FAILURE;
}

const u16 bw = 0;
const u32 bcol = 0;
Expand Down