commit 3f17844
Michael Forney
·
2014-01-21 04:37:26 +0000 UTC
parent 31fae1b
compositor: Handle session {,de}activation (VT switching)
1 files changed,
+43,
-3
+43,
-3
1@@ -72,6 +72,8 @@ static struct
2 * idle. */
3 uint32_t scheduled_updates;
4
5+ bool active, updating;
6+
7 struct wl_global * global;
8 } compositor;
9
10@@ -170,7 +172,7 @@ static void handle_screen_view_event(struct wl_listener * listener, void * data)
11
12 /* If we had scheduled updates that couldn't run because we were
13 * waiting on a page flip, run them now. */
14- if (compositor.scheduled_updates)
15+ if (compositor.scheduled_updates && !compositor.updating)
16 perform_update(NULL);
17 break;
18 }
19@@ -413,12 +415,21 @@ static void schedule_updates(uint32_t screens)
20 if (compositor.scheduled_updates == 0)
21 wl_event_loop_add_idle(swc.event_loop, &perform_update, NULL);
22
23+ if (screens == -1)
24+ {
25+ struct swc_screen_internal * screen;
26+
27+ screens = 0;
28+ wl_list_for_each(screen, &swc.screens, link)
29+ screens |= swc_screen_mask(screen);
30+ }
31+
32 compositor.scheduled_updates |= screens;
33 }
34
35 static bool update(struct swc_view * view)
36 {
37- if (!view->visible)
38+ if (!compositor.active || !view->visible)
39 return false;
40
41 schedule_updates(view->screens);
42@@ -725,11 +736,12 @@ static void perform_update(void * data)
43 uint32_t updates = compositor.scheduled_updates
44 & ~compositor.pending_flips;
45
46- if (!updates)
47+ if (!compositor.active || !updates)
48 return;
49
50 DEBUG("Performing update\n");
51
52+ compositor.updating = true;
53 calculate_damage();
54
55 wl_list_for_each(screen, &swc.screens, link)
56@@ -739,6 +751,7 @@ static void perform_update(void * data)
57 pixman_region32_clear(&compositor.damage);
58 compositor.pending_flips |= updates;
59 compositor.scheduled_updates &= ~updates;
60+ compositor.updating = false;
61 }
62
63 void handle_focus(struct swc_pointer * pointer)
64@@ -782,6 +795,30 @@ static void handle_switch_vt(uint32_t time, uint32_t value, void * data)
65 swc_launch_activate_vt(vt);
66 }
67
68+static void handle_launch_event(struct wl_listener * listener, void * data)
69+{
70+ struct swc_event * event = data;
71+ struct swc_screen_internal * screen;
72+
73+ switch (event->type)
74+ {
75+ case SWC_LAUNCH_EVENT_ACTIVATED:
76+ compositor.active = true;
77+ schedule_updates(-1);
78+ wl_list_for_each(screen, &swc.screens, link)
79+ screen->planes.framebuffer.need_modeset = true;
80+ break;
81+ case SWC_LAUNCH_EVENT_DEACTIVATED:
82+ compositor.active = false;
83+ compositor.scheduled_updates = 0;
84+ break;
85+ }
86+}
87+
88+static struct wl_listener launch_listener = {
89+ .notify = &handle_launch_event
90+};
91+
92 static void create_surface(struct wl_client * client,
93 struct wl_resource * resource, uint32_t id)
94 {
95@@ -841,9 +878,12 @@ bool swc_compositor_initialize()
96
97 compositor.scheduled_updates = 0;
98 compositor.pending_flips = 0;
99+ compositor.active = true;
100+ compositor.updating = false;
101 pixman_region32_init(&compositor.damage);
102 pixman_region32_init(&compositor.opaque);
103 wl_list_init(&compositor.views);
104+ wl_signal_add(&swc.launch->event_signal, &launch_listener);
105
106 wl_list_for_each(screen, &swc.screens, link)
107 screen_new(screen);