[vte] widget: Use GdkEvent accessor function
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] widget: Use GdkEvent accessor function
- Date: Mon, 19 Oct 2020 19:15:19 +0000 (UTC)
commit 028e7a7780f0ea6b95a3467b89d0bec0910bb9e0
Author: Christian Persch <chpe src gnome org>
Date: Mon Oct 19 21:14:43 2020 +0200
widget: Use GdkEvent accessor function
[gtk4 preparation]
src/widget.hh | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/src/widget.hh b/src/widget.hh
index 5fe53ac4..10345d8a 100644
--- a/src/widget.hh
+++ b/src/widget.hh
@@ -215,12 +215,15 @@ public:
ScrollDirection scroll_direction() const noexcept
{
- /* Note that we cannot use gdk_event_get_scroll_direction() here since it
- * returns false for smooth scroll events.
- */
if (!is_mouse_scroll())
return ScrollDirection::eNONE;
- switch (reinterpret_cast<GdkEventScroll*>(platform_event())->direction) {
+ auto dir = GdkScrollDirection{};
+ if (gdk_event_get_scroll_deltas(platform_event(), nullptr, nullptr))
+ dir = GDK_SCROLL_SMOOTH;
+ else if (!gdk_event_get_scroll_direction(platform_event(), &dir))
+ return ScrollDirection::eNONE;
+
+ switch (dir) {
case GDK_SCROLL_UP: return ScrollDirection::eUP;
case GDK_SCROLL_DOWN: return ScrollDirection::eDOWN;
case GDK_SCROLL_LEFT: return ScrollDirection::eLEFT;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]