1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
From 293fa0d6a596ba9f1e9dd78a3da171fea3110b84 Mon Sep 17 00:00:00 2001
From: Geoff Paul <geoffro17@gmail.com>
Date: Sat, 7 Mar 2020 14:07:01 -0600
Subject: [PATCH 25/81] Add option to span background across multiple monitors
Signed-off-by: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
---
data/x.dm.slick-greeter.gschema.xml | 8 +++
src/background.vala | 87 ++++++++++++++++++++++-------
src/greeter-list.vala | 1 -
src/main-window.vala | 22 +-------
src/settings.vala | 2 +
5 files changed, 81 insertions(+), 39 deletions(-)
diff --git a/data/x.dm.slick-greeter.gschema.xml b/data/x.dm.slick-greeter.gschema.xml
index 90ebec8..7ceba14 100644
--- a/data/x.dm.slick-greeter.gschema.xml
+++ b/data/x.dm.slick-greeter.gschema.xml
@@ -9,6 +9,14 @@
<default>'#000000'</default>
<summary>Background color (e.g. #772953), set before wallpaper is seen</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 f0789bf..e258d84 100644
--- a/src/background.vala
+++ b/src/background.vala
@@ -29,7 +29,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;
@@ -37,7 +36,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;
@@ -45,7 +44,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 ()
@@ -388,11 +386,14 @@ public class Monitor
public class Background : Gtk.Fixed
{
+ [Flags]
public enum DrawFlags
{
NONE,
GRID,
+ SPAN,
}
+ private DrawFlags flags = DrawFlags.NONE;
/* Fallback color - shown upon first startup, until an async background loader finishes,
* or until a user background or default background is loaded.
@@ -464,7 +465,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; } }
@@ -493,8 +515,13 @@ public class Background : Gtk.Fixed
timer = null;
resize_mode = Gtk.ResizeMode.QUEUE;
- draw_grid = UGSettings.get_boolean (UGSettings.KEY_DRAW_GRID);
loaders = new HashTable<string?, BackgroundLoader> (str_hash, str_equal);
+ if (UGSettings.get_boolean (UGSettings.KEY_DRAW_GRID))
+ flags |= DrawFlags.GRID;
+
+ var mode = UGSettings.get_string (UGSettings.KEY_BACKGROUND_MODE);
+ if (mode == "spanned")
+ flags |= DrawFlags.SPAN;
show ();
}
@@ -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 ();
}
@@ -577,9 +612,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);
}
@@ -625,7 +657,7 @@ public class Background : Gtk.Fixed
c.restore ();
- if ((flags & DrawFlags.GRID) != 0)
+ if (DrawFlags.GRID in flags)
overlay_grid (c);
}
@@ -633,14 +665,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);
@@ -728,19 +768,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 6d8f1f6..958720e 100644
--- a/src/greeter-list.vala
+++ b/src/greeter-list.vala
@@ -928,7 +928,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 ddd3c00..3c4fb2b 100644
--- a/src/main-window.vala
+++ b/src/main-window.vala
@@ -32,8 +32,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;
@@ -131,8 +129,6 @@ public class MainWindow : Gtk.Window
add_user_list ();
- window_size_x = 0;
- window_size_y = 0;
primary_monitor = null;
do_resize = false;
@@ -147,7 +143,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
{
@@ -212,7 +208,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);
}
@@ -223,8 +219,6 @@ public class MainWindow : Gtk.Window
Gdk.Monitor primary = display.get_primary_monitor();
Gdk.Rectangle geometry;
- window_size_x = 0;
- window_size_y = 0;
monitors = new List<Monitor> ();
primary_monitor = null;
@@ -234,16 +228,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);
@@ -258,7 +242,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 7d43449..3822939 100644
--- a/src/settings.vala
+++ b/src/settings.vala
@@ -22,6 +22,7 @@ public class UGSettings
{
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";
@@ -119,6 +120,7 @@ public class UGSettings
var string_keys = new List<string> ();
string_keys.append (KEY_BACKGROUND);
string_keys.append (KEY_BACKGROUND_COLOR);
+ string_keys.append (KEY_BACKGROUND_MODE);
string_keys.append (KEY_LOGO);
string_keys.append (KEY_OTHER_MONITORS_LOGO);
string_keys.append (KEY_THEME_NAME);
--
2.30.2
|