[vte] terminal: Use an enum class for mouse tracking mode
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] terminal: Use an enum class for mouse tracking mode
- Date: Mon, 18 Nov 2019 21:44:00 +0000 (UTC)
commit 0a96b927dc1a282175c6b395594c31b642555270
Author: Christian Persch <chpe src gnome org>
Date: Mon Nov 18 22:42:22 2019 +0100
terminal: Use an enum class for mouse tracking mode
src/vte.cc | 18 +++++++++---------
src/vteinternal.hh | 22 +++++++++++-----------
src/vteseq.cc | 14 +++++++-------
3 files changed, 27 insertions(+), 27 deletions(-)
---
diff --git a/src/vte.cc b/src/vte.cc
index 016245c7..4e289207 100644
--- a/src/vte.cc
+++ b/src/vte.cc
@@ -2150,7 +2150,7 @@ Terminal::apply_mouse_cursor()
m_real_widget->set_cursor(vte::platform::Widget::CursorType::eHyperlink);
} else if (regex_match_has_current()) {
m_real_widget->set_cursor(regex_match_current()->cursor());
- } else if (m_mouse_tracking_mode) {
+ } else if (m_mouse_tracking_mode != MouseTrackingMode::eNONE) {
_vte_debug_print(VTE_DEBUG_CURSOR,
"Setting mousing cursor.\n");
m_real_widget->set_cursor(vte::platform::Widget::CursorType::eMousing);
@@ -5631,7 +5631,7 @@ Terminal::feed_mouse_event(vte::grid::coords const& rowcol /* confined */,
}
/* Encode the modifiers. */
- if (m_mouse_tracking_mode >= MOUSE_TRACKING_SEND_XY_ON_BUTTON) {
+ if (m_mouse_tracking_mode >= MouseTrackingMode::eSEND_XY_ON_BUTTON) {
if (m_modifiers & GDK_SHIFT_MASK) {
cb |= 4;
}
@@ -5704,12 +5704,12 @@ Terminal::maybe_send_mouse_button(vte::grid::coords const& unconfined_rowcol,
{
switch (event_type) {
case GDK_BUTTON_PRESS:
- if (m_mouse_tracking_mode < MOUSE_TRACKING_SEND_XY_ON_CLICK) {
+ if (m_mouse_tracking_mode < MouseTrackingMode::eSEND_XY_ON_CLICK) {
return false;
}
break;
case GDK_BUTTON_RELEASE: {
- if (m_mouse_tracking_mode < MOUSE_TRACKING_SEND_XY_ON_BUTTON) {
+ if (m_mouse_tracking_mode < MouseTrackingMode::eSEND_XY_ON_BUTTON) {
return false;
}
break;
@@ -5748,10 +5748,10 @@ Terminal::maybe_send_mouse_drag(vte::grid::coords const& unconfined_rowcol,
/* First determine if we even want to send notification. */
switch (event_type) {
case GDK_MOTION_NOTIFY:
- if (m_mouse_tracking_mode < MOUSE_TRACKING_CELL_MOTION_TRACKING)
+ if (m_mouse_tracking_mode < MouseTrackingMode::eCELL_MOTION_TRACKING)
return false;
- if (m_mouse_tracking_mode < MOUSE_TRACKING_ALL_MOTION_TRACKING) {
+ if (m_mouse_tracking_mode < MouseTrackingMode::eALL_MOTION_TRACKING) {
if (m_mouse_pressed_buttons == 0) {
return false;
@@ -7006,7 +7006,7 @@ Terminal::widget_button_press(GdkEventButton *event)
/* If we're in event mode, and the user held down the
* shift key, we start selecting. */
- if (m_mouse_tracking_mode) {
+ if (m_mouse_tracking_mode != MouseTrackingMode::eNONE) {
if (m_modifiers & GDK_SHIFT_MASK) {
start_selecting = TRUE;
}
@@ -7040,7 +7040,7 @@ Terminal::widget_button_press(GdkEventButton *event)
* to the app. */
case 2:
if ((m_modifiers & GDK_SHIFT_MASK) ||
- !m_mouse_tracking_mode) {
+ m_mouse_tracking_mode == MouseTrackingMode::eNONE) {
gboolean do_paste;
g_object_get (gtk_widget_get_settings(m_widget),
@@ -9540,7 +9540,7 @@ Terminal::widget_scroll(GdkEventScroll *event)
/* If we're running a mouse-aware application, map the scroll event
* to a button press on buttons four and five. */
- if (m_mouse_tracking_mode) {
+ if (m_mouse_tracking_mode != MouseTrackingMode::eNONE) {
cnt = m_mouse_smooth_scroll_delta;
if (cnt == 0)
return;
diff --git a/src/vteinternal.hh b/src/vteinternal.hh
index fc577669..74252c23 100644
--- a/src/vteinternal.hh
+++ b/src/vteinternal.hh
@@ -68,16 +68,6 @@
#include "icu-converter.hh"
#endif
-/* The order is important */
-typedef enum {
- MOUSE_TRACKING_NONE,
- MOUSE_TRACKING_SEND_XY_ON_CLICK,
- MOUSE_TRACKING_SEND_XY_ON_BUTTON,
- MOUSE_TRACKING_HILITE_TRACKING,
- MOUSE_TRACKING_CELL_MOTION_TRACKING,
- MOUSE_TRACKING_ALL_MOTION_TRACKING
-} MouseTrackingMode;
-
enum {
VTE_XTERM_WM_RESTORE_WINDOW = 1,
VTE_XTERM_WM_MINIMIZE_WINDOW = 2,
@@ -326,6 +316,16 @@ private:
eSTEADY_IBEAM = 6,
};
+ /* The order is important */
+ enum class MouseTrackingMode {
+ eNONE,
+ eSEND_XY_ON_CLICK,
+ eSEND_XY_ON_BUTTON,
+ eHILITE_TRACKING,
+ eCELL_MOTION_TRACKING,
+ eALL_MOTION_TRACKING,
+ };
+
protected:
/* NOTE: This needs to be kept in sync with the public VteCursorBlinkMode enum */
@@ -546,7 +546,7 @@ public:
bool m_input_enabled{true};
time_t m_last_keypress_time;
- MouseTrackingMode m_mouse_tracking_mode{MOUSE_TRACKING_NONE};
+ MouseTrackingMode m_mouse_tracking_mode{MouseTrackingMode::eNONE};
guint m_mouse_pressed_buttons; /* bits 0, 1, 2 resp. for buttons 1, 2, 3 */
guint m_mouse_handled_buttons; /* similar bitmap for buttons we handled ourselves */
/* The last known position the mouse pointer from an event. We don't store
diff --git a/src/vteseq.cc b/src/vteseq.cc
index 314c03d8..3b490728 100644
--- a/src/vteseq.cc
+++ b/src/vteseq.cc
@@ -493,17 +493,17 @@ void
Terminal::update_mouse_protocol() noexcept
{
if (m_modes_private.XTERM_MOUSE_ANY_EVENT())
- m_mouse_tracking_mode = MOUSE_TRACKING_ALL_MOTION_TRACKING;
+ m_mouse_tracking_mode = MouseTrackingMode::eALL_MOTION_TRACKING;
else if (m_modes_private.XTERM_MOUSE_BUTTON_EVENT())
- m_mouse_tracking_mode = MOUSE_TRACKING_CELL_MOTION_TRACKING;
+ m_mouse_tracking_mode = MouseTrackingMode::eCELL_MOTION_TRACKING;
else if (m_modes_private.XTERM_MOUSE_VT220_HIGHLIGHT())
- m_mouse_tracking_mode = MOUSE_TRACKING_HILITE_TRACKING;
+ m_mouse_tracking_mode = MouseTrackingMode::eHILITE_TRACKING;
else if (m_modes_private.XTERM_MOUSE_VT220())
- m_mouse_tracking_mode = MOUSE_TRACKING_SEND_XY_ON_BUTTON;
+ m_mouse_tracking_mode = MouseTrackingMode::eSEND_XY_ON_BUTTON;
else if (m_modes_private.XTERM_MOUSE_X10())
- m_mouse_tracking_mode = MOUSE_TRACKING_SEND_XY_ON_CLICK;
+ m_mouse_tracking_mode = MouseTrackingMode::eSEND_XY_ON_CLICK;
else
- m_mouse_tracking_mode = MOUSE_TRACKING_NONE;
+ m_mouse_tracking_mode = MouseTrackingMode::eNONE;
m_mouse_smooth_scroll_delta = 0.0;
@@ -511,7 +511,7 @@ Terminal::update_mouse_protocol() noexcept
apply_mouse_cursor();
_vte_debug_print(VTE_DEBUG_MODES,
- "Mouse protocol is now %d\n", m_mouse_tracking_mode);
+ "Mouse protocol is now %d\n", (int)m_mouse_tracking_mode);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]