[Xfce4-commits] [xfce/xfce4-settings] 22/27: Make sizes const and drop useless includes
noreply at xfce.org
noreply at xfce.org
Sun Feb 25 23:56:31 CET 2018
This is an automated email from the git hooks/post-receive script.
o c h o s i p u s h e d a c o m m i t t o b r a n c h x f c e - 4 . 1 2
in repository xfce/xfce4-settings.
commit c4bb03d44304602e904ed866bd4e35dd563eac16
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Sun Feb 25 15:42:33 2018 +0100
Make sizes const and drop useless includes
---
dialogs/accessibility-settings/find-cursor.c | 44 +++++++++++++++-------------
1 file changed, 23 insertions(+), 21 deletions(-)
diff --git a/dialogs/accessibility-settings/find-cursor.c b/dialogs/accessibility-settings/find-cursor.c
index 0932bd6..3a7ecf3 100644
--- a/dialogs/accessibility-settings/find-cursor.c
+++ b/dialogs/accessibility-settings/find-cursor.c
@@ -30,23 +30,22 @@
#include <gdk/gdkx.h>
#include <math.h>
-#include <X11/extensions/shape.h>
-#include <gdk/gdkkeysyms.h>
-
#include <xfconf/xfconf.h>
+/* size of the window and circles */
+#define CIRCLE_SIZE 500
+#define CIRCLE_RADIUS 250
+
/* global var to keep track of the circle size */
double px = 1;
-/* size of the final circles */
-gint circle_size = 500;
-
GdkPixbuf *pixbuf = NULL;
gint screenshot_offset_x, screenshot_offset_y;
/* gdk_cairo_set_source_pixbuf() crashes with 0,0 */
gint workaround_offset = 1;
+
gboolean timeout (gpointer data)
{
GtkWidget *widget = GTK_WIDGET (data);
@@ -61,8 +60,8 @@ static GdkPixbuf
GdkPixbuf *screenshot = NULL;
GdkWindow *root_window = gdk_get_default_root_window ();
GdkColormap *colormap = gdk_colormap_get_system();
- gint width = circle_size + workaround_offset;
- gint height = circle_size + workaround_offset;
+ gint width = CIRCLE_SIZE + workaround_offset;
+ gint height = CIRCLE_SIZE + workaround_offset;
/* cut down screenshot if it's out of bounds */
if (x < 0) {
@@ -91,7 +90,7 @@ find_cursor_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event,
gpointer userdata)
{
- gtk_window_move (GTK_WINDOW (widget), event->x_root - (circle_size/2), event->y_root - (circle_size/2));
+ gtk_window_move (GTK_WINDOW (widget), event->x_root - CIRCLE_RADIUS, event->y_root - CIRCLE_RADIUS);
return FALSE;
}
@@ -126,6 +125,7 @@ find_cursor_window_expose (GtkWidget *widget,
gboolean composited = GPOINTER_TO_INT (user_data);
cr = gdk_cairo_create (event->window);
+
if (composited) {
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0);
@@ -135,7 +135,9 @@ find_cursor_window_expose (GtkWidget *widget,
if (screenshot_offset_x > 0) screenshot_offset_x = 0;
if (screenshot_offset_y > 0) screenshot_offset_y = 0;
- gdk_cairo_set_source_pixbuf (cr, pixbuf, 0 - screenshot_offset_x - workaround_offset, 0 - screenshot_offset_y - workaround_offset);
+ gdk_cairo_set_source_pixbuf (cr, pixbuf,
+ 0 - screenshot_offset_x - workaround_offset,
+ 0 - screenshot_offset_y - workaround_offset);
}
else
g_warning ("Something with the screenshot went wrong.");
@@ -144,7 +146,7 @@ find_cursor_window_expose (GtkWidget *widget,
cairo_paint (cr);
cairo_set_line_width (cr, 3.0);
- cairo_translate (cr, circle_size / 2, circle_size / 2);
+ cairo_translate (cr, CIRCLE_RADIUS, CIRCLE_RADIUS);
if (px > 90.0)
arcs = 4;
@@ -166,7 +168,7 @@ find_cursor_window_expose (GtkWidget *widget,
}
/* stop before the circles get bigger than the window */
- if (px >= (circle_size/2)) {
+ if (px >= CIRCLE_RADIUS) {
if (pixbuf)
g_object_unref (pixbuf);
gtk_main_quit ();
@@ -203,9 +205,8 @@ main (gint argc, gchar **argv)
/* open the channels */
accessibility_channel = xfconf_channel_new ("accessibility");
- if (xfconf_channel_get_bool (accessibility_channel, "/FindCursor", TRUE))
- g_warning ("continue");
- else
+ /* don't do anything if the /FindCursor setting is not enabled */
+ if (!xfconf_channel_get_bool (accessibility_channel, "/FindCursor", TRUE))
return 0;
gtk_init (&argc, &argv);
@@ -218,28 +219,29 @@ main (gint argc, gchar **argv)
window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_container_set_border_width (GTK_CONTAINER (window), 0);
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
- gtk_window_set_default_size (GTK_WINDOW (window), circle_size, circle_size);
- gtk_widget_set_size_request (GTK_WIDGET (window), circle_size, circle_size);
+ gtk_window_set_default_size (GTK_WINDOW (window), CIRCLE_SIZE, CIRCLE_SIZE);
+ gtk_widget_set_size_request (GTK_WIDGET (window), CIRCLE_SIZE, CIRCLE_SIZE);
gtk_window_set_decorated (GTK_WINDOW (window), FALSE);
gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE);
gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window), FALSE);
/* center the window around the mouse cursor */
- gtk_window_move (GTK_WINDOW (window), x - (circle_size/2), y - (circle_size/2));
+ gtk_window_move (GTK_WINDOW (window), x - CIRCLE_RADIUS, y - CIRCLE_RADIUS);
/* check if we're in a composited environment */
composited = find_cursor_window_composited (GTK_WIDGET (window));
- /* make the circles follow the mouse cursor */
+ /* with compositor: make the circles follow the mouse cursor */
if (composited) {
gtk_widget_set_events (GTK_WIDGET (window), GDK_POINTER_MOTION_MASK);
g_signal_connect (G_OBJECT (window), "motion-notify-event",
G_CALLBACK (find_cursor_motion_notify_event), NULL);
}
+ /* fake transparency by creating a screenshot and using that as window bg */
else {
/* this offset has to match the screenshot */
- screenshot_offset_x = x - (circle_size/2) - workaround_offset;
- screenshot_offset_y = y - (circle_size/2) - workaround_offset;
+ screenshot_offset_x = x - CIRCLE_RADIUS - workaround_offset;
+ screenshot_offset_y = y - CIRCLE_RADIUS - workaround_offset;
pixbuf = get_rectangle_screenshot (screenshot_offset_x, screenshot_offset_y);
if (!pixbuf)
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list