aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/org.ArcticaProject.arctica-greeter.gschema.xml8
-rw-r--r--src/background.vala91
-rw-r--r--src/greeter-list.vala1
-rw-r--r--src/main-window.vala23
-rw-r--r--src/settings.vala1
5 files changed, 82 insertions, 42 deletions
diff --git a/data/org.ArcticaProject.arctica-greeter.gschema.xml b/data/org.ArcticaProject.arctica-greeter.gschema.xml
index 70ddbe0..5496fe9 100644
--- a/data/org.ArcticaProject.arctica-greeter.gschema.xml
+++ b/data/org.ArcticaProject.arctica-greeter.gschema.xml
@@ -53,6 +53,14 @@
<default>'#4B1635'</default>
<summary>Border color (e.g. #391C31) of flat buttons (e.g. the session chooser icon)</summary>
</key>
+ <key name="background-mode" type="s">
+ <choices>
+ <choice value='zoom'/>
+ <choice value='spanned'/>
+ </choices>
+ <default>'zoom'</default>
+ <summary>Determines how the background image is rendered</summary>
+ </key>
<key name="draw-user-backgrounds" type="b">
<default>true</default>
<summary>Whether to draw user backgrounds</summary>
diff --git a/src/background.vala b/src/background.vala
index d533274..c523eb5 100644
--- a/src/background.vala
+++ b/src/background.vala
@@ -31,7 +31,6 @@ class BackgroundLoader : Object
public Gdk.RGBA average_color;
private Cairo.Surface target_surface;
- private bool draw_grid;
private Thread<void*> thread;
private Gdk.Pixbuf[] images;
private bool finished;
@@ -39,7 +38,7 @@ class BackgroundLoader : Object
public signal void loaded ();
- public BackgroundLoader (Cairo.Surface target_surface, string filename, int[] widths, int[] heights, bool draw_grid)
+ public BackgroundLoader (Cairo.Surface target_surface, string filename, int[] widths, int[] heights)
{
this.target_surface = target_surface;
this.filename = filename;
@@ -47,7 +46,6 @@ class BackgroundLoader : Object
this.heights = heights;
patterns = new Cairo.Pattern[widths.length];
images = new Gdk.Pixbuf[widths.length];
- this.draw_grid = draw_grid;
}
public bool load ()
@@ -391,11 +389,14 @@ public class Monitor
public class Background : Gtk.Fixed
{
+ [Flags]
public enum DrawFlags
{
NONE,
GRID,
+ SPAN,
}
+ private DrawFlags flags = DrawFlags.NONE;
/* Fallback bgcolor - shown upon first startup, until an async background loader finishes,
* or until a user background or default background is loaded.
@@ -468,7 +469,28 @@ public class Background : Gtk.Fixed
}
}
- public bool draw_grid { get; set; default = true; }
+ /* Width - total pixel width of the entire background canvas. This total width
+ * should account for the relative geometry of all attached monitors.
+ */
+
+ private int _width = 0;
+ public int width {
+ get {
+ return _width;
+ }
+ }
+
+ /* Height - total pixel height of the entire background canvas. This total height
+ * should account for the relative geometry of all attached monitors.
+ */
+
+ private int _height = 0;
+ public int height {
+ get {
+ return _height;
+ }
+ }
+
public double alpha { get; private set; default = 1.0; }
public Gdk.RGBA average_color { get { return current.average_color; } }
@@ -478,7 +500,6 @@ public class Background : Gtk.Fixed
private Monitor? active_monitor = null;
private AnimateTimer timer;
- load_background (null);
private BackgroundLoader current;
private BackgroundLoader old;
@@ -495,10 +516,15 @@ public class Background : Gtk.Fixed
timer = null;
resize_mode = Gtk.ResizeMode.QUEUE;
- draw_grid = AGSettings.get_boolean (AGSettings.KEY_DRAW_GRID);
-
loaders = new HashTable<string?, BackgroundLoader> (str_hash, str_equal);
+ if (AGSettings.get_boolean (AGSettings.KEY_DRAW_GRID))
+ flags |= DrawFlags.GRID;
+
+ var mode = AGSettings.get_string (AGSettings.KEY_BACKGROUND_MODE);
+ if (mode == "spanned")
+ flags |= DrawFlags.SPAN;
+
show ();
}
@@ -508,6 +534,7 @@ public class Background : Gtk.Fixed
timer = new AnimateTimer (AnimateTimer.ease_in_out, 700);
+ load_background (null);
set_logo (AGSettings.get_string (AGSettings.KEY_LOGO));
timer.animate.connect (animate_cb);
}
@@ -545,7 +572,15 @@ public class Background : Gtk.Fixed
{
this.monitors = new List<Monitor> ();
foreach (var m in monitors)
+ {
+ if (_width < m.x + m.width)
+ _width = m.x + m.width;
+
+ if (_height < m.y + m.height)
+ _height = m.y + m.height;
+
this.monitors.append (m);
+ }
queue_draw ();
}
@@ -578,9 +613,6 @@ public class Background : Gtk.Fixed
public override bool draw (Cairo.Context c)
{
- var flags = DrawFlags.NONE;
- if (draw_grid)
- flags |= DrawFlags.GRID;
draw_full (c, flags);
return base.draw (c);
}
@@ -626,7 +658,7 @@ public class Background : Gtk.Fixed
c.restore ();
- if ((flags & DrawFlags.GRID) != 0)
+ if (DrawFlags.GRID in flags)
overlay_grid (c);
}
@@ -634,14 +666,22 @@ public class Background : Gtk.Fixed
{
foreach (var monitor in monitors)
{
- var pattern = background.get_pattern (monitor.width, monitor.height);
+ Cairo.Pattern? pattern;
+ var matrix = Cairo.Matrix.identity ();
+ if (DrawFlags.SPAN in flags)
+ {
+ pattern = background.get_pattern (_width, _height);
+ }
+ else
+ {
+ pattern = background.get_pattern (monitor.width, monitor.height);
+ matrix.translate (-monitor.x, -monitor.y);
+ }
+
if (pattern == null)
continue;
c.save ();
- pattern = background.get_pattern (monitor.width, monitor.height);
- var matrix = Cairo.Matrix.identity ();
- matrix.translate (-monitor.x, -monitor.y);
pattern.set_matrix (matrix);
c.set_source (pattern);
c.rectangle (monitor.x, monitor.y, monitor.width, monitor.height);
@@ -710,19 +750,28 @@ public class Background : Gtk.Fixed
var widths = new int[monitors.length ()];
var heights = new int[monitors.length ()];
var n_sizes = 0;
- foreach (var monitor in monitors)
+ if (DrawFlags.SPAN in flags)
+ {
+ widths[n_sizes] = _width;
+ heights[n_sizes] = _height;
+ n_sizes++;
+ }
+ else
{
- if (monitor_is_unique_size (monitor))
+ foreach (var monitor in monitors)
{
- widths[n_sizes] = monitor.width;
- heights[n_sizes] = monitor.height;
- n_sizes++;
+ if (monitor_is_unique_size (monitor))
+ {
+ widths[n_sizes] = monitor.width;
+ heights[n_sizes] = monitor.height;
+ n_sizes++;
+ }
}
}
widths.resize (n_sizes);
heights.resize (n_sizes);
- b = new BackgroundLoader (target_surface, filename, widths, heights, draw_grid);
+ b = new BackgroundLoader (target_surface, filename, widths, heights);
b.logo = version_logo_surface;
b.loaded.connect (() => { reload (); });
b.load ();
diff --git a/src/greeter-list.vala b/src/greeter-list.vala
index 3c5af9f..b1853cf 100644
--- a/src/greeter-list.vala
+++ b/src/greeter-list.vala
@@ -952,7 +952,6 @@ public abstract class GreeterList : FadableBox
}
/* Set the background */
- background.draw_grid = false;
background.queue_draw ();
}
diff --git a/src/main-window.vala b/src/main-window.vala
index cf7042e..fd1e19c 100644
--- a/src/main-window.vala
+++ b/src/main-window.vala
@@ -34,8 +34,6 @@ public class MainWindow : Gtk.Window
private Gtk.Box hbox;
private Gtk.Button back_button;
private ShutdownDialog? shutdown_dialog = null;
- private int window_size_x;
- private int window_size_y;
private bool do_resize;
public ListStack stack;
@@ -156,8 +154,6 @@ public class MainWindow : Gtk.Window
add_user_list ();
- window_size_x = 0;
- window_size_y = 0;
primary_monitor = null;
do_resize = false;
@@ -173,7 +169,7 @@ public class MainWindow : Gtk.Window
monitors.append (new Monitor (800, 120, 640, 480));
background.set_monitors (monitors);
move_to_monitor (monitors.nth_data (0));
- resize (800 + 640, 600);
+ resize (background.width, background.height);
}
else
{
@@ -221,7 +217,7 @@ public class MainWindow : Gtk.Window
/* Setup the size and position of the window */
public void setup_window ()
{
- resize (window_size_x, window_size_y);
+ resize (background.width, background.height);
move (0, 0);
move_to_monitor (primary_monitor);
}
@@ -246,9 +242,6 @@ public class MainWindow : Gtk.Window
Gdk.Monitor primary = display.get_primary_monitor();
geometry = primary.get_geometry();
- window_size_x = 0;
- window_size_y = 0;
-
monitors = new List<Monitor> ();
primary_monitor = null;
@@ -258,16 +251,6 @@ public class MainWindow : Gtk.Window
geometry = monitor.get_geometry ();
debug ("Monitor %d is %dx%d pixels at %d,%d", i, geometry.width, geometry.height, geometry.x, geometry.y);
- if (window_size_x < geometry.x + geometry.width)
- {
- window_size_x = geometry.x + geometry.width;
- }
-
- if (window_size_y < geometry.y + geometry.height)
- {
- window_size_y = geometry.y + geometry.height;
- }
-
if (monitor_is_unique_position (display, i))
{
var greeter_monitor = new Monitor (geometry.x, geometry.y, geometry.width, geometry.height);
@@ -282,7 +265,7 @@ public class MainWindow : Gtk.Window
}
}
- debug ("MainWindow is %dx%d pixels", window_size_x, window_size_y);
+ debug ("MainWindow is %dx%d pixels", background.width, background.height);
background.set_monitors (monitors);
diff --git a/src/settings.vala b/src/settings.vala
index d347813..33d40c1 100644
--- a/src/settings.vala
+++ b/src/settings.vala
@@ -26,6 +26,7 @@ public class AGSettings : Object
{
public const string KEY_BACKGROUND = "background";
public const string KEY_BACKGROUND_COLOR = "background-color";
+ public const string KEY_BACKGROUND_MODE = "background-mode";
public const string KEY_DRAW_USER_BACKGROUNDS = "draw-user-backgrounds";
public const string KEY_DRAW_GRID = "draw-grid";
public const string KEY_SHOW_HOSTNAME = "show-hostname";