From 7dba21c6d885605dd83fb1bea828b0c5e723b0d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Eric=20Janouch?=
Date: Sat, 13 Nov 2021 09:20:37 +0100 Subject: [PATCH] Use the hand/pointer cursor in the browser Also, fix the build. --- fastiv-browser.c | 23 ++++++++++++++++++++++- meson.build | 4 ++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/fastiv-browser.c b/fastiv-browser.c index 2db04ea..0d183c4 100644 --- a/fastiv-browser.c +++ b/fastiv-browser.c @@ -335,7 +335,7 @@ fastiv_browser_realize(GtkWidget *widget) .visual = gtk_widget_get_visual(widget), .event_mask = gtk_widget_get_events(widget) | GDK_KEY_PRESS_MASK | - GDK_BUTTON_PRESS_MASK, + GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK, }; // We need this window to receive input events at all. @@ -401,6 +401,26 @@ fastiv_browser_button_press_event(GtkWidget *widget, GdkEventButton *event) return TRUE; } +gboolean +fastiv_browser_motion_notify_event(GtkWidget *widget, GdkEventMotion *event) +{ + FastivBrowser *self = FASTIV_BROWSER(widget); + if (event->state != 0) + return FALSE; + + const Entry *entry = entry_at(self, event->x, event->y); + GdkWindow *window = gtk_widget_get_window(widget); + if (entry) { + GdkCursor *cursor = + gdk_cursor_new_from_name(gdk_window_get_display(window), "pointer"); + gdk_window_set_cursor(window, cursor); + g_object_unref(cursor); + } else { + gdk_window_set_cursor(window, NULL); + } + return TRUE; +} + static void fastiv_browser_style_updated(GtkWidget *widget) { @@ -476,6 +496,7 @@ fastiv_browser_class_init(FastivBrowserClass *klass) widget_class->draw = fastiv_browser_draw; widget_class->size_allocate = fastiv_browser_size_allocate; widget_class->button_press_event = fastiv_browser_button_press_event; + widget_class->motion_notify_event = fastiv_browser_motion_notify_event; widget_class->style_updated = fastiv_browser_style_updated; browser_signals[ITEM_ACTIVATED] = diff --git a/meson.build b/meson.build index 0434cff..1125cd9 100644 --- a/meson.build +++ b/meson.build @@ -32,10 +32,10 @@ executable('fastiv', 'fastiv.c', 'fastiv-view.c', 'fastiv-io.c', install : true, dependencies : [dependencies]) -if gdk_pixbuf.found() +if gdkpixbuf.found() executable('io-benchmark', 'fastiv-io-benchmark.c', 'fastiv-io.c', 'xdg.c', build_by_default : false, - dependencies : [dependencies, gdk_pixbuf]) + dependencies : [dependencies, gdkpixbuf]) endif install_data('fastiv.desktop',