]> git.neil.brown.name Git - edlib.git/commitdiff
display-x11/gtk: grab input focus on press or release
authorNeilBrown <neil@brown.name>
Sun, 15 Aug 2021 11:43:08 +0000 (21:43 +1000)
committerNeilBrown <neil@brown.name>
Sun, 15 Aug 2021 11:43:08 +0000 (21:43 +1000)
On a mouse action, make sure we get keyboard input.
I dropped this from gtk a while back because I couldn't see why it was
needed.  I now see why.

The window managed might choose to move the focus elsewhere - e.g. when
a window appears.  Use can get it back by leave/enter, but a simple
click should work too.

Signed-off-by: NeilBrown <neil@brown.name>
display-x11-xcb.c
python/display-pygtk.py

index ed28c46ed6c74ba3c60885f8ab6a961aa72ef60e..3fe0862669d4b43ec70bb38e18b7516e5e505102 100644 (file)
@@ -1087,6 +1087,8 @@ static void handle_button(struct pane *home safe,
        char mod[2+2+2+1];
        char key[2+2+2+9+1+1];
 
+       xcb_set_input_focus(xd->conn, XCB_INPUT_FOCUS_POINTER_ROOT,
+                           xd->win, XCB_CURRENT_TIME);
        mod[0] = 0;
        if (press) {
                xd->motion_blocked = False;
index 190179fe723b5155d59903d1b941d94a0a46c663..cbd1241cb95976ba32dcc8e2e1b1f1c96afa3f8f 100644 (file)
@@ -544,6 +544,7 @@ class EdDisplay(edlib.Pane):
             #maybe GDK_2BUTTON_PRESS - don't want that.
             return
         edlib.time_start(edlib.TIME_KEY)
+        c.grab_focus()
         self.unblock_motion()
         x = int(event.x)
         y = int(event.y)
@@ -562,6 +563,7 @@ class EdDisplay(edlib.Pane):
 
     def release(self, c, event):
         edlib.time_start(edlib.TIME_KEY)
+        c.grab_focus()
         x = int(event.x)
         y = int(event.y)
         s = ":Release-" + ("%d"%event.button)