Skip to content

Commit

Permalink
Update to build against wlroots 0.17.x (#2024)
Browse files Browse the repository at this point in the history
* Update to build against wlroots 0.17.x

* core: use existing idle-inhibit framework

* render-manager: refactor new painting algorithm

* cube: damage in the proper place and time

* api: bump API/ABI version

To reflect new wlroots release.

* xdg-toplevel: adapt for wlroots !4409

* render-manager: adapt for wlroots !4067

* use wlr_output_state_init (wlroots !4227)

* xcursor: do not load themes manually

wlroots does this for us

* output-layout: remove unnecessary loop to find output

* output-layout: reenable disabling wayland outputs

wlroots 0.17 has a bug, but it is supposed to work.

* a few more smaller fixes to render-manager

* render-manager: rename output-damage to swapchain-damage-manager

* render-manager: add handling for gamma (wlroots !4046)

* Mention new wlroots dependencies in the README

* s/input_inhibit_changed_signal/idle_inhibit_changed_signal/

* keyboard: Drop session null check

---------

Co-authored-by: Ilia Bozhinov <ammen99@gmail.com>
  • Loading branch information
soreau and ammen99 authored Nov 25, 2023
1 parent 1cc998e commit c48194e
Show file tree
Hide file tree
Showing 44 changed files with 592 additions and 351 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
container: alpine:edge
steps:
- run: apk --no-cache add git gcc g++ binutils pkgconf meson ninja musl-dev wayland-dev wayland-protocols libinput-dev libevdev-dev libxkbcommon-dev pixman-dev glm-dev libdrm-dev mesa-dev cairo-dev pango-dev eudev-dev libxml2-dev libseat-dev libxcb-dev xcb-util-wm-dev xwayland doctest doctest-dev cmake hwdata
- run: apk --no-cache add git gcc g++ binutils pkgconf meson ninja musl-dev wayland-dev wayland-protocols libinput-dev libevdev-dev libxkbcommon-dev pixman-dev glm-dev libdrm-dev mesa-dev cairo-dev pango-dev eudev-dev libxml2-dev libseat-dev libxcb-dev xcb-util-wm-dev xwayland doctest doctest-dev cmake libdisplay-info-dev hwdata-dev
- uses: actions/checkout@v1
- run: git config --global --add safe.directory /__w/wayfire/wayfire
- run: git submodule sync --recursive && git submodule update --init --force --recursive
Expand All @@ -23,7 +23,7 @@ jobs:
steps:
- run: sed -i 's/SigLevel = Required DatabaseOptional/SigLevel = Optional TrustAll/' /etc/pacman.conf
- run: pacman --noconfirm --noprogressbar -Syyu
- run: pacman --noconfirm --noprogressbar -Sy git clang lld libc++ pkgconf meson ninja wayland wayland-protocols libinput libxkbcommon pixman glm libdrm libglvnd cairo pango systemd scdoc base-devel seatd
- run: pacman --noconfirm --noprogressbar -Sy git clang lld libc++ pkgconf meson ninja wayland wayland-protocols libinput libxkbcommon pixman glm libdrm libglvnd cairo pango systemd scdoc base-devel seatd hwdata libdisplay-info

# Build Wayfire
- uses: actions/checkout@v1
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ These are the dependencies needed for building Wayfire.
These are the dependencies needed for building wlroots, and should be installed before building it.
They are relevant for cases when the system doesn't have a version of wlroots installed.

#### DRM Backend (optional, but you most likely want this)

- [libdisplay-info-dev](https://gitlab.freedesktop.org/emersion/libdisplay-info)
- [hwdata-dev](https://github.com/vcrhonek/hwdata)

#### Session Provider (optional, recommended)

- [systemd](https://systemd.io/) **or**
Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ if get_option('use_system_wlroots').disabled()

elif get_option('use_system_wlroots').enabled()
use_system_wlroots = true
wlroots = dependency('wlroots', version: ['>=0.16.0', '<0.17.0'], required: true)
wlroots = dependency('wlroots', version: ['>=0.17.0', '<0.18.0'], required: true)

elif get_option('use_system_wlroots').auto()
message( 'SEARCHING FOR WLROOTS' )
wlroots = dependency('wlroots', version: ['>=0.16.0', '<0.17.0'], required: false)
wlroots = dependency('wlroots', version: ['>=0.17.0', '<0.18.0'], required: false)
use_system_wlroots = true
if not wlroots.found()
use_system_wlroots = false
Expand Down
2 changes: 1 addition & 1 deletion plugins/cube/cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class wayfire_cube : public wf::per_output_plugin_instance_t, public wf::pointer
}

self->cube->render(target.translated(-wf::origin(self->get_bounding_box())), framebuffers);
wf::scene::damage_node(self, self->get_bounding_box());
}

void compute_visibility(wf::output_t *output, wf::region_t& visible) override
Expand Down Expand Up @@ -664,6 +663,7 @@ class wayfire_cube : public wf::per_output_plugin_instance_t, public wf::pointer
wf::effect_hook_t pre_hook = [=] ()
{
update_view_matrix();
wf::scene::damage_node(render_node, render_node->get_bounding_box());
if (animation.cube_animation.running())
{
output->render->schedule_redraw();
Expand Down
6 changes: 5 additions & 1 deletion plugins/decor/deco-layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,11 @@ wf::region_t decoration_layout_t::calculate_region() const
wf::region_t r{};
for (auto& area : layout_areas)
{
r |= area->get_geometry();
auto g = area->get_geometry();
if ((g.width > 0) && (g.height > 0))
{
r |= g;
}
}

return r;
Expand Down
4 changes: 2 additions & 2 deletions plugins/protocols/foreign-toplevel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ class wayfire_foreign_toplevel
} else if (app_id_mode == "full")
{
#if WF_HAS_XWAYLAND
if (view->get_wlr_surface() && wlr_surface_is_xwayland_surface(view->get_wlr_surface()))
if (wlr_xwayland_surface *xw_surface =
wlr_xwayland_surface_try_from_wlr_surface(view->get_wlr_surface()))
{
auto xw_surface = wlr_xwayland_surface_from_wlr_surface(view->get_wlr_surface());
ev.app_id = nonull(xw_surface->instance);
}

Expand Down
3 changes: 1 addition & 2 deletions plugins/protocols/gtk-shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,8 @@ static void handle_gtk_shell_get_gtk_surface(wl_client *client, wl_resource *res
gtk_surface, handle_gtk_surface_destroy);

wlr_surface *wlr_surface = wlr_surface_from_resource(surface);
if (wlr_surface_is_xdg_surface(wlr_surface))
if (wlr_xdg_surface *xdg_surface = wlr_xdg_surface_try_from_wlr_surface(wlr_surface))
{
wlr_xdg_surface *xdg_surface = wlr_xdg_surface_from_wlr_surface(wlr_surface);
gtk_surface->on_configure.set_callback([=] (void*)
{
handle_xdg_surface_on_configure(gtk_surface);
Expand Down
138 changes: 71 additions & 67 deletions plugins/single_plugins/idle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "wayfire/output-layout.hpp"
#include "wayfire/workspace-set.hpp"
#include "wayfire/signal-definitions.hpp"
#include "wayfire/seat.hpp"
#include "../cube/cube-control-signal.hpp"

#include <cmath>
Expand Down Expand Up @@ -36,60 +37,56 @@ class screensaver_animation_t : public duration_t
class wayfire_idle
{
wf::option_wrapper_t<int> dpms_timeout{"idle/dpms_timeout"};
wf::wl_listener_wrapper on_idle_dpms, on_resume_dpms;
wlr_idle_timeout *timeout_dpms = NULL;
bool is_idle = false;

public:
wf::signal::connection_t<wf::seat_activity_signal> on_seat_activity;
std::optional<wf::idle_inhibitor_t> hotkey_inhibitor;
wf::wl_timer<false> timeout_dpms;

wayfire_idle()
{
dpms_timeout.set_callback([=] ()
{
create_dpms_timeout(dpms_timeout);
create_dpms_timeout();
});
create_dpms_timeout(dpms_timeout);
}

void destroy_dpms_timeout()
{
if (timeout_dpms)
on_seat_activity = [=] (void*)
{
on_idle_dpms.disconnect();
on_resume_dpms.disconnect();
wlr_idle_timeout_destroy(timeout_dpms);
}

timeout_dpms = NULL;
create_dpms_timeout();
};
create_dpms_timeout();
wf::get_core().connect(&on_seat_activity);
}

void create_dpms_timeout(int timeout_sec)
void create_dpms_timeout()
{
destroy_dpms_timeout();
if (timeout_sec <= 0)
if (dpms_timeout <= 0)
{
timeout_dpms.disconnect();
return;
}

timeout_dpms = wlr_idle_timeout_create(wf::get_core().protocols.idle,
wf::get_core().get_current_seat(), 1000 * timeout_sec);

on_idle_dpms.set_callback([&] (void*)
if (!timeout_dpms.is_connected() && is_idle)
{
set_state(wf::OUTPUT_IMAGE_SOURCE_SELF, wf::OUTPUT_IMAGE_SOURCE_DPMS);
});
on_idle_dpms.connect(&timeout_dpms->events.idle);
is_idle = false;
set_state(wf::OUTPUT_IMAGE_SOURCE_DPMS, wf::OUTPUT_IMAGE_SOURCE_SELF);

return;
}

on_resume_dpms.set_callback([&] (void*)
timeout_dpms.disconnect();
timeout_dpms.set_timeout(1000 * dpms_timeout, [=] ()
{
set_state(wf::OUTPUT_IMAGE_SOURCE_DPMS, wf::OUTPUT_IMAGE_SOURCE_SELF);
is_idle = true;
set_state(wf::OUTPUT_IMAGE_SOURCE_SELF, wf::OUTPUT_IMAGE_SOURCE_DPMS);
});
on_resume_dpms.connect(&timeout_dpms->events.resume);
}

~wayfire_idle()
{
destroy_dpms_timeout();
timeout_dpms.disconnect();
wf::get_core().disconnect(&on_seat_activity);
}

/* Change all outputs with state from to state to */
Expand Down Expand Up @@ -128,17 +125,12 @@ class wayfire_idle_plugin : public wf::per_output_plugin_instance_t
bool hook_set = false;
bool output_inhibited = false;
uint32_t last_time;
wlr_idle_timeout *timeout_screensaver = NULL;
wf::wl_listener_wrapper on_idle_screensaver, on_resume_screensaver;
wf::wl_timer<false> timeout_screensaver;
wf::signal::connection_t<wf::seat_activity_signal> on_seat_activity;
wf::shared_data::ref_ptr_t<wayfire_idle> global_idle;

wf::activator_callback toggle = [=] (auto)
{
if (!output->can_activate_plugin(&grab_interface))
{
return false;
}

if (global_idle->hotkey_inhibitor.has_value())
{
global_idle->hotkey_inhibitor.reset();
Expand All @@ -157,6 +149,29 @@ class wayfire_idle_plugin : public wf::per_output_plugin_instance_t
update_fullscreen();
};

wf::signal::connection_t<wf::idle_inhibit_changed_signal> inhibit_changed =
[=] (wf::idle_inhibit_changed_signal *ev)
{
if (!ev)
{
return;
}

if (ev->inhibit)
{
wf::get_core().disconnect(&global_idle->on_seat_activity);
wf::get_core().disconnect(&on_seat_activity);
global_idle->timeout_dpms.disconnect();
timeout_screensaver.disconnect();
} else
{
wf::get_core().connect(&global_idle->on_seat_activity);
wf::get_core().connect(&on_seat_activity);
global_idle->create_dpms_timeout();
create_screensaver_timeout();
}
};

wf::config::option_base_t::updated_callback_t disable_on_fullscreen_changed =
[=] ()
{
Expand Down Expand Up @@ -207,49 +222,37 @@ class wayfire_idle_plugin : public wf::per_output_plugin_instance_t

screensaver_timeout.set_callback([=] ()
{
create_screensaver_timeout(screensaver_timeout);
create_screensaver_timeout();
});
create_screensaver_timeout(screensaver_timeout);
}
create_screensaver_timeout();

void destroy_screensaver_timeout()
{
if (state == CUBE_SCREENSAVER_RUNNING)
on_seat_activity = [=] (void*)
{
stop_screensaver();
}

if (timeout_screensaver)
{
on_idle_screensaver.disconnect();
on_resume_screensaver.disconnect();
wlr_idle_timeout_destroy(timeout_screensaver);
}

timeout_screensaver = NULL;
create_screensaver_timeout();
};
wf::get_core().connect(&on_seat_activity);
wf::get_core().connect(&inhibit_changed);
}

void create_screensaver_timeout(int timeout_sec)
void create_screensaver_timeout()
{
destroy_screensaver_timeout();
if (timeout_sec <= 0)
if (screensaver_timeout <= 0)
{
timeout_screensaver.disconnect();
return;
}

timeout_screensaver = wlr_idle_timeout_create(wf::get_core().protocols.idle,
wf::get_core().get_current_seat(), 1000 * timeout_sec);
on_idle_screensaver.set_callback([&] (void*)
if (!timeout_screensaver.is_connected() && (state == CUBE_SCREENSAVER_RUNNING))
{
start_screensaver();
});
on_idle_screensaver.connect(&timeout_screensaver->events.idle);
stop_screensaver();
return;
}

on_resume_screensaver.set_callback([&] (void*)
timeout_screensaver.disconnect();
timeout_screensaver.set_timeout(1000 * screensaver_timeout, [=] ()
{
stop_screensaver();
start_screensaver();
});
on_resume_screensaver.connect(&timeout_screensaver->events.resume);
}

void inhibit_output()
Expand Down Expand Up @@ -351,8 +354,7 @@ class wayfire_idle_plugin : public wf::per_output_plugin_instance_t

if (state == CUBE_SCREENSAVER_STOPPING)
{
wlr_idle_notify_activity(wf::get_core().protocols.idle,
wf::get_core().get_current_seat());
wf::get_core().seat->notify_activity();
}
};

Expand Down Expand Up @@ -410,7 +412,9 @@ class wayfire_idle_plugin : public wf::per_output_plugin_instance_t

void fini() override
{
destroy_screensaver_timeout();
wf::get_core().disconnect(&on_seat_activity);
wf::get_core().disconnect(&inhibit_changed);
timeout_screensaver.disconnect();
output->rem_binding(&toggle);
}
};
Expand Down
2 changes: 1 addition & 1 deletion plugins/single_plugins/ipc-rules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class ipc_rules_t : public wf::plugin_interface_t, public wf::per_output_tracker
{
#if WF_HAS_XWAYLAND
auto surf = view->get_wlr_surface();
if (surf && wlr_surface_is_xwayland_surface(surf))
if (surf && wlr_xwayland_surface_try_from_wlr_surface(surf))
{
return "x-or";
}
Expand Down
1 change: 0 additions & 1 deletion proto/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ wayland_scanner_client = generator(

server_protocols = [
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
[wl_protocol_dir, 'unstable/idle-inhibit/idle-inhibit-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'],
[wl_protocol_dir, 'unstable/xdg-output/xdg-output-unstable-v1.xml'],
Expand Down
3 changes: 2 additions & 1 deletion src/api/wayfire/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class compositor_core_t : public wf::object_base_t, public signal::provider_t
* used instead of this one
*/
wlr_backend *backend;
wlr_session *session;
wlr_renderer *renderer;
wlr_allocator *allocator;

Expand All @@ -127,7 +128,7 @@ class compositor_core_t : public wf::object_base_t, public signal::provider_t
wlr_virtual_keyboard_manager_v1 *vkbd_manager;
wlr_virtual_pointer_manager_v1 *vptr_manager;
wlr_input_inhibit_manager *input_inhibit;
wlr_idle *idle;
wlr_idle_notifier_v1 *idle_notifier;
wlr_idle_inhibit_manager_v1 *idle_inhibit;
wlr_pointer_gestures_v1 *pointer_gestures;
wlr_relative_pointer_manager_v1 *relative_pointer;
Expand Down
2 changes: 1 addition & 1 deletion src/api/wayfire/idle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ class idle_inhibitor_t

private:
static unsigned int inhibitors;
void notify_wlroots();
void notify_update();
};
}
Loading

0 comments on commit c48194e

Please sign in to comment.