Cloudef / monsterwm-xcb

Port of monsterwm to xcb
Other
37 stars 10 forks source link

Dialogs from other busy programs or upload files from the browser conflict with monsterwm-xcb #8

Open su8 opened 3 months ago

su8 commented 3 months ago

Uploading files or closing xfce terminal with busy tabs conflict and they try to steal the focus which makes them completely unclosable and when I kill the dialog window it closes the entire browser/terminal. The WM is compiled with FOLLOW_MOUSE True, CLICK_TO_FOCUS False if I set the CLICK_TO_FOCUS to True and FOLLOW_MOUSE False -- it's working correctly.

edit:

Try to simulate busy xfce terminal. Type in at least 2 tabs: while true; do sleep 1;done and try to close it with keyboard combo buttons. The terminal must NOT be the only launched program, because the closing dialog works fine in this scenario. Open up other program.

To test the uploading scenario seek google to upload some images.

su8 commented 3 months ago

2024-08-08-123657_1920x944_scrot

As you can see the browser is behind all windows.

2024-08-08-123715_1920x944_scrot

And this is what it looks like when the windows are closed, the terminal is not expanded to fullscreen, I must to set the current tag/workspace to tiled or other mode manually.

2024-08-08-123747_1920x944_scrot

su8 commented 3 months ago

@sulami @c00kiemon5ter your FrankenWM and monsterwm are having the same issue like the one described here.

su8 commented 3 months ago

I have fixed it in my hellxcb fork - https://github.com/su8/hellxcb , commits are - https://github.com/su8/hellxcb/commit/0c1b4f8def3c30e1cb25ae8b09a619cdfb65274a , https://github.com/su8/hellxcb/commit/5b91d54be7fbd8d195d462428eaaeb4cc8a2832f

su8 commented 3 months ago

I have also fixed flickering and freezing of floating programs such as gimp as he tried to steal the focus with the Grid mode/layout https://github.com/su8/hellxcb/commit/0cf2cc211d9380e344b5538f3cf9333d02838c36

edit: To try it out, start with Tiled mode and open up some programs e.g for example 2 terminals and Gimp, then switch to Grid mode/layout to see the bug in action.

su8 commented 3 months ago

I have fixed yet another bug.

When resizing/moving window manually and spawning a new one they fight for the focus until the mouse pointer is moved away or switching to another layout/mode - https://github.com/su8/hellxcb/commit/32b4cc7fbfe5faf5fa61b2a9a84bd8fba7846281

su8 commented 3 months ago

Here's a patch to be applied by monsterwm-xcb, watch out it will comment in the monocle code.

1,2c1,17
< /* see license for copyright and license */
< 
---
> /*
> Copyright 08/07/2024 https://github.com/su8/hellxcb
> This program is free software; you can redistribute it and/or modify
> it under the terms of the GNU General Public License as published by
> the Free Software Foundation; either version 2 of the License, or
> (at your option) any later version.
> 
> This program is distributed in the hope that it will be useful,
> but WITHOUT ANY WARRANTY; without even the implied warranty of
> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> GNU General Public License for more details.
> 
> You should have received a copy of the GNU General Public License
> along with this program; if not, write to the Free Software
> Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
> MA 02110-1301, USA.
> */
42a58,63
> static unsigned int workspaces[][2] = { {0, 0}, {0, 0}, {0, 0}, {0, 0}}; /* show how many windows are opened in all tags/workspaces */
> static unsigned int currentworkspace = 0U; /* to count how many windows are opened in all tags/workspaces */
> static unsigned int moveResizeDetected = 0U; /* Don't flicker/freeze when using the manual resizing/moving a window, this variable is used as flag to set wheter it will steal the focus from another window or not */
> static unsigned int numOfWindows = 0U; /* count how many windows are in the currently working tag/workspace */
> static unsigned int stealFocus = 0U; /* don't steal focus from busy programs/uplod file dialogs */
> 
50c71
< #define USAGE           "usage: monsterwm [-h] [-v]"
---
> #define USAGE           "usage: hellxcb [-h] [-v]"
53c74
< enum { TILE, MONOCLE, BSTACK, GRID, MODES };
---
> enum { TILE, BSTACK, GRID, MODES };
138a160
> static void aDontStealFocus(const Arg *arg);
145a168
> static void cycle_mode(const Arg *arg);
159c182
< static void monocle(int h, int y);
---
> /*static void monocle(int h, int y);*/
213c236
<     [TILE] = stack, [BSTACK] = stack, [GRID] = grid, [MONOCLE] = monocle,
---
>     [TILE] = stack, [BSTACK] = stack, [GRID] = grid,
296c319
<         } else puts("WARN: monsterwm failed to register %s atom.\nThings might not work right.");
---
>         } else puts("WARN: hellxcb failed to register %s atom.\nThings might not work right.");
317a341,346
> /* manually set stealFocus to be used by FOLLOW_MOUSE macro */
>  static void aDontStealFocus(const Arg *arg) {
>     (void)arg;
>     stealFocus = 0U;
>  }
> 
363a393,395
>     numOfWindows = 0U;
>     workspaces[arg->i][1] = 0U;
>     currentworkspace = arg->i;
372a405
>     for (client *c2=head; c2; c2=c2->next) workspaces[arg->i][1]++;
409a443,446
>     //for (client *c2=head; c2; c2=c2->next) { if (c2) continue; workspaces[currentworkspace][1]++; }
>     workspaces[arg->i][1]++; 
>     workspaces[currentworkspace][1]--;
> 
459a497,507
> /* cycle thru all of the tiling modes and reset all floating windows */
> void cycle_mode(const Arg *arg) {
>     (void)arg;
>     static unsigned int x = 0U;
>     for (client *c=head; c; c=c->next) c->isfloating = False;
>     if (x >= 3U) x = 0U;
>     mode = x++;
>     tile(); update_current(current);
>     desktopinfo();
> }
> 
515c563
<     if (c && ev->mode == XCB_NOTIFY_MODE_NORMAL && ev->detail != XCB_NOTIFY_DETAIL_INFERIOR) update_current(c);
---
>     if (c && ev->mode == XCB_NOTIFY_MODE_NORMAL && ev->detail != XCB_NOTIFY_DETAIL_INFERIOR && !stealFocus) update_current(c);
575a624,625
>     numOfWindows = 0U;
>     workspaces[currentworkspace][1] = 0U;
583c633,634
<         if (ISFFT(c)) continue; else ++i;
---
>         if (c->isfloating) continue;
>         if (ISFFT(c)) continue; else { ++i; numOfWindows++; workspaces[currentworkspace][1]++; }
613a665,666
>     numOfWindows == 1U ? numOfWindows-- : 0;
>     workspaces[currentworkspace][1] == 1U ? workspaces[currentworkspace][1]-- : 0;
686a740,744
>     if (c->isfloating) stealFocus = 1U;
>     else { c->isfloating = 0; stealFocus = 0U; }
> 
>     //for (client *c2=head; c2; c2=c2->next) { if (c2) continue; workspaces[currentworkspace][1]++; }
> 
747c805
<     if (!current->isfloating) current->isfloating = True;
---
>     if (!current->isfloating && moveResizeDetected == 1U) current->isfloating = True;
758a817
>             {
759a819,820
>                 moveResizeDetected = 0U;
>             }
761a823
>             {
765,766c827,828
<                 if (arg->i == RESIZE) xcb_resize(dis, current->win, xw>MINWSZ?xw:winw, yh>MINWSZ?yh:winh);
<                 else if (arg->i == MOVE) xcb_move(dis, current->win, xw, yh);
---
>                 if (arg->i == RESIZE) { xcb_resize(dis, current->win, xw>MINWSZ?xw:winw, yh>MINWSZ?yh:winh); moveResizeDetected = 1U; }
>                 else if (arg->i == MOVE) { xcb_move(dis, current->win, xw, yh); moveResizeDetected = 1U; }
767a830
>             }
772a836
>             {
773a838,841
>                 moveResizeDetected = 0U;
>             }
>                 break;
>             default: break;
781c849
< void monocle(int hh, int cy) {
---
> /*void monocle(int hh, int cy) {
783c851
< }
---
> }*/
981a1050,1051
>     static FILE *fp = NULL;
>     static char *styles_arr[] = { "tile", "bstack", "grid"};
991a1062,1064
>     if (!(fp = fopen(HELLXCB_TAG_AND_MODE, "w"))) { puts("Cannot open a text file to output some data."); return; }
>     fprintf(fp, "[tag: %d] [mode: %s] [windows: %u] [web win: %u] [dev win: %u] [misc win: %u] [float win: %u]", i + 1, styles_arr[mode], numOfWindows, workspaces[0][1], workspaces[1][1], workspaces[2][1], workspaces[3][1]);
>     (void)fclose(fp);
1000,1001c1073
<     xcb_border_width(dis, c->win, (!head->next || c->isfullscrn
<                 || (mode == MONOCLE && !ISFFT(c))) ? 0:BORDER_WIDTH);
---
>     xcb_border_width(dis, c->win, (!head->next || c->isfullscrn || BORDER_WIDTH));
1100a1173,1174
>     numOfWindows = 1U;
>     workspaces[currentworkspace][1] = 1U;
1105c1179
<     for (t = head; t; t=t->next) if (!ISFFT(t)) { if (c) ++n; else c = t; }
---
>     for (t = head; t; t=t->next) if (!ISFFT(t)) { if (c) { ++n; numOfWindows++; workspaces[currentworkspace][1]++; } else c = t; }
1177c1251
<     layout[head->next ? mode : MONOCLE](wh + (showpanel ? 0:PANEL_HEIGHT),
---
>     layout[head->next ? mode : TILE](wh + (showpanel ? 0:PANEL_HEIGHT),
1227,1228c1301
<         xcb_border_width(dis, c->win, (!head->next || c->isfullscrn
<                     || (mode == MONOCLE && !ISFFT(c))) ? 0:BORDER_WIDTH);
---
>         xcb_border_width(dis, c->win, (!head->next || c->isfullscrn || BORDER_WIDTH));
1248a1322
> 
1270,1271d1343
< 
< /* vim: set ts=4 sw=4 :*/