[Xfce4-commits] [xfce/xfce4-settings] 04/09: Small code cleanup

noreply at xfce.org noreply at xfce.org
Sun Mar 11 13:37:26 CET 2018


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

b   l   u   e   s   a   b   r   e       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 xfce/xfce4-settings.

commit 5233c6f957ecbb0fee2890a558d1c04ff3d95fa1
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Tue Feb 20 15:40:48 2018 +0100

    Small code cleanup
---
 dialogs/accessibility-settings/find-cursor.c | 40 +++++++++++++++-------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/dialogs/accessibility-settings/find-cursor.c b/dialogs/accessibility-settings/find-cursor.c
index 0aefb68..3bf96fe 100644
--- a/dialogs/accessibility-settings/find-cursor.c
+++ b/dialogs/accessibility-settings/find-cursor.c
@@ -41,10 +41,10 @@ gboolean timeout (gpointer data)
 
 
 static void
-screen_changed (GtkWidget *widget, GdkScreen *old_screen, gpointer userdata) {
+find_cursor_window_screen_changed (GtkWidget *widget, GdkScreen *old_screen, gpointer userdata) {
     gboolean supports_alpha;
-    GdkScreen *screen = gtk_widget_get_screen(widget);
-    GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
+    GdkScreen *screen = gtk_widget_get_screen (widget);
+    GdkVisual *visual = gdk_screen_get_rgba_visual (screen);
 
     /* this is a purely informatonal check at the moment. could later be user_data
      * to call some fallback in non-composited envs */
@@ -61,14 +61,13 @@ screen_changed (GtkWidget *widget, GdkScreen *old_screen, gpointer userdata) {
 }
 
 double px = 10;
-double vx = 3;
 
 static gboolean
-find_cursor_window_draw  (GtkWidget      *window,
-                          cairo_t *cr,
-                          gpointer     user_data) {
+find_cursor_window_draw (GtkWidget      *window,
+                         cairo_t        *cr,
+                         gpointer        user_data) {
     int width, height;
-    int i = 1;
+    int i = 0;
     int arcs = 1;
 
     gtk_window_get_size (GTK_WINDOW (window), &width, &height);
@@ -79,25 +78,27 @@ find_cursor_window_draw  (GtkWidget      *window,
 
     cairo_set_line_width (cr, 3.0);
     cairo_translate (cr, width / 2, height / 2);
-    if (px > 30.0)
-        arcs = 2;
-    if (px > 60.0)
-        arcs = 3;
     if (px > 90.0)
         arcs = 4;
+    else if (px > 60.0)
+        arcs = 3;
+    else if (px > 30.0)
+        arcs = 2;
 
-    for (i = 1; i <= arcs; i++) {
-      cairo_arc (cr, 0, 0, px - ((i - 1) * 30.0), 0, 2 * M_PI);
+    for (i = 0; i < arcs; i++) {
+        cairo_arc (cr, 0, 0, px - (i * 30.0), 0, 2 * M_PI);
     }
+
     cairo_set_source_rgba (cr, 1.0, 0.0, 0.0, 0.5);
     cairo_fill_preserve (cr);
     cairo_set_source_rgba (cr, 1.0, 0.0, 0.0, 1.0);
     cairo_stroke (cr);
 
     /* stop before the circles get bigger than the window */
-    if (px <= 3 || px >= 200-3)
+    if (px > 200)
         gtk_main_quit();
-    px += vx;
+
+    px += 3;
 
     return FALSE;
 }
@@ -126,17 +127,18 @@ main (gint argc, gchar **argv)
     gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
     gtk_widget_set_app_paintable (window, TRUE);
     gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window), FALSE);
+    /* tell the wm to ignore if parts of the window are offscreen */
     gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DOCK);
-    gtk_window_set_gravity (GTK_WINDOW (window), GDK_GRAVITY_NORTH_WEST);
     /* center the window around the mouse cursor */
     gtk_window_move (GTK_WINDOW (window), x - 250, y - 250);
 
     g_signal_connect (G_OBJECT (window), "draw",
                       G_CALLBACK (find_cursor_window_draw), NULL);
-    g_signal_connect (G_OBJECT(window), "screen-changed", G_CALLBACK (screen_changed), NULL);
+    g_signal_connect (G_OBJECT(window), "screen-changed",
+                      G_CALLBACK (find_cursor_window_screen_changed), NULL);
     g_signal_connect (G_OBJECT(window), "destroy",
                       G_CALLBACK(gtk_main_quit), NULL);
-    screen_changed (window, NULL, NULL);
+    find_cursor_window_screen_changed (window, NULL, NULL);
     gtk_widget_show_all (window);
 
     g_timeout_add (10, timeout, window);

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


More information about the Xfce4-commits mailing list