1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-02-18 14:11:38 -08:00

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
This commit is contained in:
Jeff Walsh 2021-09-27 00:20:57 +10:00 committed by Yuuki Harano
parent f1a6022515
commit 6c1f0dd709
2 changed files with 13 additions and 11 deletions

View file

@ -1996,16 +1996,19 @@ xg_set_no_focus_on_map (struct frame *f, Lisp_Object no_focus_on_map)
void
xg_set_no_accept_focus (struct frame *f, Lisp_Object no_accept_focus)
{
gboolean g_no_accept_focus = NILP (no_accept_focus) ? TRUE : FALSE;
#ifdef HAVE_PGTK
if (!FRAME_GTK_OUTER_WIDGET (f))
return;
{
if (FRAME_WIDGET(f))
gtk_widget_set_can_focus (FRAME_WIDGET(f), g_no_accept_focus);
return;
}
#endif
block_input ();
if (FRAME_GTK_WIDGET (f))
{
GtkWindow *gwin = GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f));
gboolean g_no_accept_focus = NILP (no_accept_focus) ? TRUE : FALSE;
gtk_window_set_accept_focus (gwin, g_no_accept_focus);
}
unblock_input ();

View file

@ -4702,12 +4702,12 @@ pgtk_focus_frame (struct frame *f, bool noactivate)
{
struct pgtk_display_info *dpyinfo = FRAME_DISPLAY_INFO (f);
GtkWidget *wid = FRAME_GTK_OUTER_WIDGET (f);
GtkWidget *wid = FRAME_WIDGET (f);
if (dpyinfo->x_focus_frame != f && wid != NULL)
{
block_input ();
gtk_window_present (GTK_WINDOW (wid));
gtk_widget_grab_focus(wid);
unblock_input ();
}
}
@ -6460,12 +6460,11 @@ button_event (GtkWidget * widget, GdkEvent * event, gpointer * user_data)
if (FRAME_PARENT_FRAME (f) || (hf && frame_ancestor_p (f, hf)))
{
block_input ();
#if 0
XSetInputFocus (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f),
RevertToParent, CurrentTime);
if (FRAME_PARENT_FRAME (f))
XRaiseWindow (FRAME_X_DISPLAY (f), FRAME_OUTER_WINDOW (f));
#endif
gtk_widget_grab_focus(FRAME_GTK_WIDGET(f));
if (FRAME_GTK_OUTER_WIDGET (f))
{
gtk_window_present (GTK_WINDOW (FRAME_GTK_OUTER_WIDGET (f)));
}
unblock_input ();
}
}