Codebase list wlroots / e521b04
Add server-decoration skeleton emersion 6 years ago
5 changed file(s) with 190 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 #ifndef WLR_TYPES_WLR_SERVER_DECORATION_H
1 #define WLR_TYPES_WLR_SERVER_DECORATION_H
2
3 #include <wayland-server.h>
4
5 struct wlr_server_decoration_manager {
6 struct wl_global *wl_global;
7 struct wl_list decorations; // wlr_server_decoration::link
8
9 void *data;
10 };
11
12 struct wlr_server_decoration {
13 struct wl_resource *resource;
14 struct wl_list link;
15
16 struct {
17 struct wl_signal destroy;
18 } events;
19
20 void *data;
21 };
22
23 struct wlr_server_decoration_manager *wlr_server_decoration_manager_create(
24 struct wl_display *display);
25 void wlr_server_decoration_manager_destroy(
26 struct wlr_server_decoration_manager *manager);
27
28 #endif
2323 [wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'],
2424 'gamma-control.xml',
2525 'screenshooter.xml',
26 'server-decoration.xml',
2627 ]
2728
2829 client_protocols = [
2930 [wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'],
3031 'gamma-control.xml',
3132 'screenshooter.xml',
33 'server-decoration.xml',
3234 ]
3335
3436 wl_protos_src = []
0 <?xml version="1.0" encoding="UTF-8"?>
1 <protocol name="server_decoration">
2 <copyright><![CDATA[
3 Copyright (C) 2015 Martin Gräßlin
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 ]]></copyright>
18 <interface name="org_kde_kwin_server_decoration_manager" version="1">
19 <description summary="Server side window decoration manager">
20 This interface allows to coordinate whether the server should create
21 a server-side window decoration around a wl_surface representing a
22 shell surface (wl_shell_surface or similar). By announcing support
23 for this interface the server indicates that it supports server
24 side decorations.
25 </description>
26 <request name="create">
27 <description summary="Create a server-side decoration object for a given surface">
28 When a client creates a server-side decoration object it indicates
29 that it supports the protocol. The client is supposed to tell the
30 server whether it wants server-side decorations or will provide
31 client-side decorations.
32
33 If the client does not create a server-side decoration object for
34 a surface the server interprets this as lack of support for this
35 protocol and considers it as client-side decorated. Nevertheless a
36 client-side decorated surface should use this protocol to indicate
37 to the server that it does not want a server-side deco.
38 </description>
39 <arg name="id" type="new_id" interface="org_kde_kwin_server_decoration"/>
40 <arg name="surface" type="object" interface="wl_surface"/>
41 </request>
42 <enum name="mode">
43 <description summary="Possible values to use in request_mode and the event mode."/>
44 <entry name="None" value="0" summary="Undecorated: The surface is not decorated at all, neither server nor client-side. An example is a popup surface which should not be decorated."/>
45 <entry name="Client" value="1" summary="Client-side decoration: The decoration is part of the surface and the client."/>
46 <entry name="Server" value="2" summary="Server-side decoration: The server embeds the surface into a decoration frame."/>
47 </enum>
48 <event name="default_mode">
49 <description summary="The default mode used on the server">
50 This event is emitted directly after binding the interface. It contains
51 the default mode for the decoration. When a new server decoration object
52 is created this new object will be in the default mode until the first
53 request_mode is requested.
54
55 The server may change the default mode at any time.
56 </description>
57 <arg name="mode" type="uint" summary="The default decoration mode applied to newly created server decorations."/>
58 </event>
59 </interface>
60 <interface name="org_kde_kwin_server_decoration" version="1">
61 <request name="release" type="destructor">
62 <description summary="release the server decoration object"/>
63 </request>
64 <enum name="mode">
65 <description summary="Possible values to use in request_mode and the event mode."/>
66 <entry name="None" value="0" summary="Undecorated: The surface is not decorated at all, neither server nor client-side. An example is a popup surface which should not be decorated."/>
67 <entry name="Client" value="1" summary="Client-side decoration: The decoration is part of the surface and the client."/>
68 <entry name="Server" value="2" summary="Server-side decoration: The server embeds the surface into a decoration frame."/>
69 </enum>
70 <request name="request_mode">
71 <description summary="The decoration mode the surface wants to use."/>
72 <arg name="mode" type="uint" summary="The mode this surface wants to use."/>
73 </request>
74 <event name="mode">
75 <description summary="The new decoration mode applied by the server">
76 This event is emitted directly after the decoration is created and
77 represents the base decoration policy by the server. E.g. a server
78 which wants all surfaces to be client-side decorated will send Client,
79 a server which wants server-side decoration will send Server.
80
81 The client can request a different mode through the decoration request.
82 The server will acknowledge this by another event with the same mode. So
83 even if a server prefers server-side decoration it's possible to force a
84 client-side decoration.
85
86 The server may emit this event at any time. In this case the client can
87 again request a different mode. It's the responsibility of the server to
88 prevent a feedback loop.
89 </description>
90 <arg name="mode" type="uint" summary="The decoration mode applied to the surface by the server."/>
91 </event>
92 </interface>
93 </protocol>
1414 'wlr_region.c',
1515 'wlr_screenshooter.c',
1616 'wlr_seat.c',
17 'wlr_server_decoration.c',
1718 'wlr_surface.c',
1819 'wlr_tablet_pad.c',
1920 'wlr_tablet_tool.c',
0 #include <assert.h>
1 #include <stdlib.h>
2 #include <server-decoration-protocol.h>
3 #include <wlr/types/wlr_server_decoration.h>
4
5 static const struct org_kde_kwin_server_decoration_manager_interface
6 server_decoration_manager_impl = {
7 // TODO
8 };
9
10 static void server_decoration_manager_bind(struct wl_client *client,
11 void *_manager, uint32_t version, uint32_t id) {
12 struct wlr_server_decoration_manager *manager = _manager;
13 assert(client && manager);
14
15 struct wl_resource *resource = wl_resource_create(client,
16 &org_kde_kwin_server_decoration_manager_interface, version, id);
17 if (resource == NULL) {
18 wl_client_post_no_memory(client);
19 return;
20 }
21 wl_resource_set_implementation(resource, &server_decoration_manager_impl,
22 manager, NULL);
23 }
24
25 static void server_decoration_destroy(
26 struct wlr_server_decoration *decoration) {
27 wl_signal_emit(&decoration->events.destroy, decoration);
28 wl_resource_set_user_data(decoration->resource, NULL);
29 wl_list_remove(&decoration->link);
30 free(decoration);
31 }
32
33 struct wlr_server_decoration_manager *wlr_server_decoration_manager_create(
34 struct wl_display *display) {
35 struct wlr_server_decoration_manager *manager =
36 calloc(1, sizeof(struct wlr_server_decoration_manager));
37 if (manager == NULL) {
38 return NULL;
39 }
40 manager->wl_global = wl_global_create(display,
41 &org_kde_kwin_server_decoration_manager_interface, 1, manager,
42 server_decoration_manager_bind);
43 if (manager->wl_global == NULL) {
44 free(manager);
45 return NULL;
46 }
47 wl_list_init(&manager->decorations);
48 return manager;
49 }
50
51 void wlr_server_decoration_manager_destroy(
52 struct wlr_server_decoration_manager *manager) {
53 if (manager == NULL) {
54 return;
55 }
56 struct wlr_server_decoration *decoration, *tmp;
57 wl_list_for_each_safe(decoration, tmp, &manager->decorations,
58 link) {
59 server_decoration_destroy(decoration);
60 }
61 wl_global_destroy(manager->wl_global);
62 free(manager);
63 }