Skip to content

Commit

Permalink
Update to build against wlroots 0.17.x
Browse files Browse the repository at this point in the history
  • Loading branch information
soreau committed Nov 18, 2023
1 parent c70479f commit 4b7668b
Show file tree
Hide file tree
Showing 41 changed files with 478 additions and 248 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
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
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::input_inhibit_changed_signal> inhibit_changed =
[=] (wf::input_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 @@ -340,7 +340,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
5 changes: 3 additions & 2 deletions src/api/wayfire/nonstd/wlroots-full.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ extern "C"
#define static
#include <wlr/types/wlr_compositor.h>
#include <wlr/render/wlr_renderer.h>
#include <wlr/render/swapchain.h>
#include <wlr/render/allocator.h>
#include <wlr/render/gles2.h>
#include <wlr/render/egl.h>
Expand All @@ -32,7 +33,7 @@ extern "C"
#include <wlr/types/wlr_buffer.h>
#include <wlr/types/wlr_viewporter.h>

#include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_damage_ring.h>
#include <wlr/types/wlr_presentation_time.h>
#include <wlr/util/region.h>
#include <wlr/types/wlr_screencopy_v1.h>
Expand Down Expand Up @@ -117,14 +118,14 @@ extern "C"
#include <wlr/types/wlr_switch.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/types/wlr_pointer_gestures_v1.h>
#include <wlr/types/wlr_idle.h>
#include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/types/wlr_touch.h>
#include <wlr/types/wlr_pointer_gestures_v1.h>
#include <wlr/xcursor.h>
#include <wlr/types/wlr_data_control_v1.h>
#include <wlr/types/wlr_virtual_keyboard_v1.h>
#include <wlr/types/wlr_virtual_pointer_v1.h>
#include <wlr/types/wlr_idle_notify_v1.h>
#include <wlr/types/wlr_idle_inhibit_v1.h>
#include <wlr/types/wlr_input_inhibitor.h>
#define delete delete_
Expand Down
9 changes: 6 additions & 3 deletions src/api/wayfire/nonstd/wlroots.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ extern "C"
struct wlr_xdg_output_manager_v1;
struct wlr_export_dmabuf_manager_v1;
struct wlr_server_decoration_manager;
struct wlr_xdg_decoration_manager_v1;
struct wlr_input_inhibit_manager;
struct wlr_idle_inhibit_manager_v1;
struct wlr_xdg_decoration_manager_v1;
struct wlr_virtual_keyboard_manager_v1;
struct wlr_virtual_pointer_manager_v1;
struct wlr_idle;
struct wlr_idle_inhibit_manager_v1;
struct wlr_idle_notifier_v1;
struct wlr_screencopy_manager_v1;
struct wlr_foreign_toplevel_manager_v1;
struct wlr_pointer_gestures_v1;
Expand All @@ -53,7 +53,10 @@ extern "C"
#include <wlr/types/wlr_pointer.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_touch.h>
#define static
#include <wlr/types/wlr_output.h>
#undef static
#include <wlr/backend/session.h>
#include <wlr/util/box.h>
#include <wlr/util/edges.h>
#include <wayland-server.h>
Expand Down
Loading

0 comments on commit 4b7668b

Please sign in to comment.