← Back to team overview

lightdm-gtk-greeter-team team mailing list archive

Re: Patch submission

 

Dear devs,

I've made some tests, so that a gtk_window cannot be displayed outside
the screen
If position are wrong (eg: it will display things out of sight), then
it puts it at the center (default behavior)
My goal was to add a feature that enable user to simply position the
auth-banner (eg: do not display it upon some important area of the
wallpaper); I think absolute position is the best way to do this
(people know their screen resolution,and might easily find coordinates
to move out the banner, isn't ?)

Anyway, this patch allow people to move it without tricking code, so I
think it is a solution (better than nothing, at least);

Thank for your interest !

Alexandre Bruyelles


2013/6/2 Simon Steinbeiß <simon@xxxxxxxx>:
> Hey Sean,
>
> I'm fine with adding that functionality, but I'm not sure using absolute coordinates is a good thing. On the one hand it doesn't seem very error-safe (we'd have to check the total display size to prevent the user from putting the login-window offscreen – and as we know from the display dialog, this doesn't always work 100% reliably), on the other hand not very user-friendly.
> Using percentages would be a way of avoiding both those issues, but it wouldn't allow the user to put the dialog on a different monitor by using the offset. (I'm not sure that works though anyway with the way the greeter is implemented now.)
>
> Alexander, what are your thoughts on the above?
>
> Cheers,
> Simon
>
>
>
> On Sat, 1 Jun 2013 15:26:49 -0400
> Sean Davis <smd.seandavis@xxxxxxxxx> wrote:
>
>> ---------- Forwarded message ----------
>> From: Alexandre Bruyelles <alexandre.bruyelles@xxxxxxxxx>
>> Date: Thu, May 30, 2013 at 2:41 PM
>> Subject: [Lightdm-gtk-greeter-team] Patch submission
>> To: lightdm-gtk-greeter-team@xxxxxxxxxxxxxxxxxxx
>>
>>
>> Dear team,
>>
>> I've written a (small) patch for my needs, it may be a good idea to push it
>> This patch just allow users to define where will be put the
>> authentication banner, by reading x and y positions from config
>>
>> I hope you will accept it
>>
>> Thanks
>>
>>
>>
>> --- commit/data/lightdm-gtk-greeter.conf        2013-05-30
>> 20:16:47.892174000 +0200
>> +++ new/data/lightdm-gtk-greeter.conf   2013-05-30 20:24:55.052403274 +0200
>> @@ -12,6 +12,8 @@
>>  # show-clock (true or false)
>>  # clock-format = strftime-format string, e.g. %H:%M
>>  # keyboard = command to launch on-screen keyboard
>> +# banner-x = position where to put the authentication banner position (x)
>> +# banner-y = position where to put the authentication banner position (y)
>>  #
>>  [greeter]
>>  background=/lib/plymouth/themes/xubuntu-logo/xubuntu-greybird.png
>> @@ -28,3 +30,5 @@ show-language-selector=true
>>  show-clock=true
>>  clock-format=%a, %I:%M %p
>>  keyboard=onboard
>> +#banner-x=250
>> +#banner-y=250
>> diff -rupN commit/src/lightdm-gtk-greeter.c new/src/lightdm-gtk-greeter.c
>> --- commit/src/lightdm-gtk-greeter.c    2013-05-30 20:16:47.892174000 +0200
>> +++ new/src/lightdm-gtk-greeter.c       2013-05-30 20:23:55.148399038 +0200
>> @@ -78,6 +78,9 @@ static cairo_region_t *window_region = N
>>  static GdkRegion *window_region = NULL;
>>  #endif
>>
>> +/* Banner positions */
>> +static gint banner_x = -1;
>> +static gint banner_y = -1;
>>
>>  #ifdef HAVE_LIBINDICATOR
>>  static gboolean
>> @@ -917,8 +920,10 @@ authentication_complete_cb (LightDMGreet
>>  }
>>
>>  static void
>> -center_window (GtkWindow *window)
>> +position_window (GtkWindow *window)
>>  {
>> +    gint x = banner_x;
>> +    gint y = banner_y;
>>      GdkScreen *screen;
>>      GtkAllocation allocation;
>>      GdkRectangle monitor_geometry;
>> @@ -926,9 +931,14 @@ center_window (GtkWindow *window)
>>      screen = gtk_window_get_screen (window);
>>      gdk_screen_get_monitor_geometry (screen,
>> gdk_screen_get_primary_monitor (screen), &monitor_geometry);
>>      gtk_widget_get_allocation (GTK_WIDGET (window), &allocation);
>> -    gtk_window_move (window,
>> +
>> +    /* Default: if values are not suitable, put the window at the center */
>> +    if (x == -1 || y == -1 || (x + allocation.width >
>> monitor_geometry.width) || (y + allocation.height >
>> monitor_geometry.height))
>> +        gtk_window_move (window,
>>                       monitor_geometry.x + (monitor_geometry.width -
>> allocation.width) / 2,
>>                       monitor_geometry.y + (monitor_geometry.height -
>> allocation.height) / 2);
>> +    else
>> +        gtk_window_move (window, x, y);
>>  }
>>
>>  void suspend_cb (GtkWidget *widget, LightDMGreeter *greeter);
>> @@ -984,7 +994,7 @@ restart_cb (GtkWidget *widget, LightDMGr
>>      /* Hide the login window and show the dialog */
>>      gtk_widget_hide (GTK_WIDGET (login_window));
>>      gtk_widget_show_all (dialog);
>> -    center_window (GTK_WINDOW (dialog));
>> +    position_window (GTK_WINDOW (dialog));
>>
>>      if (gtk_dialog_run (GTK_DIALOG (dialog)))
>>          lightdm_restart (NULL);
>> @@ -1030,7 +1040,7 @@ shutdown_cb (GtkWidget *widget, LightDMG
>>      /* Hide the login window and show the dialog */
>>      gtk_widget_hide (GTK_WIDGET (login_window));
>>      gtk_widget_show_all (dialog);
>> -    center_window (GTK_WINDOW (dialog));
>> +    position_window (GTK_WINDOW (dialog));
>>
>>      if (gtk_dialog_run (GTK_DIALOG (dialog)))
>>          lightdm_shutdown (NULL);
>> @@ -1525,6 +1535,18 @@ main (int argc, char **argv)
>>      /* Set the background */
>>      set_background (NULL);
>>
>> +
>> +    /* Get banner position */
>> +    banner_x = g_key_file_get_integer (config, "greeter", "banner-x",
>> &error);
>> +    if (error)
>> +        banner_x = -1;
>> +    g_clear_error (&error);
>> +
>> +    banner_y = g_key_file_get_integer (config, "greeter", "banner-y",
>> &error);
>> +    if (error)
>> +        banner_y = -1;
>> +    g_clear_error (&error);
>> +
>>      /* Set GTK+ settings */
>>      value = g_key_file_get_value (config, "greeter", "theme-name", NULL);
>>      if (value)
>> @@ -1803,8 +1825,8 @@ main (int argc, char **argv)
>>      gtk_builder_connect_signals(builder, greeter);
>>
>>      gtk_widget_show (GTK_WIDGET (login_window));
>> -    center_window (login_window);
>> -    g_signal_connect (GTK_WIDGET (login_window), "size-allocate",
>> G_CALLBACK (center_window), login_window);
>> +    position_window (login_window);
>> +    g_signal_connect (GTK_WIDGET (login_window), "size-allocate",
>> G_CALLBACK (position_window), login_window);
>>
>>      gtk_widget_show (GTK_WIDGET (panel_window));
>>      GtkAllocation allocation;
>>
>> --
>> Mailing list: https://launchpad.net/~lightdm-gtk-greeter-team
>> Post to     : lightdm-gtk-greeter-team@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~lightdm-gtk-greeter-team
>> More help   : https://help.launchpad.net/ListHelp


References