Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions proto/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ server_protocols = [
[wl_protocol_dir, 'staging/ext-foreign-toplevel-list/ext-foreign-toplevel-list-v1.xml'],
[wl_protocol_dir, 'staging/ext-image-capture-source/ext-image-capture-source-v1.xml'],
[wl_protocol_dir, 'staging/ext-image-copy-capture/ext-image-copy-capture-v1.xml'],
[wl_protocol_dir, 'staging/cursor-shape/cursor-shape-v1.xml'],
'wayfire-shell-unstable-v2.xml',
'gtk-shell.xml',
'wlr-layer-shell-unstable-v1.xml',
Expand Down
3 changes: 3 additions & 0 deletions src/api/wayfire/nonstd/wlroots-full.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ extern "C"
#include <wlr/types/wlr_single_pixel_buffer_v1.h>
#include <wlr/types/wlr_session_lock_v1.h>
#include <wlr/types/wlr_security_context_v1.h>
#if __has_include(<cursor-shape-v1-protocol.h>)
#include <wlr/types/wlr_cursor_shape_v1.h>
#endif

// Activation plugin
#include <wlr/types/wlr_xdg_activation_v1.h>
Expand Down
1 change: 1 addition & 0 deletions src/api/wayfire/nonstd/wlroots.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ extern "C"
struct wlr_primary_selection_v1_device_manager;
struct wlr_drm_lease_v1_manager;
struct wlr_session_lock_manager_v1;
struct wlr_cursor_shape_manager_v1;

struct wlr_xdg_foreign_v1;
struct wlr_xdg_foreign_v2;
Expand Down
46 changes: 37 additions & 9 deletions src/core/seat/cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ wf::cursor_t::cursor_t(wf::seat_t *seat)
wlr_cursor_map_to_output(cursor, NULL);
wlr_cursor_warp(cursor, NULL, cursor->x, cursor->y);
init_xcursor();
init_cursor_shape_manager();

config_reloaded = [=] (auto)
{
Expand Down Expand Up @@ -128,14 +129,46 @@ void wf::cursor_t::init_xcursor()
set_cursor("default");
}

void wf::cursor_t::set_cursor(std::string name)
bool wf::cursor_t::can_client_set_cursor()
{
if (this->touchscreen_mode_active)
{
return false;
}

if (this->hide_ref_counter)
{
return;
return false;
}

if (this->touchscreen_mode_active)
return true;
}

void wf::cursor_t::init_cursor_shape_manager()
{
cursor_shape_manager = wlr_cursor_shape_manager_v1_create(seat->seat->display, 1);
request_set_cursor_shape.set_callback([&] (void *data)
{
auto event = (wlr_cursor_shape_manager_v1_request_set_shape_event*)data;
const char *shape_name = wlr_cursor_shape_v1_name(event->shape);
struct wlr_seat_client *focused_client = seat->seat->pointer_state.focused_client;

if (focused_client != event->seat_client)
{
return;
}

if (can_client_set_cursor())
{
wlr_cursor_set_xcursor(cursor, xcursor, shape_name);
}
});
request_set_cursor_shape.connect(&cursor_shape_manager->events.request_set_shape);
}

void wf::cursor_t::set_cursor(std::string name)
{
if (!can_client_set_cursor())
{
return;
}
Expand Down Expand Up @@ -189,12 +222,7 @@ wf::pointf_t wf::cursor_t::get_cursor_position()
void wf::cursor_t::set_cursor(
wlr_seat_pointer_request_set_cursor_event *ev, bool validate_request)
{
if (this->hide_ref_counter)
{
return;
}

if (this->touchscreen_mode_active)
if (!can_client_set_cursor())
{
return;
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/seat/cursor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct cursor_t
void set_cursor(wlr_seat_pointer_request_set_cursor_event *ev,
bool validate_request);
void set_cursor(std::string name);
bool can_client_set_cursor();
void unhide_cursor();
void hide_cursor();
int hide_ref_counter = 0;
Expand All @@ -48,6 +49,7 @@ struct cursor_t
wf::pointf_t get_cursor_position();

void init_xcursor();
void init_cursor_shape_manager();
void setup_listeners();

// Device event listeners
Expand All @@ -63,12 +65,14 @@ struct cursor_t

// Seat events
wf::wl_listener_wrapper request_set_cursor;
wf::wl_listener_wrapper request_set_cursor_shape;

wf::signal::connection_t<wf::reload_config_signal> config_reloaded;
wf::seat_t *seat;

wlr_cursor *cursor = NULL;
wlr_xcursor_manager *xcursor = NULL;
wlr_cursor_shape_manager_v1 *cursor_shape_manager = NULL;

std::string last_cursor_name;

Expand Down