aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2017-12-09 14:06:00 -0500
committerLibravatar Tony Crisci <tony@dubstepdish.com>2017-12-09 14:06:00 -0500
commit9333a7eb5329073aecfaf776c8ee0572c7dff67c (patch)
tree1438a16a31d2df9ec035e856fd4c89abe6c34e38 /sway
parentsway xcursor manager (diff)
downloadsway-9333a7eb5329073aecfaf776c8ee0572c7dff67c.tar.gz
sway-9333a7eb5329073aecfaf776c8ee0572c7dff67c.tar.zst
sway-9333a7eb5329073aecfaf776c8ee0572c7dff67c.zip
working xcursor
Diffstat (limited to 'sway')
-rw-r--r--sway/desktop/output.c7
-rw-r--r--sway/input/cursor.c8
-rw-r--r--sway/input/seat.c18
-rw-r--r--sway/main.c3
4 files changed, 24 insertions, 12 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index 7eb48bdf..d2003834 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -12,6 +12,8 @@
12#include "sway/output.h" 12#include "sway/output.h"
13#include "sway/server.h" 13#include "sway/server.h"
14#include "sway/view.h" 14#include "sway/view.h"
15#include "sway/input/input-manager.h"
16#include "sway/input/seat.h"
15 17
16static void output_frame_view(swayc_t *view, void *data) { 18static void output_frame_view(swayc_t *view, void *data) {
17 struct sway_output *output = data; 19 struct sway_output *output = data;
@@ -120,6 +122,11 @@ void output_add_notify(struct wl_listener *listener, void *data) {
120 output->resolution.notify = output_resolution_notify; 122 output->resolution.notify = output_resolution_notify;
121 wl_signal_add(&wlr_output->events.resolution, &output->resolution); 123 wl_signal_add(&wlr_output->events.resolution, &output->resolution);
122 124
125 for (int i = 0; i < server->input->seats->length; ++i) {
126 struct sway_seat *seat = server->input->seats->items[i];
127 sway_seat_configure_xcursor(seat);
128 }
129
123 arrange_windows(output->swayc, -1, -1); 130 arrange_windows(output->swayc, -1, -1);
124} 131}
125 132
diff --git a/sway/input/cursor.c b/sway/input/cursor.c
index 85b7865d..4f0344be 100644
--- a/sway/input/cursor.c
+++ b/sway/input/cursor.c
@@ -1,5 +1,6 @@
1#define _XOPEN_SOURCE 700 1#define _XOPEN_SOURCE 700
2#include <wlr/types/wlr_cursor.h> 2#include <wlr/types/wlr_cursor.h>
3#include <wlr/types/wlr_xcursor_manager.h>
3#include "sway/input/cursor.h" 4#include "sway/input/cursor.h"
4#include "log.h" 5#include "log.h"
5 6
@@ -7,7 +8,10 @@ static void handle_cursor_motion(struct wl_listener *listener, void *data) {
7 struct sway_cursor *cursor = 8 struct sway_cursor *cursor =
8 wl_container_of(listener, cursor, motion); 9 wl_container_of(listener, cursor, motion);
9 struct wlr_event_pointer_motion *event = data; 10 struct wlr_event_pointer_motion *event = data;
10 sway_log(L_DEBUG, "TODO: handle event: %p", event); 11 sway_log(L_DEBUG, "TODO: handle cursor motion event: dx=%f, dy=%f", event->delta_x, event->delta_y);
12 wlr_cursor_move(cursor->cursor, event->device, event->delta_x, event->delta_y);
13 sway_log(L_DEBUG, "TODO: new x=%f, y=%f", cursor->cursor->x, cursor->cursor->y);
14 wlr_xcursor_manager_set_cursor_image(cursor->xcursor_manager, "left_ptr", cursor->cursor);
11} 15}
12 16
13static void handle_cursor_motion_absolute(struct wl_listener *listener, 17static void handle_cursor_motion_absolute(struct wl_listener *listener,
@@ -87,6 +91,8 @@ struct sway_cursor *sway_cursor_create(struct sway_seat *seat) {
87 return NULL; 91 return NULL;
88 } 92 }
89 93
94 wlr_cursor_attach_output_layout(wlr_cursor, root_container.output_layout);
95
90 // input events 96 // input events
91 wl_signal_add(&wlr_cursor->events.motion, &cursor->motion); 97 wl_signal_add(&wlr_cursor->events.motion, &cursor->motion);
92 cursor->motion.notify = handle_cursor_motion; 98 cursor->motion.notify = handle_cursor_motion;
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 1fd65980..5aed1f68 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -83,15 +83,13 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) {
83 // TODO configure theme and size 83 // TODO configure theme and size
84 const char *cursor_theme = "default"; 84 const char *cursor_theme = "default";
85 85
86 if (seat->cursor->xcursor_manager) { 86 if (!seat->cursor->xcursor_manager) {
87 wlr_xcursor_manager_destroy(seat->cursor->xcursor_manager); 87 seat->cursor->xcursor_manager =
88 } 88 wlr_xcursor_manager_create("default", 24);
89 89 if (sway_assert(seat->cursor->xcursor_manager,
90 seat->cursor->xcursor_manager = 90 "Cannot create XCursor manager for theme %s", cursor_theme)) {
91 wlr_xcursor_manager_create(NULL, 24); 91 return;
92 if (sway_assert(seat->cursor->xcursor_manager, 92 }
93 "Cannot create XCursor manager for theme %s", cursor_theme)) {
94 return;
95 } 93 }
96 94
97 for (int i = 0; i < root_container.children->length; ++i) { 95 for (int i = 0; i < root_container.children->length; ++i) {
@@ -102,7 +100,7 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) {
102 wlr_xcursor_manager_load(seat->cursor->xcursor_manager, 100 wlr_xcursor_manager_load(seat->cursor->xcursor_manager,
103 output->scale); 101 output->scale);
104 102
105 sway_assert(result, 103 sway_assert(!result,
106 "Cannot load xcursor theme for output '%s' with scale %d", 104 "Cannot load xcursor theme for output '%s' with scale %d",
107 output->name, output->scale); 105 output->name, output->scale);
108 } 106 }
diff --git a/sway/main.c b/sway/main.c
index bc843591..363f4d96 100644
--- a/sway/main.c
+++ b/sway/main.c
@@ -381,11 +381,12 @@ int main(int argc, char **argv) {
381 381
382 sway_log(L_INFO, "Starting sway version " SWAY_VERSION "\n"); 382 sway_log(L_INFO, "Starting sway version " SWAY_VERSION "\n");
383 383
384 init_layout();
385
384 if (!server_init(&server)) { 386 if (!server_init(&server)) {
385 return 1; 387 return 1;
386 } 388 }
387 389
388 init_layout();
389 ipc_init(&server); 390 ipc_init(&server);
390 log_env(); 391 log_env();
391 392