Browse files

rework focusing configured client - still some kind of race condition

  • Loading branch information...
1 parent 9dc2f10 commit 99f38821894f945326c5ef60af491cdddc3561af @c00kiemon5ter committed Jan 24, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 monsterwm.c
@@ -343,10 +343,10 @@ void configurerequest(XEvent *e) {
XSync(dis, False);
- update_current(c?c:current);
+ if (c && c == current) update_current(c);
c00kiemon5ter Jan 24, 2012 owner

refocus the configured client if it's the current one
this doesn't work all the time. seems there's some kind of race condition hidding somewhere <.<

Cloudef Jan 24, 2012

(╯°□°)╯︵ ┻━┻
And I just merged the earlier revision!

c00kiemon5ter Jan 24, 2012 owner

update_current(c?c:current); would always focus the configured client, which isn't something one would like. For example if you open gvim, it gets configured, but will also get configured everytime a window appears/closes and gvim has to be resized, so it will steal focus all the time, so we need to (re)focus that client only if it's the current one.

What I think happens is that: a client that gets configured - mplayer being one that it's easy to test - it requests a specific size, in the case of mplayer it requests a size as big as the video that's going to be played. So, we get that request, and fill the window changes, and send that event/message, so the window is now happy and won't throw errors.
At this point the window has a desired/prefered size, as it requested, but we immediately call tile() which resizes the client again to our prefered size, so no gaps are apparent, and after that we call update_current() which places the borders around the window.
Now, update_current() seems to run faster than tile() (how is that possible) and give borders to the smaller window.

💣 But I just realized that the video I'm playing is supposed to be bigger than the space mplayer will get, so it's surely not giving borders to a "smaller" window, cause there is no smaller window.

I have no idea. I'll grab some cookies and think about it later. >.>

-/* send the given event - WM_DELETE_WINDOW for now */
+/* close the window */
void deletewindow(Window w) {
XEvent ev;
ev.type = ClientMessage;

0 comments on commit 99f3882

Please sign in to comment.