[gnome-boxes] display: Account for offset of event_box child when relaying events
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] display: Account for offset of event_box child when relaying events
- Date: Mon, 13 Jul 2020 15:55:47 +0000 (UTC)
commit 38d071b3dc6d81f747540ac1d474894537e0d5be
Author: Jason Gerecke <killertofu gmail com>
Date: Fri Jun 26 13:05:43 2020 -0700
display: Account for offset of event_box child when relaying events
The VNC backend experiences an issue with pointer events being offset
from their intended position whenever there is excess space around
the widget. This is due to the (event_box-relative) events not being
adjusted before being fed into the child widget.
https://gitlab.gnome.org/GNOME/gnome-boxes/-/issues/157
https://gitlab.gnome.org/GNOME/gnome-boxes/-/issues/239
src/display-page.vala | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/display-page.vala b/src/display-page.vala
index b786a648..e6b709dd 100644
--- a/src/display-page.vala
+++ b/src/display-page.vala
@@ -292,8 +292,24 @@ private bool on_event_box_event (Gdk.Event event) {
if (event.type == EventType.GRAB_BROKEN)
return false;
- if (event_box.get_child () != null)
- event_box.get_child ().event (event);
+ if (event_box.get_child () != null) {
+ var child = event_box.get_child ();
+ var offset_x = (get_allocated_width () - child.get_allocated_width ()) / 2.0;
+ var offset_y = (get_allocated_height () - child.get_allocated_height ()) / 2.0;
+
+ switch (event.get_event_type ()) {
+ case Gdk.EventType.MOTION_NOTIFY:
+ event.motion.x -= offset_x;
+ event.motion.y -= offset_y;
+ break;
+
+ default:
+ // Offset not needed or not possible
+ break;
+ }
+
+ child.event (event);
+ }
return false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]