[Xfce4-commits] [apps/ristretto] 01/01: Hide the cursor while inactive in fullscreen mode

noreply at xfce.org noreply at xfce.org
Tue Sep 10 16:24:59 CEST 2019


This is an automated email from the git hooks/post-receive script.

f   2   4   0   4       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository apps/ristretto.

commit 520b15bedc6be80d1f05b8ae04096e5d939ab69a
Author: Igor <f2404 at yandex.ru>
Date:   Tue Sep 10 10:23:15 2019 -0400

    Hide the cursor while inactive in fullscreen mode
    
    Fixes bug #15920
---
 src/image_list.c   |  6 ++----
 src/image_viewer.c |  3 +--
 src/main_window.c  | 62 ++++++++++++++++++++++++++++++++++++++++++++++--------
 src/thumbnailer.c  |  5 +++--
 src/util.h         |  3 +++
 5 files changed, 62 insertions(+), 17 deletions(-)

diff --git a/src/image_list.c b/src/image_list.c
index 6743e71..3aa6930 100644
--- a/src/image_list.c
+++ b/src/image_list.c
@@ -684,8 +684,7 @@ rstto_image_list_set_directory (
     /* Source code block */
     if (image_list->priv->directory_loader != 0)
     {
-        g_source_remove (image_list->priv->directory_loader);
-        image_list->priv->directory_loader = 0;
+        REMOVE_SOURCE (image_list->priv->directory_loader);
     }
 
     rstto_image_list_remove_all (image_list);
@@ -803,8 +802,7 @@ cb_rstto_read_file ( gpointer user_data )
         /* This is a hack, use a closure */
         if (loader->image_list->priv->directory_loader != 0)
         {
-            g_source_remove (loader->image_list->priv->directory_loader);
-            loader->image_list->priv->directory_loader = 0;
+            REMOVE_SOURCE (loader->image_list->priv->directory_loader);
         }
 
         iter = loader->image_list->priv->iterators;
diff --git a/src/image_viewer.c b/src/image_viewer.c
index 912aabe..d71dc36 100644
--- a/src/image_viewer.c
+++ b/src/image_viewer.c
@@ -3026,8 +3026,7 @@ rstto_image_viewer_set_show_clock (RsttoImageViewer *viewer, gboolean value)
     {
         if (viewer->priv->refresh_timeout_id)
         {
-            g_source_remove (viewer->priv->refresh_timeout_id);
-            viewer->priv->refresh_timeout_id = 0;
+            REMOVE_SOURCE (viewer->priv->refresh_timeout_id);
         }
     }
 }
diff --git a/src/main_window.c b/src/main_window.c
index 4cef356..75e2ffe 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -79,6 +79,7 @@ struct _RsttoMainWindowPriv
     GDBusProxy            *filemanager_proxy;
 
     guint                  show_fs_toolbar_timeout_id;
+    guint                  show_fs_mouse_cursor_timeout_id;
     gint                   window_save_geometry_timer_id;
 
     gboolean               fs_toolbar_sticky;
@@ -186,6 +187,10 @@ static gboolean
 cb_rstto_main_window_show_fs_toolbar_timeout (RsttoMainWindow *window);
 static void
 cb_rstto_main_window_show_fs_toolbar_timeout_destroy (gpointer user_data);
+static gboolean
+cb_rstto_main_window_show_fs_mouse_cursor_timeout (RsttoMainWindow *window);
+static void
+cb_rstto_main_window_show_fs_mouse_cursor_timeout_destroy (gpointer user_data);
 static void
 cb_rstto_main_window_image_list_iter_changed (RsttoImageListIter *iter, RsttoMainWindow *window);
 static void
@@ -2428,8 +2433,7 @@ cb_rstto_main_window_state_event (GtkWidget *widget, GdkEventWindowState *event,
             {
                 if (window->priv->show_fs_toolbar_timeout_id > 0)
                 {
-                    g_source_remove (window->priv->show_fs_toolbar_timeout_id);
-                    window->priv->show_fs_toolbar_timeout_id = 0;
+                    REMOVE_SOURCE (window->priv->show_fs_toolbar_timeout_id);
                 }
                 if (rstto_image_list_get_n_images (window->priv->image_list) != 0)
                 {
@@ -2440,6 +2444,11 @@ cb_rstto_main_window_state_event (GtkWidget *widget, GdkEventWindowState *event,
                 }
             }
 
+            window->priv->show_fs_mouse_cursor_timeout_id =
+                    g_timeout_add_full (G_PRIORITY_DEFAULT, 500,
+                                        (GSourceFunc) cb_rstto_main_window_show_fs_mouse_cursor_timeout, window,
+                                        cb_rstto_main_window_show_fs_mouse_cursor_timeout_destroy);
+
             if (rstto_settings_get_boolean_property (window->priv->settings_manager, "hide-thumbnails-fullscreen"))
             {
                 gtk_widget_hide (window->priv->t_bar_s_window);
@@ -2506,8 +2515,16 @@ G_GNUC_END_IGNORE_DEPRECATIONS
 
             if (window->priv->show_fs_toolbar_timeout_id > 0)
             {
-                g_source_remove (window->priv->show_fs_toolbar_timeout_id);
-                window->priv->show_fs_toolbar_timeout_id = 0;
+                REMOVE_SOURCE (window->priv->show_fs_toolbar_timeout_id);
+            }
+
+            if (window->priv->show_fs_mouse_cursor_timeout_id > 0)
+            {
+                REMOVE_SOURCE (window->priv->show_fs_mouse_cursor_timeout_id);
+            }
+            else
+            {
+                gdk_window_set_cursor (gtk_widget_get_window (widget), NULL);
             }
 
             gtk_widget_show (window->priv->menubar);
@@ -2549,11 +2566,25 @@ cb_rstto_main_window_motion_notify_event (RsttoMainWindow *window, GdkEventMotio
 
                 if (window->priv->show_fs_toolbar_timeout_id > 0)
                 {
-                    g_source_remove (window->priv->show_fs_toolbar_timeout_id);
-                    window->priv->show_fs_toolbar_timeout_id = 0;
+                    REMOVE_SOURCE (window->priv->show_fs_toolbar_timeout_id);
                 }
             }
         }
+
+        /* Show the mouse cursor, but set a timer to hide it in 1 second if not moved again */
+        if (window->priv->show_fs_mouse_cursor_timeout_id > 0)
+        {
+            REMOVE_SOURCE (window->priv->show_fs_mouse_cursor_timeout_id);
+        }
+        else
+        {
+            gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window)), NULL);
+        }
+
+        window->priv->show_fs_mouse_cursor_timeout_id =
+                g_timeout_add_full (G_PRIORITY_DEFAULT, 1000,
+                                    (GSourceFunc) cb_rstto_main_window_show_fs_mouse_cursor_timeout, window,
+                                    cb_rstto_main_window_show_fs_mouse_cursor_timeout_destroy);
     }
     return TRUE;
 }
@@ -2598,8 +2629,7 @@ cb_rstto_main_window_image_viewer_enter_notify_event (GtkWidget *widget, GdkEven
             window->priv->fs_toolbar_sticky = FALSE;
             if (window->priv->show_fs_toolbar_timeout_id > 0)
             {
-                g_source_remove (window->priv->show_fs_toolbar_timeout_id);
-                window->priv->show_fs_toolbar_timeout_id = 0;
+                REMOVE_SOURCE (window->priv->show_fs_toolbar_timeout_id);
             }
             window->priv->show_fs_toolbar_timeout_id =
                     g_timeout_add_full (G_PRIORITY_DEFAULT, 500,
@@ -2624,6 +2654,20 @@ cb_rstto_main_window_show_fs_toolbar_timeout_destroy (gpointer user_data)
     RSTTO_MAIN_WINDOW (user_data)->priv->show_fs_toolbar_timeout_id = 0;
 }
 
+static gboolean
+cb_rstto_main_window_show_fs_mouse_cursor_timeout (RsttoMainWindow *window)
+{
+    GdkCursor *cursor = gdk_cursor_new_from_name (gtk_widget_get_display (GTK_WIDGET (window)), "none");
+    gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window)), cursor);
+    return FALSE;
+}
+
+static void
+cb_rstto_main_window_show_fs_mouse_cursor_timeout_destroy (gpointer user_data)
+{
+    RSTTO_MAIN_WINDOW (user_data)->priv->show_fs_mouse_cursor_timeout_id = 0;
+}
+
 /**
  * cb_rstto_main_window_play:
  * @widget:
@@ -2852,7 +2896,7 @@ cb_rstto_main_window_configure_event (GtkWidget *widget, GdkEventConfigure *even
         /* drop any previous timer source */
         if (window->priv->window_save_geometry_timer_id > 0)
         {
-            g_source_remove (window->priv->window_save_geometry_timer_id);
+            REMOVE_SOURCE (window->priv->window_save_geometry_timer_id);
         }
 
         /* check if we should schedule another save timer */
diff --git a/src/thumbnailer.c b/src/thumbnailer.c
index 7d2d7ac..b883423 100644
--- a/src/thumbnailer.c
+++ b/src/thumbnailer.c
@@ -295,7 +295,7 @@ rstto_thumbnailer_queue_file (
 
     if (thumbnailer->priv->request_timer_id)
     {
-        g_source_remove (thumbnailer->priv->request_timer_id);
+        REMOVE_SOURCE (thumbnailer->priv->request_timer_id);
         if (thumbnailer->priv->handle)
         {
             if(tumbler_thumbnailer1_call_dequeue_sync(
@@ -338,7 +338,8 @@ rstto_thumbnailer_dequeue_file (
     
     if (thumbnailer->priv->request_timer_id)
     {
-        g_source_remove (thumbnailer->priv->request_timer_id);
+        REMOVE_SOURCE (thumbnailer->priv->request_timer_id);
+
     }
 
     if (thumbnailer->priv->handle)
diff --git a/src/util.h b/src/util.h
index 9541ecb..3079c52 100644
--- a/src/util.h
+++ b/src/util.h
@@ -79,6 +79,9 @@ typedef enum {
 #define THUMBNAIL_SIZE_LARGER_SIZE      128
 #define THUMBNAIL_SIZE_VERY_LARGE_SIZE  256
 
+/* Macro to remove and clear a source id */
+#define REMOVE_SOURCE(ID) ({g_source_remove (ID); ID = 0;})
+
 G_END_DECLS
 
 #endif /* __RSTTO_UTIL_H__ */

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list