Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wayland server side decorations #3425

Merged
merged 23 commits into from
Jul 2, 2024
Merged
Changes from 3 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e80daf5
Add xdg-decoration-unstable-v1 and modify CMakeLists.txt to generate …
tarek-y-ismail Jun 14, 2024
feca272
Add first prototype of xdg-decoration-unstable-v1.
tarek-y-ismail Jun 14, 2024
cc04d24
Apply formatting
tarek-y-ismail Jun 14, 2024
5b8027c
Add missing configure event call.
tarek-y-ismail Jun 14, 2024
68aad57
Apply formatting.
tarek-y-ismail Jun 14, 2024
59c8c08
Remove `mir::wayland` alias in header.
tarek-y-ismail Jun 14, 2024
826096a
Add missing copyright notice to xdg_decoration_unstable_v1.cpp
tarek-y-ismail Jun 14, 2024
7e75976
Strip logs from xdg_decoration_unstable_v1.cpp
tarek-y-ismail Jun 14, 2024
ba4db7c
Add basic error handling for xdg decoration
tarek-y-ismail Jun 24, 2024
9d89052
Apply formatting to xdg_decoration_unstable_v1.cpp
Jun 24, 2024
b8f0b2c
Convert the wayland error check to a sanity check in
Jun 24, 2024
0741868
Add listeners for decoration and toplevel destruction
tarek-y-ismail Jun 26, 2024
2a42cf4
Log instead of throwing `orphaned` when toplevels are destroyed.
Jun 28, 2024
f52391e
Add `destroy_toplevel_before_decoration` to expected failure list.
Jun 28, 2024
6632601
Wrap `toplevels_with_decorations` in a class.
Jul 1, 2024
f240d13
Fix comment typo in `mir::frontend::ToplevelsWithDecorations::unregis…
Jul 1, 2024
27d1207
Make comment in `acceptance-tests/wayland/CMakeLists.txt` clearer.
Jul 1, 2024
e0ca81e
Fix lifetime issues related to `toplevels_with_decorations`.
Jul 1, 2024
2012b20
Fix naming convention of `{register,unregister}Toplevel`.
Jul 1, 2024
6faabb4
Remove redundant `ToplevelsWithDecorations` construction code and dis…
tarek-y-ismail Jul 1, 2024
e69e676
Always unregister toplevel on destruction.
Jul 1, 2024
1af2a26
Improve semantics of `unregister_toplevel` and explain decoration
tarek-y-ismail Jul 2, 2024
faa1e16
Rename `destroy_toplevel_before_decoration` to `destroy_toplevel_befo…
tarek-y-ismail Jul 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 29 additions & 18 deletions src/server/frontend_wayland/xdg_decoration_unstable_v1.cpp
AlanGriffiths marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@
#include "xdg_decoration_unstable_v1.h"

#include "mir/shell/surface_specification.h"
#include "mir/wayland/protocol_error.h"

#include "xdg-decoration-unstable-v1_wrapper.h"
#include "xdg_output_v1.h"
#include "xdg_shell_stable.h"

#include <unordered_set>

namespace mir
{
namespace frontend
Expand All @@ -42,6 +45,7 @@ class XdgDecorationManagerV1 : public wayland::XdgDecorationManagerV1

private:
void get_toplevel_decoration(wl_resource* id, wl_resource* toplevel) override;
std::unordered_set<wl_resource*> toplevels_with_decorations;
};

class XdgToplevelDecorationV1 : public wayland::XdgToplevelDecorationV1
Expand All @@ -55,7 +59,7 @@ class XdgToplevelDecorationV1 : public wayland::XdgToplevelDecorationV1
private:
void update_mode(uint32_t new_mode);

static const uint32_t default_mode = Mode::client_side;
static uint32_t const default_mode = Mode::client_side;

mir::frontend::XdgToplevelStable* toplevel;
uint32_t mode;
Expand All @@ -69,8 +73,8 @@ auto mir::frontend::create_xdg_decoration_unstable_v1(wl_display* display)
return std::make_shared<XdgDecorationManagerV1::Global>(display);
}

mir::frontend::XdgDecorationManagerV1::Global::Global(wl_display* display)
: wayland::XdgDecorationManagerV1::Global::Global{display, Version<1>{}}
mir::frontend::XdgDecorationManagerV1::Global::Global(wl_display* display) :
wayland::XdgDecorationManagerV1::Global::Global{display, Version<1>{}}
{
}

Expand All @@ -79,23 +83,36 @@ void mir::frontend::XdgDecorationManagerV1::Global::bind(wl_resource* new_zxdg_d
new XdgDecorationManagerV1{new_zxdg_decoration_manager_v1};
}

mir::frontend::XdgDecorationManagerV1::XdgDecorationManagerV1(wl_resource* resource)
: mir::wayland::XdgDecorationManagerV1{resource, Version<1>{}}
mir::frontend::XdgDecorationManagerV1::XdgDecorationManagerV1(wl_resource* resource) :
mir::wayland::XdgDecorationManagerV1{resource, Version<1>{}}
{
}

void mir::frontend::XdgDecorationManagerV1::get_toplevel_decoration(wl_resource* id, wl_resource* toplevel)
{
using Error = mir::frontend::XdgToplevelDecorationV1::Error;

if (toplevels_with_decorations.contains(toplevel))
{
BOOST_THROW_EXCEPTION(mir::wayland::ProtocolError(
resource, Error::already_constructed, "Decoration already constructed for this toplevel"));
}

auto* tl = mir::frontend::XdgToplevelStable::from(toplevel);
if (tl)
if (!tl)
{
new XdgToplevelDecorationV1{id, tl};
BOOST_THROW_EXCEPTION(std::runtime_error("Invalid toplevel pointer"));
}


new XdgToplevelDecorationV1{id, tl};
toplevels_with_decorations.insert(toplevel);
AlanGriffiths marked this conversation as resolved.
Show resolved Hide resolved
}

mir::frontend::XdgToplevelDecorationV1::XdgToplevelDecorationV1(wl_resource* id,
mir::frontend::XdgToplevelStable* toplevel)
: wayland::XdgToplevelDecorationV1{id, Version<1>{}}, toplevel{toplevel}
mir::frontend::XdgToplevelDecorationV1::XdgToplevelDecorationV1(
wl_resource* id, mir::frontend::XdgToplevelStable* toplevel) :
wayland::XdgToplevelDecorationV1{id, Version<1>{}},
toplevel{toplevel}
{
}

Expand All @@ -118,12 +135,6 @@ void mir::frontend::XdgToplevelDecorationV1::update_mode(uint32_t new_mode)
send_configure_event(mode);
}

void mir::frontend::XdgToplevelDecorationV1::set_mode(uint32_t mode)
{
update_mode(mode);
}
void mir::frontend::XdgToplevelDecorationV1::set_mode(uint32_t mode) { update_mode(mode); }
tarek-y-ismail marked this conversation as resolved.
Show resolved Hide resolved

void mir::frontend::XdgToplevelDecorationV1::unset_mode()
{
update_mode(default_mode);
}
void mir::frontend::XdgToplevelDecorationV1::unset_mode() { update_mode(default_mode); }
Loading