aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authortaiyu <taiyu.len@gmail.com>2015-08-16 00:46:58 -0700
committertaiyu <taiyu.len@gmail.com>2015-08-16 00:46:58 -0700
commiteefc76b39e61ce04fa8ac0e732a22c10d9c98e1f (patch)
tree914b01d7f01ea8b90397041dce2437305453aba2 /sway
parente9e09d123ce1e82cb1680e499a6c349241ada9e6 (diff)
set userdata for handler to swayc_t container
Diffstat (limited to 'sway')
-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) {
output->height = size->h;
output->handle = handle;
- add_child(&root_container, output);
+ //link this to handler
+ wlc_handle_set_user_data(handle, output);
+ add_child(&root_container, output);
//TODO something with this
int total_width = 0;
container_map(&root_container, add_output_widths, &total_width);
@@ -138,6 +140,8 @@ swayc_t *new_view(swayc_t *sibling, wlc_handle handle) {
view->name = strdup(title);
view->visible = true;
+ //Link view to handle
+ wlc_handle_set_user_data(handle, view);
//Case of focused workspace, just create as child of it
if (sibling->type == C_WORKSPACE) {
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) {
static void handle_output_resolution_change(wlc_handle output, const struct wlc_size *from, const struct wlc_size *to) {
sway_log(L_DEBUG, "Output %d resolution changed to %d x %d", output, to->w, to->h);
- swayc_t *c = get_swayc_for_handle(output, &root_container);
+ swayc_t *c = wlc_handle_get_user_data(output);
if (!c) return;
c->width = to->w;
c->height = to->h;
@@ -77,7 +77,7 @@ static void handle_output_resolution_change(wlc_handle output, const struct wlc_
}
static void handle_output_focused(wlc_handle output, bool focus) {
- swayc_t *c = get_swayc_for_handle(output, &root_container);
+ swayc_t *c = wlc_handle_get_user_data(output);
if (!c) return;
if (focus) {
unfocus_all(&root_container);
@@ -109,7 +109,7 @@ static bool handle_view_created(wlc_handle handle) {
static void handle_view_destroyed(wlc_handle handle) {
sway_log(L_DEBUG, "Destroying window %d", handle);
- swayc_t *view = get_swayc_for_handle(handle, &root_container);
+ swayc_t *view = wlc_handle_get_user_data(handle);
swayc_t *parent;
swayc_t *focused = get_focused_container(&root_container);
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) {
j++;
i++;
}
- free(left);
}
}
return res;