[vte] widget: Move grab focus method to Widget
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] widget: Move grab focus method to Widget
- Date: Fri, 1 May 2020 21:11:20 +0000 (UTC)
commit 4870238eccdc3a0a5e8a9dc3bc94b0dba218b96d
Author: Christian Persch <chpe src gnome org>
Date: Fri May 1 23:08:42 2020 +0200
widget: Move grab focus method to Widget
src/vte.cc | 19 +++++++++----------
src/vteinternal.hh | 2 +-
src/widget.hh | 2 ++
3 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index ec7a6148..fd3856b8 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -5587,7 +5587,7 @@ Terminal::feed_focus_event_initial()
/* We immediately send the terminal a focus event, since otherwise
* it has no way to know the current status.
*/
- feed_focus_event(gtk_widget_has_focus(m_widget));
+ feed_focus_event(m_has_focus);
}
void
@@ -6872,9 +6872,8 @@ Terminal::widget_mouse_press(MouseEvent const& event)
_vte_debug_print(VTE_DEBUG_EVENTS,
"Handling click ourselves.\n");
/* Grab focus. */
- if (!gtk_widget_has_focus(m_widget)) {
- gtk_widget_grab_focus(m_widget);
- }
+ if (!m_has_focus)
+ widget()->grab_focus();
/* If we're in event mode, and the user held down the
* shift key, we start selecting. */
@@ -7058,13 +7057,13 @@ Terminal::widget_focus_in()
{
_vte_debug_print(VTE_DEBUG_EVENTS, "Focus in.\n");
- gtk_widget_grab_focus(m_widget);
+ m_has_focus = true;
+ widget()->grab_focus();
/* We only have an IM context when we're realized, and there's not much
* point to painting the cursor if we don't have a window. */
if (widget_realized()) {
m_cursor_blink_state = TRUE;
- m_has_focus = TRUE;
/* If blinking gets enabled now, do a full repaint.
* If blinking gets disabled, only repaint if there's blinking stuff present
@@ -10774,14 +10773,14 @@ Terminal::set_input_enabled (bool enabled)
/* FIXME: maybe hide cursor when input disabled, too? */
if (enabled) {
- if (gtk_widget_has_focus(m_widget))
- m_real_widget->im_focus_in();
+ if (m_has_focus)
+ widget()->im_focus_in();
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_READ_ONLY);
} else {
im_reset();
- if (gtk_widget_has_focus(m_widget))
- m_real_widget->im_focus_out();
+ if (m_has_focus)
+ widget()->im_focus_out();
disconnect_pty_write();
_vte_byte_array_clear(m_outgoing);
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index 4dc40e60..58a78bf1 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -732,7 +732,7 @@ public:
gint m_cursor_blink_cycle; /* gtk-cursor-blink-time / 2 */
int m_cursor_blink_timeout{500}; /* gtk-cursor-blink-timeout */
gint64 m_cursor_blink_time; /* how long the cursor has been blinking yet */
- gboolean m_has_focus; /* is the terminal window focused */
+ bool m_has_focus{false}; /* is the widget focused */
/* Contents blinking */
bool text_blink_timer_callback() noexcept;
diff --git a/src/widget.hh b/src/widget.hh
index 59e74cce..468e545b 100644
--- a/src/widget.hh
+++ b/src/widget.hh
@@ -83,6 +83,8 @@ public:
void scroll(GdkEventScroll *event) noexcept {
m_terminal->widget_mouse_scroll(*mouse_event_from_gdk(reinterpret_cast<GdkEvent*>(event))); }
bool motion_notify(GdkEventMotion *event) noexcept { return
m_terminal->widget_mouse_motion(*mouse_event_from_gdk(reinterpret_cast<GdkEvent*>(event))); }
+ void grab_focus() noexcept { gtk_widget_grab_focus(gtk()); }
+
void paste(GdkAtom board) noexcept { m_terminal->widget_paste(board); }
void copy(VteSelection sel,
VteFormat format) noexcept { m_terminal->widget_copy(sel, format); }
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]