Support dragging the view

It would also be possible to handle this through press/motion/release
event handlers, though GtkGestureDrag is more convenient for hacking in
support for dragging to widgets not supporting GtkScrollable (yet).

There may be some undesired interactions lurking, besides the jarring
movements when dragging native GdkWindows (these are a pain).
This commit is contained in:
2021-11-22 16:36:38 +01:00
parent 1fee920902
commit c55500f51a
2 changed files with 91 additions and 2 deletions

View File

@@ -384,8 +384,12 @@ fiv_view_realize(GtkWidget *widget)
// Assuming here that we can't ask for a higher-precision Visual
// than what we get automatically.
.visual = gtk_widget_get_visual(widget),
.event_mask = gtk_widget_get_events(widget) | GDK_SCROLL_MASK |
GDK_KEY_PRESS_MASK | GDK_BUTTON_PRESS_MASK,
// Pointer motion/release enables attaching GtkGestureDrag to
// the parent GtkScrolledWindow, having it work with the mouse.
.event_mask = gtk_widget_get_events(widget) | GDK_KEY_PRESS_MASK |
GDK_SCROLL_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK,
};
// We need this window to receive input events at all.