Skip to content

Commit f92ff88

Browse files
authored
Merge pull request #54 from wmww/mock-server-xdg-dialog
Use xdg-dialog-v1 protocol in the mock server
2 parents 12d672e + 7e1aaec commit f92ff88

4 files changed

Lines changed: 120 additions & 2 deletions

File tree

protocol/meson.build

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ protocols = [
1111
'stable/xdg-shell/xdg-shell.xml'),
1212
]
1313

14+
if get_option('tests')
15+
protocols += 'xdg-dialog-v1.xml'
16+
endif
17+
1418
gen_client_header = generator(prog_wayland_scanner,
1519
output: ['@BASENAME@-client.h'],
1620
arguments: ['-c', 'client-header', '@INPUT@', '@BUILD_DIR@/@BASENAME@-client.h'])
@@ -28,8 +32,10 @@ server_protocol_srcs = []
2832

2933
foreach protocol : protocols
3034
client_header = gen_client_header.process(protocol)
31-
server_header = gen_server_header.process(protocol)
3235
code = gen_private_code.process(protocol)
3336
client_protocol_srcs += [client_header, code]
34-
server_protocol_srcs += [server_header, code]
37+
if get_option('tests')
38+
server_header = gen_server_header.process(protocol)
39+
server_protocol_srcs += [server_header, code]
40+
endif
3541
endforeach

protocol/xdg-dialog-v1.xml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<protocol name="xdg_dialog_v1">
3+
<copyright>
4+
Copyright © 2023 Carlos Garnacho
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a
7+
copy of this software and associated documentation files (the "Software"),
8+
to deal in the Software without restriction, including without limitation
9+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10+
and/or sell copies of the Software, and to permit persons to whom the
11+
Software is furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice (including the next
14+
paragraph) shall be included in all copies or substantial portions of the
15+
Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
DEALINGS IN THE SOFTWARE.
24+
</copyright>
25+
26+
<interface name="xdg_wm_dialog_v1" version="1">
27+
<description summary="create dialogs related to other toplevels">
28+
The xdg_wm_dialog_v1 interface is exposed as a global object allowing
29+
to register surfaces with a xdg_toplevel role as "dialogs" relative to
30+
another toplevel.
31+
32+
The compositor may let this relation influence how the surface is
33+
placed, displayed or interacted with.
34+
35+
Warning! The protocol described in this file is currently in the testing
36+
phase. Backward compatible changes may be added together with the
37+
corresponding interface version bump. Backward incompatible changes can
38+
only be done by creating a new major version of the extension.
39+
</description>
40+
41+
<enum name="error">
42+
<entry name="already_used" value="0"
43+
summary="the xdg_toplevel object has already been used to create a xdg_dialog_v1"/>
44+
</enum>
45+
46+
<request name="destroy" type="destructor">
47+
<description summary="destroy the dialog manager object">
48+
Destroys the xdg_wm_dialog_v1 object. This does not affect
49+
the xdg_dialog_v1 objects generated through it.
50+
</description>
51+
</request>
52+
53+
<request name="get_xdg_dialog">
54+
<description summary="create a dialog object">
55+
Creates a xdg_dialog_v1 object for the given toplevel. See the interface
56+
description for more details.
57+
58+
Compositors must raise an already_used error if clients attempt to
59+
create multiple xdg_dialog_v1 objects for the same xdg_toplevel.
60+
</description>
61+
<arg name="id" type="new_id" interface="xdg_dialog_v1"/>
62+
<arg name="toplevel" type="object" interface="xdg_toplevel"/>
63+
</request>
64+
</interface>
65+
66+
<interface name="xdg_dialog_v1" version="1">
67+
<description summary="dialog object">
68+
A xdg_dialog_v1 object is an ancillary object tied to a xdg_toplevel. Its
69+
purpose is hinting the compositor that the toplevel is a "dialog" (e.g. a
70+
temporary window) relative to another toplevel (see
71+
xdg_toplevel.set_parent). If the xdg_toplevel is destroyed, the xdg_dialog_v1
72+
becomes inert.
73+
74+
Through this object, the client may provide additional hints about
75+
the purpose of the secondary toplevel. This interface has no effect
76+
on toplevels that are not attached to a parent toplevel.
77+
</description>
78+
79+
<request name="destroy" type="destructor">
80+
<description summary="destroy the dialog object">
81+
Destroys the xdg_dialog_v1 object. If this object is destroyed
82+
before the related xdg_toplevel, the compositor should unapply its
83+
effects.
84+
</description>
85+
</request>
86+
87+
<request name="set_modal">
88+
<description summary="mark dialog as modal">
89+
Hints that the dialog has "modal" behavior. Modal dialogs typically
90+
require to be fully addressed by the user (i.e. closed) before resuming
91+
interaction with the parent toplevel, and may require a distinct
92+
presentation.
93+
94+
Clients must implement the logic to filter events in the parent
95+
toplevel on their own.
96+
97+
Compositors may choose any policy in event delivery to the parent
98+
toplevel, from delivering all events unfiltered to using them for
99+
internal consumption.
100+
</description>
101+
</request>
102+
103+
<request name="unset_modal">
104+
<description summary="mark dialog as not modal">
105+
Drops the hint that this dialog has "modal" behavior. See
106+
xdg_dialog_v1.set_modal for more details.
107+
</description>
108+
</request>
109+
</interface>
110+
</protocol>

test/mock-server/mock-server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "test-common.h"
1313
#include <wayland-server.h>
1414
#include "xdg-shell-server.h"
15+
#include "xdg-dialog-v1-server.h"
1516
#include "wlr-layer-shell-unstable-v1-server.h"
1617

1718
extern struct wl_display* display;

test/mock-server/overrides.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,4 +371,5 @@ void init()
371371
default_global_create(display, &wl_subcompositor_interface, 1);
372372
default_global_create(display, &xdg_wm_base_interface, 2);
373373
default_global_create(display, &zwlr_layer_shell_v1_interface, 4);
374+
default_global_create(display, &xdg_wm_dialog_v1_interface, 1);
374375
}

0 commit comments

Comments
 (0)