[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/pgtk 6c1f0dd 1/2: pgtk: Handle (child) frame focusing better
From: |
Yuuki Harano |
Subject: |
feature/pgtk 6c1f0dd 1/2: pgtk: Handle (child) frame focusing better |
Date: |
Mon, 15 Nov 2021 07:39:57 -0500 (EST) |
branch: feature/pgtk
commit 6c1f0dd709a77a2fade006b5957553fc5abd7631
Author: Jeff Walsh <fejfighter@gmail.com>
Commit: Yuuki Harano <masm+github@masm11.me>
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
---
src/gtkutil.c | 9 ++++++---
src/pgtkterm.c | 15 +++++++--------
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 6822aeb..3e4d6e0 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)
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 ();
diff --git a/src/pgtkterm.c b/src/pgtkterm.c
index 75386ee..978d479 100644
--- a/src/pgtkterm.c
+++ b/src/pgtkterm.c
@@ -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 ();
}
}