Thursday, October 18, 2018

KCMOUSE - Minimal Window Manager for X11



      I recently updated my minimal window manager for X11 that I made a couple years ago. I had stopped using it because for some reason the cpu usage was going to 100% occasionally when using one particular program. I decided to look at the code again and discovered the issue. It was because a window was not properly raised to the top of the stack after calling the XCirculateSubwindowsDown and XCirculateSubwindowsUp commands. It wasn't noticable during normal use, due to the XsetInputFocus command proving focus to the new window.


     The fix was to query the mouse pointer after the window cycle to find the new focused window and add it to the focuswin variable. Then I added the XraiseWindow command to raise the newly focused window. Now all my programs are happy, and when they are happy I'm happy :} Here is a snipplet of the code I'm talking about:


XCirculateSubwindowsDown(display, root);
XQueryPointer(display, root, &unusedwin, &focuswin, &unusedint, &unusedint, &unusedint, &unusedint, &unusedint);
XSetInputFocus(display, focuswin, RevertToNone, CurrentTime);
XRaiseWindow(display, focuswin);



     I've updated the source code on Github here: https://github.com/netfun81/kcmouse


You are welcome to it Microsoft :}



No comments: