In some QT applications, such as Scribus, dialogs like "Open File" or
"Create New Document" prevent the pointer from moving outside the
window.  Upon reaching any edge, the pointer jumps again to the center
of the window.  I recognized that this behavior is due to the
client_ptr_warp() function, so I searched the code for any instances of
this function, commented on that line here and there until I found the
culprit.  Removing this occurrence of client_ptr_warp() solves the
problem (xevents.c, l. 404):

 } else if (e->message_type == ewmh[_NET_ACTIVE_WINDOW]) {
                if ((cc = client_find(e->window)) != NULL) {
                        if ((old_cc = client_current(NULL)) != NULL)
                                client_ptr_save(old_cc);
                        client_show(cc);
                        //client_ptr_warp(cc);
                        ^
                        Removing this line fixes the issue


This chunk is part of xev_handle_clientmessage() in xevents.c.
According to the 3.8 title of this documentation:

  https://specifications.freedesktop.org/wm-spec/1.3/ar01s03.html

Where says:

    "If a Client wants to activate another window, it MUST send a
     _NET_ACTIVE_WINDOW client message to the root window:"

it seems that client_ptr_warp() is there to let the dialog get focus
when it's oppened.  But seems to be redundant since the following
already takes care of that (xevents.c, l. 92):

static void
xev_handle_maprequest(XEvent *ee)
{
        XMapRequestEvent        *e = &ee->xmaprequest;
        struct screen_ctx       *sc;
        struct client_ctx       *cc, *old_cc;

        LOG_DEBUG3("parent: 0x%lx window: 0x%lx", e->parent, e->window);

        if ((sc = screen_find(e->parent)) == NULL)
                return;

        if ((old_cc = client_current(sc)) != NULL)
                client_ptr_save(old_cc);

        if ((cc = client_find(e->window)) == NULL)
                cc = client_init(e->window, NULL);

        if ((cc != NULL) && (!(cc->flags & CLIENT_IGNORE)))
              client_ptr_warp(cc);
              ^
              This seems to already take care of focusing
              transient dialogs.


So far I've been using cwm(1) (as I usually do on daily basis) with the
patch below applied and I didn't notice any regression.  I've tried
oppening dialogs on other applications (gimp, inkscape, firefox,
blender, imagemagick) and dialogs get the focus as expected.

If Okan ever comes back to life, he'll tell us whether it's safe to
delete that line or not. :-)


Index: xevents.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/xevents.c,v
diff -u -p -r1.150 xevents.c
--- xevents.c   24 Mar 2020 14:47:29 -0000      1.150
+++ xevents.c   27 Aug 2025 16:24:50 -0000
@@ -401,7 +401,6 @@ xev_handle_clientmessage(XEvent *ee)
                        if ((old_cc = client_current(NULL)) != NULL)
                                client_ptr_save(old_cc);
                        client_show(cc);
-                       client_ptr_warp(cc);
                }
        } else if (e->message_type == ewmh[_NET_WM_DESKTOP]) {
                if ((cc = client_find(e->window)) != NULL) {



-- 
Walter

Reply via email to