commit 94d46f7
Michael Forney
·
2015-03-15 08:56:42 +0000 UTC
parent 5009ed3
Implement subcompositor stubs
6 files changed,
+283,
-13
+2,
-0
1@@ -43,6 +43,8 @@ SWC_SOURCES = \
2 libswc/shell.c \
3 libswc/shell_surface.c \
4 libswc/shm.c \
5+ libswc/subcompositor.c \
6+ libswc/subsurface.c \
7 libswc/surface.c \
8 libswc/swc.c \
9 libswc/util.c \
+81,
-0
1@@ -0,0 +1,81 @@
2+/* swc: libswc/subcompositor.c
3+ *
4+ * Copyright (c) 2015 Michael Forney
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in
14+ * all copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ * SOFTWARE.
23+ */
24+
25+#include "swc.h"
26+#include "internal.h"
27+#include "subcompositor.h"
28+#include "subsurface.h"
29+
30+static struct wl_global * global;
31+
32+static void get_subsurface(struct wl_client * client,
33+ struct wl_resource * resource,
34+ uint32_t id,
35+ struct wl_resource * surface_resource,
36+ struct wl_resource * parent_resource)
37+{
38+ struct subsurface * subsurface;
39+
40+ subsurface = subsurface_new(client, wl_resource_get_version(resource), id);
41+
42+ if (!subsurface)
43+ {
44+ wl_resource_post_no_memory(resource);
45+ return;
46+ }
47+}
48+
49+static struct wl_subcompositor_interface subcompositor_implementation = {
50+ .get_subsurface = &get_subsurface,
51+};
52+
53+static void bind_subcompositor(struct wl_client * client, void * data,
54+ uint32_t version, uint32_t id)
55+{
56+ struct wl_resource * resource;
57+
58+ if (version > 1)
59+ version = 1;
60+
61+ resource = wl_resource_create(client, &wl_subcompositor_interface,
62+ version, id);
63+ wl_resource_set_implementation(resource, &subcompositor_implementation,
64+ NULL, NULL);
65+}
66+
67+bool subcompositor_initialize()
68+{
69+ global = wl_global_create(swc.display, &wl_subcompositor_interface, 1,
70+ NULL, &bind_subcompositor);
71+
72+ if (!global)
73+ return false;
74+
75+ return true;
76+}
77+
78+void subcompositor_finalize()
79+{
80+ wl_global_destroy(global);
81+}
82+
+32,
-0
1@@ -0,0 +1,32 @@
2+/* swc: libswc/subcompositor.h
3+ *
4+ * Copyright (c) 2015 Michael Forney
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in
14+ * all copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ * SOFTWARE.
23+ */
24+
25+#ifndef SWC_SUBCOMPOSITOR_H
26+#define SWC_SUBCOMPOSITOR_H
27+
28+bool subcompositor_initialize();
29+
30+void subcompositor_finalize();
31+
32+#endif
33+
+106,
-0
1@@ -0,0 +1,106 @@
2+/* swc: libswc/subsurface.c
3+ *
4+ * Copyright (c) 2015 Michael Forney
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in
14+ * all copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ * SOFTWARE.
23+ */
24+
25+#include "subsurface.h"
26+
27+#include <stdlib.h>
28+#include <wayland-server.h>
29+
30+static void destroy(struct wl_client * client, struct wl_resource * resource)
31+{
32+ wl_resource_destroy(resource);
33+}
34+
35+static void set_position(struct wl_client * client,
36+ struct wl_resource * resource,
37+ int32_t x, int32_t y)
38+{
39+ /* TODO: Implement. */
40+}
41+
42+static void place_above(struct wl_client * client,
43+ struct wl_resource * resource,
44+ struct wl_resource * sibling_resource)
45+{
46+ /* TODO: Implement. */
47+}
48+
49+static void place_below(struct wl_client * client,
50+ struct wl_resource * resource,
51+ struct wl_resource * sibling_resource)
52+{
53+ /* TODO: Implement. */
54+}
55+
56+static void set_sync(struct wl_client * client, struct wl_resource * resource)
57+{
58+ /* TODO: Implement. */
59+}
60+
61+static void set_desync(struct wl_client * client, struct wl_resource * resource)
62+{
63+ /* TODO: Implement. */
64+}
65+
66+static struct wl_subsurface_interface subsurface_implementation = {
67+ .destroy = &destroy,
68+ .set_position = &set_position,
69+ .place_above = &place_above,
70+ .place_below = &place_below,
71+ .set_sync = &set_sync,
72+ .set_desync = &set_desync,
73+};
74+
75+static void subsurface_destroy(struct wl_resource * resource)
76+{
77+ struct subsurface * subsurface = wl_resource_get_user_data(resource);
78+
79+ free(subsurface);
80+}
81+
82+struct subsurface * subsurface_new(struct wl_client * client,
83+ uint32_t version, uint32_t id)
84+{
85+ struct subsurface * subsurface;
86+
87+ if (!(subsurface = malloc(sizeof *subsurface)))
88+ goto error0;
89+
90+ subsurface->resource = wl_resource_create(client, &wl_subsurface_interface,
91+ version, id);
92+
93+ if (!subsurface->resource)
94+ goto error1;
95+
96+ wl_resource_set_implementation(subsurface->resource,
97+ &subsurface_implementation,
98+ subsurface, &subsurface_destroy);
99+
100+ return subsurface;
101+
102+ error1:
103+ free(subsurface);
104+ error0:
105+ return NULL;
106+}
107+
+40,
-0
1@@ -0,0 +1,40 @@
2+/* swc: libswc/subsurface.h
3+ *
4+ * Copyright (c) 2015 Michael Forney
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in
14+ * all copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+ * SOFTWARE.
23+ */
24+
25+#ifndef SWC_SUBSURFACE_H
26+#define SWC_SUBSURFACE_H
27+
28+#include <stdint.h>
29+
30+struct wl_client;
31+
32+struct subsurface
33+{
34+ struct wl_resource * resource;
35+};
36+
37+struct subsurface * subsurface_new(struct wl_client * client,
38+ uint32_t version, uint32_t id);
39+
40+#endif
41+
+22,
-13
1@@ -36,6 +36,7 @@
2 #include "seat.h"
3 #include "shell.h"
4 #include "shm.h"
5+#include "subcompositor.h"
6 #include "util.h"
7 #include "window.h"
8 #include "xdg_shell.h"
9@@ -145,53 +146,59 @@ bool swc_initialize(struct wl_display * display,
10 goto error3;
11 }
12
13+ if (!subcompositor_initialize())
14+ {
15+ ERROR("Could not initialize subcompositor\n");
16+ goto error4;
17+ }
18+
19 if (!screens_initialize())
20 {
21 ERROR("Could not initialize screens\n");
22- goto error4;
23+ goto error5;
24 }
25
26 if (!compositor_initialize())
27 {
28 ERROR("Could not initialize compositor\n");
29- goto error5;
30+ goto error6;
31 }
32
33 if (!data_device_manager_initialize())
34 {
35 ERROR("Could not initialize data device manager\n");
36- goto error6;
37+ goto error7;
38 }
39
40 if (!seat_initialize(default_seat))
41 {
42 ERROR("Could not initialize seat\n");
43- goto error7;
44+ goto error8;
45 }
46
47 if (!shell_initialize())
48 {
49 ERROR("Could not initialize shell\n");
50- goto error8;
51+ goto error9;
52 }
53
54 if (!xdg_shell_initialize())
55 {
56 ERROR("Could not initialize XDG shell\n");
57- goto error9;
58+ goto error10;
59 }
60
61 if (!panel_manager_initialize())
62 {
63 ERROR("Could not initialize panel manager\n");
64- goto error10;
65+ goto error11;
66 }
67
68 #ifdef ENABLE_XWAYLAND
69 if (!xserver_initialize())
70 {
71 ERROR("Could not initialize xwayland\n");
72- goto error11;
73+ goto error12;
74 }
75 #endif
76
77@@ -200,17 +207,19 @@ bool swc_initialize(struct wl_display * display,
78 return true;
79
80 #ifdef ENABLE_XWAYLAND
81- error11:
82+ error12:
83 panel_manager_finalize();
84 #endif
85- error10:
86+ error11:
87 xdg_shell_finalize();
88- error9:
89+ error10:
90 shell_finalize();
91- error8:
92+ error9:
93 seat_finalize();
94- error7:
95+ error8:
96 data_device_manager_finalize();
97+ error7:
98+ subcompositor_finalize();
99 error6:
100 compositor_finalize();
101 error5: