Make eye movement independent, like in xeyes (bug #9036).

Clean up formatting of this function and make the eye movement independent.
The actual change is subtracting GTK_WIDGET(widget)->allocation.x from nx
and GTK_WIDGET(widget)->allocation.y from ny.
This commit is contained in:
Harald Judt 2013-02-27 13:53:16 +01:00
parent 64c5b6460a
commit c5f5e0484d

View file

@ -56,8 +56,11 @@ static void eyes_write_rc_file (XfcePanelPlugin *plugin,
*****************************/ *****************************/
static void static void
calculate_pupil_xy (EyesPlugin *eyes_applet, calculate_pupil_xy (EyesPlugin *eyes_applet,
gint x, gint y, gint x,
gint *pupil_x, gint *pupil_y, GtkWidget* widget) gint y,
gint *pupil_x,
gint *pupil_y,
GtkWidget *widget)
{ {
double sina; double sina;
double cosa; double cosa;
@ -70,18 +73,25 @@ calculate_pupil_xy (EyesPlugin *eyes_applet,
width = GTK_WIDGET(widget)->allocation.width; width = GTK_WIDGET(widget)->allocation.width;
height = GTK_WIDGET(widget)->allocation.height; height = GTK_WIDGET(widget)->allocation.height;
gtk_misc_get_alignment(GTK_MISC(widget), &xalign, &yalign); gtk_misc_get_alignment(GTK_MISC(widget), &xalign, &yalign);
nx = x - MAX(width - eyes_applet->eye_width, 0) * xalign - eyes_applet->eye_width / 2; nx = x - (MAX(width - eyes_applet->eye_width, 0)
ny = y - MAX(height- eyes_applet->eye_height, 0) * yalign - eyes_applet->eye_height / 2; * xalign - eyes_applet->eye_width / 2)
- GTK_WIDGET(widget)->allocation.x;
ny = y - (MAX(height - eyes_applet->eye_height, 0)
* yalign - eyes_applet->eye_height / 2)
- GTK_WIDGET(widget)->allocation.y;
h = hypot (nx, ny); h = hypot (nx, ny);
if (h < 0.5 || abs (h) if (h < 0.5 ||
< (abs (hypot (eyes_applet->eye_height / 2, eyes_applet->eye_width / 2)) - eyes_applet->wall_thickness - eyes_applet->pupil_height)) abs (h) < (abs (hypot (eyes_applet->eye_height / 2,
eyes_applet->eye_width / 2))
- eyes_applet->wall_thickness
- eyes_applet->pupil_height))
{ {
*pupil_x = nx + eyes_applet->eye_width / 2; *pupil_x = nx + eyes_applet->eye_width / 2;
*pupil_y = ny + eyes_applet->eye_height / 2; *pupil_y = ny + eyes_applet->eye_height / 2;
return; return;
} }
sina = nx / h; sina = nx / h;