Merge lp:~voldyman/pantheon-greeter/fix-1083452 into lp:~elementary-pantheon/pantheon-greeter/trunk

Proposed by Akshay Shekher
Status: Merged
Approved by: Cody Garver
Approved revision: 358
Merged at revision: 358
Proposed branch: lp:~voldyman/pantheon-greeter/fix-1083452
Merge into: lp:~elementary-pantheon/pantheon-greeter/trunk
Diff against target: 170 lines (+86/-9)
4 files modified
CMakeLists.txt (+1/-0)
src/Authenticator.vala (+0/-1)
src/PantheonGreeter.vala (+83/-8)
src/Wallpaper.vala (+2/-0)
To merge this branch: bzr merge lp:~voldyman/pantheon-greeter/fix-1083452
Reviewer Review Type Date Requested Status
elementary Pantheon team Pending
Review via email: mp+257186@code.launchpad.net

Commit message

Set wallpaper as root window pixmap to avoid dark flashes when logging in

Description of the change

Set wallpaper as root window pixmap to avoid dark flashes when logging in

To post a comment you must log in.
Revision history for this message
Danielle Foré (danrabbit) wrote :

Can confirm it works as expected here on Intel

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2015-04-06 21:32:51 +0000
3+++ CMakeLists.txt 2015-04-22 21:12:35 +0000
4@@ -54,6 +54,7 @@
5 indicator-0.4
6 gl
7 posix-fixes
8+ x-fixes
9 OPTIONS
10 --vapidir=${CMAKE_CURRENT_SOURCE_DIR}/vapi
11 )
12
13=== modified file 'src/Authenticator.vala'
14--- src/Authenticator.vala 2015-04-18 06:31:59 +0000
15+++ src/Authenticator.vala 2015-04-22 21:12:35 +0000
16@@ -250,7 +250,6 @@
17 } catch (Error e) {
18 error (e.message);
19 }
20- Posix.exit (Posix.EXIT_SUCCESS);
21 }
22
23 void authentication () {
24
25=== modified file 'src/PantheonGreeter.vala'
26--- src/PantheonGreeter.vala 2015-04-18 06:31:59 +0000
27+++ src/PantheonGreeter.vala 2015-04-22 21:12:35 +0000
28@@ -258,6 +258,8 @@
29 * start_session by firing login_successful!.
30 */
31 void fade_out_ui () {
32+ refresh_background ();
33+
34 // The animations are always the same. If they would have different
35 // lengths we need to use a TransitionGroup to determine
36 // the correct time everything is faded out.
37@@ -331,17 +333,17 @@
38
39 bool scroll_navigation (Gdk.EventScroll e) {
40 switch (e.direction) {
41- case Gdk.ScrollDirection.UP:
42- userlist.select_prev_user ();
43- break;
44- case Gdk.ScrollDirection.DOWN:
45- userlist.select_next_user ();
46- break;
47+ case Gdk.ScrollDirection.UP:
48+ userlist.select_prev_user ();
49+ break;
50+ case Gdk.ScrollDirection.DOWN:
51+ userlist.select_next_user ();
52+ break;
53 }
54
55 return false;
56 }
57-
58+
59 public string? get_greeter_state (string key) {
60 try {
61 return state.get_value ("greeter", key);
62@@ -361,7 +363,74 @@
63 }
64 }
65
66-
67+ Cairo.XlibSurface? create_root_surface (Gdk.Screen screen) {
68+ var visual = screen.get_system_visual ();
69+ var xvisual = (visual as Gdk.X11.Visual).get_xvisual ();
70+
71+ var gdk_display = (screen.get_display () as Gdk.X11.Display);
72+ unowned X.Display display = gdk_display.get_xdisplay ();
73+
74+ var root_window = (screen.get_root_window () as Gdk.X11.Window);
75+ var pixmap = X.CreatePixmap (display,
76+ root_window.get_xid (),
77+ screen.get_width (),
78+ screen.get_height (),
79+ visual.get_depth ());
80+
81+ /* Convert into a Cairo surface */
82+ var surface = new Cairo.XlibSurface (display, pixmap,
83+ xvisual,
84+ screen.get_width (),
85+ screen.get_height ());
86+
87+ return surface;
88+ }
89+
90+ void draw_wallpaper_on_surface (Cairo.Surface surface) {
91+ var ctx = new Cairo.Context (surface);
92+ ctx.save ();
93+ ctx.set_source_rgba (0.0, 0.0, 0.0, 0.0);
94+
95+ var current_pixbuf = wallpaper.background_pixbuf;
96+
97+ var img_surface = new Cairo.Surface.similar (surface, Cairo.Content.COLOR_ALPHA,
98+ current_pixbuf.width,
99+ current_pixbuf.height);
100+
101+ var img_ctx = new Cairo.Context (img_surface);
102+
103+ Gdk.cairo_set_source_pixbuf (img_ctx, current_pixbuf,
104+ 0, 0);
105+
106+ img_ctx.paint ();
107+
108+ ctx.set_source_surface (img_surface, 0, 0);
109+ ctx.paint ();
110+ ctx.restore ();
111+ }
112+
113+ void refresh_background () {
114+ var screen = Gdk.Screen.get_default ();
115+ var root_window = (screen.get_root_window () as Gdk.X11.Window);
116+ var background_surface = create_root_surface (screen);
117+
118+ draw_wallpaper_on_surface (background_surface);
119+
120+ Gdk.flush ();
121+
122+ var x_display = (screen.get_display () as Gdk.X11.Display);
123+ unowned X.Display display = x_display.get_xdisplay ();
124+
125+ /* Ensure Cairo has actually finished it's drawing */
126+ background_surface.flush ();
127+
128+ /* Use this pixmap for the background */
129+ X.SetWindowBackgroundPixmap (display,
130+ root_window.get_xid (),
131+ background_surface.get_drawable ());
132+
133+ X.ClearWindow (display, root_window.get_xid ());
134+ }
135 }
136
137 public static int main (string [] args) {
138@@ -373,6 +442,12 @@
139 if (init != Clutter.InitError.SUCCESS)
140 error ("Clutter could not be intiailized");
141
142+ message ("Registering TERM signal...");
143+ GLib.Unix.signal_add (GLib.ProcessSignal.TERM, () => {
144+ message ("SIGTERM received, exiting...");
145+ Gtk.main_quit ();
146+ return true;
147+ });
148
149 message ("Applying settings...");
150 /*some settings*/
151
152=== modified file 'src/Wallpaper.vala'
153--- src/Wallpaper.vala 2015-02-06 16:09:15 +0000
154+++ src/Wallpaper.vala 2015-04-22 21:12:35 +0000
155@@ -44,6 +44,7 @@
156
157 string last_loaded = "";
158
159+ public Gdk.Pixbuf? background_pixbuf;
160 public int screen_width { get; set; }
161 public int screen_height { get; set; }
162
163@@ -102,6 +103,7 @@
164 //add loaded wallpapers and paths to cache
165 cache_path += path;
166 cache_pixbuf += buf;
167+ background_pixbuf = buf;
168 }
169 //check if the currently loaded wallpaper is the one we loaded in this method
170 if (last_loaded != path)

Subscribers

People subscribed via source and target branches