commit 5fb7304
Michael Forney
·
2014-07-23 00:25:17 +0000 UTC
parent 09023ff
screen: Add wayland global
4 files changed,
+54,
-8
+1,
-1
1@@ -84,8 +84,8 @@ SWC_SHARED_OBJECTS = $(SWC_SOURCES:%.c=%.lo)
2
3 # Explicitly state dependencies on generated files
4 objects = $(foreach obj,$(1),$(dir)/$(obj).o $(dir)/$(obj).lo)
5+$(call objects,compositor panel_manager panel screen): protocol/swc-server-protocol.h
6 $(call objects,drm drm_buffer): protocol/wayland-drm-server-protocol.h
7-$(call objects,panel_manager panel): protocol/swc-server-protocol.h
8 $(call objects,pointer): cursor/cursor_data.h
9
10 $(dir)/libswc.a: $(SWC_STATIC_OBJECTS)
+42,
-7
1@@ -28,6 +28,7 @@
2 #include "mode.h"
3 #include "output.h"
4 #include "util.h"
5+#include "protocol/swc-server-protocol.h"
6
7 #include <stdlib.h>
8 #include <sys/param.h>
9@@ -55,6 +56,28 @@ void screens_finalize()
10 screen_destroy(screen);
11 }
12
13+static void bind_screen(struct wl_client * client, void * data,
14+ uint32_t version, uint32_t id)
15+{
16+ struct screen * screen = data;
17+ struct wl_resource * resource;
18+
19+ if (version >= 1)
20+ version = 1;
21+
22+ resource = wl_resource_create(client, &swc_screen_interface, version, id);
23+
24+ if (!resource)
25+ {
26+ wl_client_post_no_memory(client);
27+ return;
28+ }
29+
30+ wl_resource_set_implementation(resource, NULL,
31+ screen, &swc_remove_resource);
32+ wl_list_insert(&screen->resources, wl_resource_get_link(resource));
33+}
34+
35 struct screen * screen_new(uint32_t crtc, struct swc_output * output)
36 {
37 struct screen * screen;
38@@ -67,26 +90,36 @@ struct screen * screen_new(uint32_t crtc, struct swc_output * output)
39 if (!(screen = malloc(sizeof *screen)))
40 goto error0;
41
42- wl_signal_init(&screen->base.event_signal);
43- wl_list_init(&screen->outputs);
44- wl_list_insert(&screen->outputs, &output->link);
45- wl_list_init(&screen->modifiers);
46+ screen->global = wl_global_create(swc.display, &swc_screen_interface, 1,
47+ screen, &bind_screen);
48+
49+ if (!screen->global)
50+ {
51+ ERROR("Failed to create screen global\n");
52+ goto error1;
53+ }
54
55 if (!framebuffer_plane_initialize(&screen->planes.framebuffer, crtc,
56 output->preferred_mode,
57 &output->connector, 1))
58 {
59 ERROR("Failed to initialize framebuffer plane\n");
60- goto error1;
61+ goto error2;
62 }
63
64 if (!cursor_plane_initialize(&screen->planes.cursor, crtc,
65 &screen->base.geometry))
66 {
67 ERROR("Failed to initialize cursor plane\n");
68- goto error2;
69+ goto error3;
70 }
71
72+ wl_signal_init(&screen->base.event_signal);
73+ wl_list_init(&screen->resources);
74+ wl_list_init(&screen->outputs);
75+ wl_list_insert(&screen->outputs, &output->link);
76+ wl_list_init(&screen->modifiers);
77+
78 view_move(&screen->planes.framebuffer.view, x, 0);
79 screen->base.geometry = screen->planes.framebuffer.view.geometry;
80 screen->base.usable_geometry = screen->base.geometry;
81@@ -95,8 +128,10 @@ struct screen * screen_new(uint32_t crtc, struct swc_output * output)
82
83 return screen;
84
85- error2:
86+ error3:
87 framebuffer_plane_finalize(&screen->planes.framebuffer);
88+ error2:
89+ wl_global_destroy(screen->global);
90 error1:
91 free(screen);
92 error0:
+3,
-0
1@@ -58,6 +58,9 @@ struct screen
2 struct cursor_plane cursor;
3 } planes;
4
5+ struct wl_global * global;
6+ struct wl_list resources;
7+
8 struct wl_list outputs;
9 struct wl_list modifiers;
10 struct wl_list link;
+8,
-0
1@@ -22,6 +22,14 @@
2 SOFTWARE.
3 </copyright>
4
5+ <interface name="swc_screen" version="1">
6+ <description summary="an area in which windows may be placed">
7+ A screen represents an area in which windows may be placed. It
8+ corresponds to one or monitors displaying the same content (in
9+ mirror mode).
10+ </description>
11+ </interface>
12+
13 <interface name="swc_panel_manager" version="1">
14 <request name="create_panel">
15 <arg name="id" type="new_id" interface="swc_panel" />