mirror of
https://github.com/gwenhael-le-moine/sway-patched-tray-menu.git
synced 2024-12-28 22:23:42 +01:00
working xcursor
This commit is contained in:
parent
7c67bea942
commit
9333a7eb53
4 changed files with 24 additions and 12 deletions
|
@ -12,6 +12,8 @@
|
|||
#include "sway/output.h"
|
||||
#include "sway/server.h"
|
||||
#include "sway/view.h"
|
||||
#include "sway/input/input-manager.h"
|
||||
#include "sway/input/seat.h"
|
||||
|
||||
static void output_frame_view(swayc_t *view, void *data) {
|
||||
struct sway_output *output = data;
|
||||
|
@ -120,6 +122,11 @@ void output_add_notify(struct wl_listener *listener, void *data) {
|
|||
output->resolution.notify = output_resolution_notify;
|
||||
wl_signal_add(&wlr_output->events.resolution, &output->resolution);
|
||||
|
||||
for (int i = 0; i < server->input->seats->length; ++i) {
|
||||
struct sway_seat *seat = server->input->seats->items[i];
|
||||
sway_seat_configure_xcursor(seat);
|
||||
}
|
||||
|
||||
arrange_windows(output->swayc, -1, -1);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#define _XOPEN_SOURCE 700
|
||||
#include <wlr/types/wlr_cursor.h>
|
||||
#include <wlr/types/wlr_xcursor_manager.h>
|
||||
#include "sway/input/cursor.h"
|
||||
#include "log.h"
|
||||
|
||||
|
@ -7,7 +8,10 @@ static void handle_cursor_motion(struct wl_listener *listener, void *data) {
|
|||
struct sway_cursor *cursor =
|
||||
wl_container_of(listener, cursor, motion);
|
||||
struct wlr_event_pointer_motion *event = data;
|
||||
sway_log(L_DEBUG, "TODO: handle event: %p", event);
|
||||
sway_log(L_DEBUG, "TODO: handle cursor motion event: dx=%f, dy=%f", event->delta_x, event->delta_y);
|
||||
wlr_cursor_move(cursor->cursor, event->device, event->delta_x, event->delta_y);
|
||||
sway_log(L_DEBUG, "TODO: new x=%f, y=%f", cursor->cursor->x, cursor->cursor->y);
|
||||
wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, "left_ptr", cursor->cursor);
|
||||
}
|
||||
|
||||
static void handle_cursor_motion_absolute(struct wl_listener *listener,
|
||||
|
@ -87,6 +91,8 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
wlr_cursor_attach_output_layout(wlr_cursor, root_container.output_layout);
|
||||
|
||||
// input events
|
||||
wl_signal_add(&wlr_cursor->events.motion, &cursor->motion);
|
||||
cursor->motion.notify = handle_cursor_motion;
|
||||
|
|
|
@ -83,15 +83,13 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) {
|
|||
// TODO configure theme and size
|
||||
const char *cursor_theme = "default";
|
||||
|
||||
if (seat->cursor->xcursor_manager) {
|
||||
wlr_xcursor_manager_destroy(seat->cursor->xcursor_manager);
|
||||
}
|
||||
|
||||
seat->cursor->xcursor_manager =
|
||||
wlr_xcursor_manager_create(NULL, 24);
|
||||
if (sway_assert(seat->cursor->xcursor_manager,
|
||||
"Cannot create XCursor manager for theme %s", cursor_theme)) {
|
||||
return;
|
||||
if (!seat->cursor->xcursor_manager) {
|
||||
seat->cursor->xcursor_manager =
|
||||
wlr_xcursor_manager_create("default", 24);
|
||||
if (sway_assert(seat->cursor->xcursor_manager,
|
||||
"Cannot create XCursor manager for theme %s", cursor_theme)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < root_container.children->length; ++i) {
|
||||
|
@ -102,7 +100,7 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) {
|
|||
wlr_xcursor_manager_load(seat->cursor->xcursor_manager,
|
||||
output->scale);
|
||||
|
||||
sway_assert(result,
|
||||
sway_assert(!result,
|
||||
"Cannot load xcursor theme for output '%s' with scale %d",
|
||||
output->name, output->scale);
|
||||
}
|
||||
|
|
|
@ -381,11 +381,12 @@ int main(int argc, char **argv) {
|
|||
|
||||
sway_log(L_INFO, "Starting sway version " SWAY_VERSION "\n");
|
||||
|
||||
init_layout();
|
||||
|
||||
if (!server_init(&server)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
init_layout();
|
||||
ipc_init(&server);
|
||||
log_env();
|
||||
|
||||
|
|
Loading…
Reference in a new issue