Skip to content

Commit

Permalink
Merge pull request #54 from wmww/mock-server-xdg-dialog
Browse files Browse the repository at this point in the history
 Use xdg-dialog-v1 protocol in the mock server
  • Loading branch information
wmww authored Nov 4, 2024
2 parents 12d672e + 7e1aaec commit f92ff88
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 2 deletions.
10 changes: 8 additions & 2 deletions protocol/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ protocols = [
'stable/xdg-shell/xdg-shell.xml'),
]

if get_option('tests')
protocols += 'xdg-dialog-v1.xml'
endif

gen_client_header = generator(prog_wayland_scanner,
output: ['@[email protected]'],
arguments: ['-c', 'client-header', '@INPUT@', '@BUILD_DIR@/@[email protected]'])
Expand All @@ -28,8 +32,10 @@ server_protocol_srcs = []

foreach protocol : protocols
client_header = gen_client_header.process(protocol)
server_header = gen_server_header.process(protocol)
code = gen_private_code.process(protocol)
client_protocol_srcs += [client_header, code]
server_protocol_srcs += [server_header, code]
if get_option('tests')
server_header = gen_server_header.process(protocol)
server_protocol_srcs += [server_header, code]
endif
endforeach
110 changes: 110 additions & 0 deletions protocol/xdg-dialog-v1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="xdg_dialog_v1">
<copyright>
Copyright © 2023 Carlos Garnacho

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
</copyright>

<interface name="xdg_wm_dialog_v1" version="1">
<description summary="create dialogs related to other toplevels">
The xdg_wm_dialog_v1 interface is exposed as a global object allowing
to register surfaces with a xdg_toplevel role as "dialogs" relative to
another toplevel.

The compositor may let this relation influence how the surface is
placed, displayed or interacted with.

Warning! The protocol described in this file is currently in the testing
phase. Backward compatible changes may be added together with the
corresponding interface version bump. Backward incompatible changes can
only be done by creating a new major version of the extension.
</description>

<enum name="error">
<entry name="already_used" value="0"
summary="the xdg_toplevel object has already been used to create a xdg_dialog_v1"/>
</enum>

<request name="destroy" type="destructor">
<description summary="destroy the dialog manager object">
Destroys the xdg_wm_dialog_v1 object. This does not affect
the xdg_dialog_v1 objects generated through it.
</description>
</request>

<request name="get_xdg_dialog">
<description summary="create a dialog object">
Creates a xdg_dialog_v1 object for the given toplevel. See the interface
description for more details.

Compositors must raise an already_used error if clients attempt to
create multiple xdg_dialog_v1 objects for the same xdg_toplevel.
</description>
<arg name="id" type="new_id" interface="xdg_dialog_v1"/>
<arg name="toplevel" type="object" interface="xdg_toplevel"/>
</request>
</interface>

<interface name="xdg_dialog_v1" version="1">
<description summary="dialog object">
A xdg_dialog_v1 object is an ancillary object tied to a xdg_toplevel. Its
purpose is hinting the compositor that the toplevel is a "dialog" (e.g. a
temporary window) relative to another toplevel (see
xdg_toplevel.set_parent). If the xdg_toplevel is destroyed, the xdg_dialog_v1
becomes inert.

Through this object, the client may provide additional hints about
the purpose of the secondary toplevel. This interface has no effect
on toplevels that are not attached to a parent toplevel.
</description>

<request name="destroy" type="destructor">
<description summary="destroy the dialog object">
Destroys the xdg_dialog_v1 object. If this object is destroyed
before the related xdg_toplevel, the compositor should unapply its
effects.
</description>
</request>

<request name="set_modal">
<description summary="mark dialog as modal">
Hints that the dialog has "modal" behavior. Modal dialogs typically
require to be fully addressed by the user (i.e. closed) before resuming
interaction with the parent toplevel, and may require a distinct
presentation.

Clients must implement the logic to filter events in the parent
toplevel on their own.

Compositors may choose any policy in event delivery to the parent
toplevel, from delivering all events unfiltered to using them for
internal consumption.
</description>
</request>

<request name="unset_modal">
<description summary="mark dialog as not modal">
Drops the hint that this dialog has "modal" behavior. See
xdg_dialog_v1.set_modal for more details.
</description>
</request>
</interface>
</protocol>
1 change: 1 addition & 0 deletions test/mock-server/mock-server.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "test-common.h"
#include <wayland-server.h>
#include "xdg-shell-server.h"
#include "xdg-dialog-v1-server.h"
#include "wlr-layer-shell-unstable-v1-server.h"

extern struct wl_display* display;
Expand Down
1 change: 1 addition & 0 deletions test/mock-server/overrides.c
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,5 @@ void init()
default_global_create(display, &wl_subcompositor_interface, 1);
default_global_create(display, &xdg_wm_base_interface, 2);
default_global_create(display, &zwlr_layer_shell_v1_interface, 4);
default_global_create(display, &xdg_wm_dialog_v1_interface, 1);
}

0 comments on commit f92ff88

Please sign in to comment.