Commit d0a29e5c authored by Victor Ananjevsky's avatar Victor Ananjevsky

improve placement of yad window. now negative zero as a coordinate works correctly

parent 4b40155c
...@@ -350,6 +350,7 @@ create_layout (GtkWidget *dlg) ...@@ -350,6 +350,7 @@ create_layout (GtkWidget *dlg)
static void static void
realize_cb (GtkWidget *dlg, gpointer d) realize_cb (GtkWidget *dlg, gpointer d)
{ {
GdkGravity gravity = GDK_GRAVITY_NORTH_WEST;
if (options.data.fixed) if (options.data.fixed)
{ {
...@@ -378,10 +379,19 @@ realize_cb (GtkWidget *dlg, gpointer d) ...@@ -378,10 +379,19 @@ realize_cb (GtkWidget *dlg, gpointer d)
gtk_window_get_position (GTK_WINDOW (dlg), &options.data.posx, NULL); gtk_window_get_position (GTK_WINDOW (dlg), &options.data.posx, NULL);
if (!options.data.use_posy) if (!options.data.use_posy)
gtk_window_get_position (GTK_WINDOW (dlg), NULL, &options.data.posy); gtk_window_get_position (GTK_WINDOW (dlg), NULL, &options.data.posy);
if (options.data.posx < 0) if (options.data.negx)
options.data.posx = sw - ww + options.data.posx; {
if (options.data.posy < 0) options.data.posx = sw - ww + options.data.posx;
options.data.posy = sh - wh + options.data.posy; gravity = GDK_GRAVITY_NORTH_EAST;
}
if (options.data.negy)
{
options.data.posy = sh - wh + options.data.posy;
gravity = GDK_GRAVITY_SOUTH_WEST;
}
if (options.data.negx && options.data.negy)
gravity = GDK_GRAVITY_SOUTH_EAST;
gtk_window_set_gravity (GTK_WINDOW (dlg), gravity);
gtk_window_move (GTK_WINDOW (dlg), options.data.posx, options.data.posy); gtk_window_move (GTK_WINDOW (dlg), options.data.posx, options.data.posy);
} }
} }
......
...@@ -1239,6 +1239,7 @@ set_posx (const gchar * option_name, const gchar * value, gpointer data, GError ...@@ -1239,6 +1239,7 @@ set_posx (const gchar * option_name, const gchar * value, gpointer data, GError
{ {
options.data.use_posx = TRUE; options.data.use_posx = TRUE;
options.data.posx = atol (value); options.data.posx = atol (value);
options.data.negx = (*value == '-');
return TRUE; return TRUE;
} }
...@@ -1248,6 +1249,7 @@ set_posy (const gchar * option_name, const gchar * value, gpointer data, GError ...@@ -1248,6 +1249,7 @@ set_posy (const gchar * option_name, const gchar * value, gpointer data, GError
{ {
options.data.use_posy = TRUE; options.data.use_posy = TRUE;
options.data.posy = atol (value); options.data.posy = atol (value);
options.data.negy = (*value == '-');
return TRUE; return TRUE;
} }
...@@ -1592,8 +1594,10 @@ yad_options_init (void) ...@@ -1592,8 +1594,10 @@ yad_options_init (void)
#endif #endif
options.data.use_posx = FALSE; options.data.use_posx = FALSE;
options.data.posx = 0; options.data.posx = 0;
options.data.negx = FALSE;
options.data.use_posy = FALSE; options.data.use_posy = FALSE;
options.data.posy = 0; options.data.posy = 0;
options.data.negy = FALSE;
options.data.geometry = NULL; options.data.geometry = NULL;
options.data.dialog_text = NULL; options.data.dialog_text = NULL;
options.data.text_width = 0; options.data.text_width = 0;
......
...@@ -546,6 +546,7 @@ parse_geometry () ...@@ -546,6 +546,7 @@ parse_geometry ()
ptr = geom + i; ptr = geom + i;
x = atoi (ptr); x = atoi (ptr);
options.data.negx = (*ptr == '-');
i++; i++;
while (geom[i] && geom[i] != '-' && geom[i] != '+') i++; while (geom[i] && geom[i] != '-' && geom[i] != '+') i++;
...@@ -555,6 +556,7 @@ parse_geometry () ...@@ -555,6 +556,7 @@ parse_geometry ()
ptr = geom + i; ptr = geom + i;
y = atoi (ptr); y = atoi (ptr);
options.data.negy = (*ptr == '-');
} }
if (w != -1) if (w != -1)
......
...@@ -227,8 +227,10 @@ typedef struct { ...@@ -227,8 +227,10 @@ typedef struct {
gint height; gint height;
gboolean use_posx; gboolean use_posx;
gint posx; gint posx;
gboolean negx;
gboolean use_posy; gboolean use_posy;
gint posy; gint posy;
gboolean negy;
gchar *geometry; gchar *geometry;
guint timeout; guint timeout;
gchar *to_indicator; gchar *to_indicator;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment