aboutsummaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorselurvedu <selurvedu@users.noreply.github.com>2020-04-22 02:06:40 +0000
committerfiaxh <fiaxh@users.noreply.github.com>2020-04-22 20:13:24 +0200
commit1f4899df166e35e1f10d811323c4a4933e824723 (patch)
tree0e51e23fb33b3456b981b53e0e5ecfdbe49719b5 /main
parentb73ec9e0ca69277241bb8a39fdf7214a4823ebe4 (diff)
downloaddino-1f4899df166e35e1f10d811323c4a4933e824723.tar.gz
dino-1f4899df166e35e1f10d811323c4a4933e824723.zip
Improve message highlighting logic
Diffstat (limited to 'main')
-rw-r--r--main/src/ui/conversation_content_view/conversation_view.vala25
1 files changed, 13 insertions, 12 deletions
diff --git a/main/src/ui/conversation_content_view/conversation_view.vala b/main/src/ui/conversation_content_view/conversation_view.vala
index 43c138cf..07fa8945 100644
--- a/main/src/ui/conversation_content_view/conversation_view.vala
+++ b/main/src/ui/conversation_content_view/conversation_view.vala
@@ -43,7 +43,6 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
private bool reload_messages = true;
ConversationItemSkeleton currently_highlighted = null;
ContentMetaItem? current_meta_item = null;
- bool mouse_inside = false;
int last_y_root = -1;
public ConversationView init(StreamInteractor stream_interactor) {
@@ -61,10 +60,19 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
app.plugin_registry.register_conversation_addition_populator(new ChatStatePopulator(stream_interactor));
app.plugin_registry.register_conversation_addition_populator(new DateSeparatorPopulator(stream_interactor));
+ // Rather than connecting to the leave event of the main_event_box directly,
+ // we connect to the parent event box that also wraps the overlaying message_menu_box.
+ // This eliminates the unwanted leave events emitted on the main_event_box when hovering
+ // the overlaying menu buttons.
main_wrap_event_box.events = EventMask.ENTER_NOTIFY_MASK;
main_wrap_event_box.events = EventMask.LEAVE_NOTIFY_MASK;
main_wrap_event_box.leave_notify_event.connect(on_leave_notify_event);
main_wrap_event_box.enter_notify_event.connect(on_enter_notify_event);
+ // The buttons of the overlaying message_menu_box may partially overlap the adjacent
+ // conversation items. We connect to the main_event_box directly to avoid emitting
+ // the pointer motion events as long as the pointer is above the message menu.
+ // This ensures that the currently highlighted item remains unchanged when the pointer
+ // reaches the overlapping part of a button.
main_event_box.events = EventMask.POINTER_MOTION_MASK;
main_event_box.motion_notify_event.connect(on_motion_notify_event);
@@ -95,13 +103,11 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
}
private bool on_enter_notify_event(Gdk.EventCrossing event) {
- mouse_inside = true;
update_highlight((int)event.x_root, (int)event.y_root);
return false;
}
private bool on_leave_notify_event(Gdk.EventCrossing event) {
- mouse_inside = false;
if (currently_highlighted != null) {
currently_highlighted.unset_state_flags(StateFlags.PRELIGHT);
currently_highlighted = null;
@@ -111,7 +117,6 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
}
private bool on_motion_notify_event(Gdk.EventMotion event) {
- mouse_inside = true;
update_highlight((int)event.x_root, (int)event.y_root);
return false;
}
@@ -131,18 +136,14 @@ public class ConversationView : Box, Plugins.ConversationItemCollection, Plugins
// Get widget under pointer
int h = 0;
- bool @break = false;
ConversationItemSkeleton? w = null;
- main.@foreach((widget) => {
- if (break) return;
-
+ foreach (Widget widget in main.get_children()) {
h += widget.get_allocated_height();
- w = widget as ConversationItemSkeleton;
if (h >= dest_y) {
- @break = true;
- return;
+ w = widget as ConversationItemSkeleton;
+ break;
}
- });
+ };
if (currently_highlighted != null) currently_highlighted.unset_state_flags(StateFlags.PRELIGHT);