summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar taiyu <taiyu.len@gmail.com>2015-08-16 00:46:58 -0700
committerLibravatar taiyu <taiyu.len@gmail.com>2015-08-16 00:46:58 -0700
commiteefc76b39e61ce04fa8ac0e732a22c10d9c98e1f (patch)
tree914b01d7f01ea8b90397041dce2437305453aba2
parentreduced code duplication (diff)
downloadsway-eefc76b39e61ce04fa8ac0e732a22c10d9c98e1f.tar.gz
sway-eefc76b39e61ce04fa8ac0e732a22c10d9c98e1f.tar.zst
sway-eefc76b39e61ce04fa8ac0e732a22c10d9c98e1f.zip
set userdata for handler to swayc_t container
-rw-r--r--sway/container.c6
-rw-r--r--sway/handlers.c6
-rw-r--r--sway/stringop.c1
3 files changed, 8 insertions, 5 deletions
diff --git a/sway/container.c b/sway/container.c
index d1c8a7de..ff9c983a 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -54,8 +54,10 @@ swayc_t *new_output(wlc_handle handle) {
54 output->height = size->h; 54 output->height = size->h;
55 output->handle = handle; 55 output->handle = handle;
56 56
57 add_child(&root_container, output); 57 //link this to handler
58 wlc_handle_set_user_data(handle, output);
58 59
60 add_child(&root_container, output);
59 //TODO something with this 61 //TODO something with this
60 int total_width = 0; 62 int total_width = 0;
61 container_map(&root_container, add_output_widths, &total_width); 63 container_map(&root_container, add_output_widths, &total_width);
@@ -138,6 +140,8 @@ swayc_t *new_view(swayc_t *sibling, wlc_handle handle) {
138 view->name = strdup(title); 140 view->name = strdup(title);
139 view->visible = true; 141 view->visible = true;
140 142
143 //Link view to handle
144 wlc_handle_set_user_data(handle, view);
141 //Case of focused workspace, just create as child of it 145 //Case of focused workspace, just create as child of it
142 if (sibling->type == C_WORKSPACE) { 146 if (sibling->type == C_WORKSPACE) {
143 add_child(sibling, view); 147 add_child(sibling, view);
diff --git a/sway/handlers.c b/sway/handlers.c
index 6f4cb477..af1fc98c 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -69,7 +69,7 @@ static void handle_output_destroyed(wlc_handle output) {
69 69
70static void handle_output_resolution_change(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to) { 70static void handle_output_resolution_change(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to) {
71 sway_log(L_DEBUG, "Output %d resolution changed to %d x %d", output, to->w, to->h); 71 sway_log(L_DEBUG, "Output %d resolution changed to %d x %d", output, to->w, to->h);
72 swayc_t *c = get_swayc_for_handle(output, &root_container); 72 swayc_t *c = wlc_handle_get_user_data(output);
73 if (!c) return; 73 if (!c) return;
74 c->width = to->w; 74 c->width = to->w;
75 c->height = to->h; 75 c->height = to->h;
@@ -77,7 +77,7 @@ static void handle_output_resolution_change(wlc_handle output, const struct wlc_
77} 77}
78 78
79static void handle_output_focused(wlc_handle output, bool focus) { 79static void handle_output_focused(wlc_handle output, bool focus) {
80 swayc_t *c = get_swayc_for_handle(output, &root_container); 80 swayc_t *c = wlc_handle_get_user_data(output);
81 if (!c) return; 81 if (!c) return;
82 if (focus) { 82 if (focus) {
83 unfocus_all(&root_container); 83 unfocus_all(&root_container);
@@ -109,7 +109,7 @@ static bool handle_view_created(wlc_handle handle) {
109 109
110static void handle_view_destroyed(wlc_handle handle) { 110static void handle_view_destroyed(wlc_handle handle) {
111 sway_log(L_DEBUG, "Destroying window %d", handle); 111 sway_log(L_DEBUG, "Destroying window %d", handle);
112 swayc_t *view = get_swayc_for_handle(handle, &root_container); 112 swayc_t *view = wlc_handle_get_user_data(handle);
113 swayc_t *parent; 113 swayc_t *parent;
114 swayc_t *focused = get_focused_container(&root_container); 114 swayc_t *focused = get_focused_container(&root_container);
115 115
diff --git a/sway/stringop.c b/sway/stringop.c
index 0f8577ae..450d5cd0 100644
--- a/sway/stringop.c
+++ b/sway/stringop.c
@@ -68,7 +68,6 @@ list_t *split_string(const char *str, const char *delims) {
68 j++; 68 j++;
69 i++; 69 i++;
70 } 70 }
71 free(left);
72 } 71 }
73 } 72 }
74 return res; 73 return res;