Skip to content

Commit

Permalink
wayland: Add experimental pantheon-desktop-shell protocol
Browse files Browse the repository at this point in the history
This is quite hacky but this open the way to using the pantheon-desktop-shell protocol.
  • Loading branch information
tintou committed May 24, 2024
1 parent e4933a6 commit 2175085
Show file tree
Hide file tree
Showing 12 changed files with 571 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ all_doc_target = custom_target(
'--pkg', 'granite',
'--pkg', 'gnome-desktop-3.0',
'--pkg', 'gmodule-2.0',
'--pkg', 'wayland-server',
'--pkg', 'pantheon-desktop-shell',
'--vapidir=' + join_paths(meson.global_source_root(), 'protocol'),
'-o', '@OUTPUT@',
'@INPUT@'
],
Expand Down
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ if get_option('systemd')
endif

subdir('data')
subdir('protocol')
subdir('lib')
subdir('src')
subdir('daemon')
Expand Down
1 change: 1 addition & 0 deletions po/POTFILES
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
src/Dialogs.vala
src/PantheonShell.vala
src/ScreenshotManager.vala
src/WindowManager.vala
daemon/BackgroundMenu.vala
Expand Down
32 changes: 32 additions & 0 deletions protocol/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
dep_scanner = dependency('wayland-scanner', native: true)
prog_scanner = find_program(dep_scanner.get_variable(pkgconfig: 'wayland_scanner'))

protocol_file = files('pantheon-desktop-shell-v1.xml')

pantheon_desktop_shell_sources = []
pantheon_desktop_shell_sources += custom_target(
'pantheon-desktop-shell-server-protocol.h',
command: [ prog_scanner, 'server-header', '@INPUT@', '@OUTPUT@' ],
input: protocol_file,
output: 'pantheon-desktop-shell-server-protocol.h',
)

output_type = 'private-code'
if dep_scanner.version().version_compare('< 1.14.91')
output_type = 'code'
endif
pantheon_desktop_shell_sources += custom_target(
'pantheon-desktop-shell-protocol.c',
command: [ prog_scanner, output_type, '@INPUT@', '@OUTPUT@' ],
input: protocol_file,
output: 'pantheon-desktop-shell-protocol.c',
)

pantheon_desktop_shell_dep = declare_dependency(
dependencies: [
vala.find_library('pantheon-desktop-shell', dirs: meson.current_source_dir()),
dependency('wayland-server'),
],
include_directories: include_directories('.'),
sources: pantheon_desktop_shell_sources
)
76 changes: 76 additions & 0 deletions protocol/pantheon-desktop-shell-v1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?xml version="1.0" encoding="UTF-8"?>
<protocol name="pantheon_shell_v1">
<copyright><![CDATA[
SPDX-FileCopyrightText: 2023 Corentin Noël <tintou@noel.tf>
SPDX-License-Identifier: LGPL-2.1-or-later
]]></copyright>

<interface name="io_elementary_pantheon_shell_v1" version="1">
<description summary="create panel, widget and get more control">
This interface is used by the Pantheon Wayland shell to communicate with
the compositor.
</description>

<request name="get_panel">
<description summary="create a panel surface from a surface">
Create a panel surface from an existing surface.
</description>
<arg name="output" type="new_id" interface="io_elementary_pantheon_panel_v1"/>
<arg name="surface" type="object" interface="wl_surface"/>
</request>

<request name="get_widget">
<description summary="create a widget surface from a surface">
Create a desktop widget surface from an existing surface.
</description>
<arg name="output" type="new_id" interface="io_elementary_pantheon_widget_v1"/>
<arg name="surface" type="object" interface="wl_surface"/>
</request>

<request name="get_extended_behavior">
<description summary="create a desktop-specific surface from a surface">
Create a desktop-specific surface from an existing surface.
</description>
<arg name="output" type="new_id" interface="io_elementary_pantheon_extended_behavior_v1"/>
<arg name="surface" type="object" interface="wl_surface"/>
</request>
</interface>

<interface name="io_elementary_pantheon_panel_v1" version="1">
<request name="destroy" type="destructor"/>

<enum name="anchor">
<description summary="anchor">
The anchor is a placement hint to the compositor.
</description>
<entry name="top" value="0" summary="the top edge of the screen"/>
<entry name="bottom" value="1" summary="the bottom edge of the screen"/>
<entry name="left" value="2" summary="the left edge of the screen"/>
<entry name="right" value="3" summary="the right edge of the screen"/>
</enum>

<request name="set_anchor">
<description summary="set panel edge anchor">
Tell the shell which side of the screen the panel is
located. This is so that new windows do not overlap the panel
and maximized windows maximize properly.
</description>

<arg name="anchor" type="uint" enum="anchor" summary="anchor"/>
</request>
</interface>

<interface name="io_elementary_pantheon_widget_v1" version="1">
<request name="destroy" type="destructor"/>
</interface>

<interface name="io_elementary_pantheon_extended_behavior_v1" version="1">
<request name="destroy" type="destructor"/>
<request name="set_keep_above">
<description summary="set keep above">
Tell the shell to keep the surface above on all workspaces
</description>
</request>
</interface>
</protocol>
1 change: 1 addition & 0 deletions protocol/pantheon-desktop-shell.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
wayland-server
60 changes: 60 additions & 0 deletions protocol/pantheon-desktop-shell.vapi
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright 2023 elementary, Inc. <https://elementary.io>
* Copyright 2023 Corentin Noël <tintou@noel.tf>
* SPDX-License-Identifier: GPL-3.0-or-later
*/

namespace Pantheon.Desktop {
[CCode (cheader_filename = "pantheon-desktop-shell-server-protocol.h", cname = "struct io_elementary_pantheon_shell_v1_interface")]
public struct ShellInterface {
[CCode (cheader_filename = "pantheon-desktop-shell-server-protocol.h", cname = "io_elementary_pantheon_shell_v1_interface")]
public static Wl.Interface iface;
public Pantheon.Desktop.GetPanel get_panel;
public Pantheon.Desktop.GetWidget get_widget;
public Pantheon.Desktop.GetExtendedBehavior get_extended_behavior;

}
[CCode (cheader_filename = "pantheon-desktop-shell-server-protocol.h", cname = "enum io_elementary_pantheon_panel_v1_anchor", cprefix="IO_ELEMENTARY_PANTHEON_PANEL_V1_ANCHOR_", has_type_id = false)]
public enum Anchor {
TOP,
BOTTOM,
LEFT,
RIGHT,
}

[CCode (cheader_filename = "pantheon-desktop-shell-server-protocol.h", cname = "struct io_elementary_pantheon_panel_v1_interface")]
public struct PanelInterface {
[CCode (cheader_filename = "pantheon-desktop-shell-server-protocol.h", cname = "io_elementary_pantheon_panel_v1_interface")]
public static Wl.Interface iface;
public Destroy destroy;
public SetAnchor set_anchor;
}

[CCode (cheader_filename = "pantheon-desktop-shell-server-protocol.h", cname = "struct io_elementary_pantheon_widget_v1_interface")]
public struct WidgetInterface {
[CCode (cheader_filename = "pantheon-desktop-shell-server-protocol.h", cname = "io_elementary_pantheon_widget_v1_interface")]
public static Wl.Interface iface;
public Destroy destroy;
}

[CCode (cheader_filename = "pantheon-desktop-shell-server-protocol.h", cname = "struct io_elementary_pantheon_extended_behavior_v1_interface")]
public struct ExtendedBehaviorInterface {
[CCode (cheader_filename = "pantheon-desktop-shell-server-protocol.h", cname = "io_elementary_pantheon_extended_behavior_v1_interface")]
public static Wl.Interface iface;
public Destroy destroy;
public SetKeepAbove set_keep_above;
}

[CCode (has_target = false, has_typedef = false)]
public delegate void GetPanel (Wl.Client client, Wl.Resource resource, uint32 output, Wl.Resource surface);
[CCode (has_target = false, has_typedef = false)]
public delegate void GetWidget (Wl.Client client, Wl.Resource resource, uint32 output, Wl.Resource surface);
[CCode (has_target = false, has_typedef = false)]
public delegate void GetExtendedBehavior (Wl.Client client, Wl.Resource resource, uint32 output, Wl.Resource surface);
[CCode (has_target = false, has_typedef = false)]
public delegate void SetAnchor (Wl.Client client, Wl.Resource resource, [CCode (type = "uint32_t")] Anchor anchor);
[CCode (has_target = false, has_typedef = false)]
public delegate void SetKeepAbove (Wl.Client client, Wl.Resource resource);
[CCode (has_target = false, has_typedef = false)]
public delegate void Destroy (Wl.Client client, Wl.Resource resource);
}
3 changes: 3 additions & 0 deletions src/Main.vala
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ namespace Gala {

try {
ctx.start ();
if (ctx.get_compositor_type () == Meta.CompositorType.WAYLAND) {
Gala.init_pantheon_shell (ctx);
}
} catch (Error e) {
stderr.printf ("Failed to start: %s\n", e.message);
return Posix.EXIT_FAILURE;
Expand Down
Loading

0 comments on commit 2175085

Please sign in to comment.