diff options
| author | Jeff Walsh | 2021-09-27 00:20:57 +1000 |
|---|---|---|
| committer | Yuuki Harano | 2021-11-15 21:07:28 +0900 |
| commit | 6c1f0dd709a77a2fade006b5957553fc5abd7631 (patch) | |
| tree | c68c4a290512343e3732edcb375937f0f9c3380c | |
| parent | f1a60225152af1f87d8580db0785cf5a0a9c7544 (diff) | |
| download | emacs-6c1f0dd709a77a2fade006b5957553fc5abd7631.tar.gz emacs-6c1f0dd709a77a2fade006b5957553fc5abd7631.zip | |
pgtk: Handle (child) frame focusing better
child frames on pgtk are gtk widgets inside the parent surface, rather
than subsurfaces (in wayland ters), and the edit widget is handled
separately from the parent window, so we need to handle signals more
correctly, rather than squinting and assuming an event for the window
is just an event for the edit widget.
* src/gtkutil.c (xg_set_no_accept_focus): set
focus on widget rather than request it on window
* src/pgtkterm.c (pgtk_focus_frame): focus frame on edit_widget
instead
(button_event): Implement focus calls to replace dead X calls
| -rw-r--r-- | src/gtkutil.c | 9 | ||||
| -rw-r--r-- | src/pgtkterm.c | 15 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/gtkutil.c b/src/gtkutil.c index 6822aeb4e32..3e4d6e076ff 100644 --- a/src/gtkutil.c +++ b/src/gtkutil.c | |||
| @@ -1996,16 +1996,19 @@ xg_set_no_focus_on_map (struct frame *f, Lisp_Object no_focus_on_map) | |||
| 1996 | void | 1996 | void |
| 1997 | xg_set_no_accept_focus (struct frame *f, Lisp_Object no_accept_focus) | 1997 | xg_set_no_accept_focus (struct frame *f, Lisp_Object no_accept_focus) |
| 1998 | { | 1998 | { |
| 1999 | gboolean g_no_accept_focus = NILP (no_accept_focus) ? TRUE : FALSE; | ||
| 1999 | #ifdef HAVE_PGTK | 2000 | #ifdef HAVE_PGTK |
| 2000 | if (!FRAME_GTK_OUTER_WIDGET (f)) | 2001 | if (!FRAME_GTK_OUTER_WIDGET (f)) |
| 2001 | return; | 2002 | { |
| 2003 | if (FRAME_WIDGET(f)) | ||
| 2004 | gtk_widget_set_can_focus (FRAME_WIDGET(f), g_no_accept_focus); | ||
| 2005 | return; | ||
| 2006 | } | ||
| 2002 | #endif | 2007 | #endif |
| 2003 | block_input (); | 2008 | block_input (); |
| 2004 | if (FRAME_GTK_WIDGET (f)) | 2009 | if (FRAME_GTK_WIDGET (f)) |
| 2005 | { | 2010 | { |
| 2006 | GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)); | 2011 | GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)); |
| 2007 | gboolean g_no_accept_focus = NILP (no_accept_focus) ? TRUE : FALSE; | ||
| 2008 | |||
| 2009 | gtk_window_set_accept_focus (gwin, g_no_accept_focus); | 2012 | gtk_window_set_accept_focus (gwin, g_no_accept_focus); |
| 2010 | } | 2013 | } |
| 2011 | unblock_input (); | 2014 | unblock_input (); |
diff --git a/src/pgtkterm.c b/src/pgtkterm.c index 75386ee6c39..978d4798d5f 100644 --- a/src/pgtkterm.c +++ b/src/pgtkterm.c | |||
| @@ -4702,12 +4702,12 @@ pgtk_focus_frame (struct frame *f, bool noactivate) | |||
| 4702 | { | 4702 | { |
| 4703 | struct pgtk_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); | 4703 | struct pgtk_display_info *dpyinfo = FRAME_DISPLAY_INFO (f); |
| 4704 | 4704 | ||
| 4705 | GtkWidget *wid = FRAME_GTK_OUTER_WIDGET (f); | 4705 | GtkWidget *wid = FRAME_WIDGET (f); |
| 4706 | 4706 | ||
| 4707 | if (dpyinfo->x_focus_frame != f && wid != NULL) | 4707 | if (dpyinfo->x_focus_frame != f && wid != NULL) |
| 4708 | { | 4708 | { |
| 4709 | block_input (); | 4709 | block_input (); |
| 4710 | gtk_window_present (GTK_WINDOW (wid)); | 4710 | gtk_widget_grab_focus(wid); |
| 4711 | unblock_input (); | 4711 | unblock_input (); |
| 4712 | } | 4712 | } |
| 4713 | } | 4713 | } |
| @@ -6460,12 +6460,11 @@ button_event (GtkWidget * widget, GdkEvent * event, gpointer * user_data) | |||
| 6460 | if (FRAME_PARENT_FRAME (f) || (hf && frame_ancestor_p (f, hf))) | 6460 | if (FRAME_PARENT_FRAME (f) || (hf && frame_ancestor_p (f, hf))) |
| 6461 | { | 6461 | { |
| 6462 | block_input (); | 6462 | block_input (); |
| 6463 | #if 0 | 6463 | gtk_widget_grab_focus(FRAME_GTK_WIDGET(f)); |
| 6464 | XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f), | 6464 | if (FRAME_GTK_OUTER_WIDGET (f)) |
| 6465 | RevertToParent, CurrentTime); | 6465 | { |
| 6466 | if (FRAME_PARENT_FRAME (f)) | 6466 | gtk_window_present (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f))); |
| 6467 | XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f)); | 6467 | } |
| 6468 | #endif | ||
| 6469 | unblock_input (); | 6468 | unblock_input (); |
| 6470 | } | 6469 | } |
| 6471 | } | 6470 | } |