aboutsummaryrefslogtreecommitdiff
path: root/sway/handlers.c
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2015-10-29 17:52:16 -0400
committerDrew DeVault <sir@cmpwn.com>2015-10-29 17:52:16 -0400
commitca5a2a387c97914d97929b09113359c45ba23279 (patch)
treec702c4a176e4e78b295c14c6d457296fcf094527 /sway/handlers.c
parentad1cd0a3bd2111041a38c920d1c10a5e5534b275 (diff)
parent515ed86f4d8106d4396d5b8056fdf5600e606458 (diff)
Merge pull request #212 from sce/mouse_warping
Learn mouse_warping
Diffstat (limited to 'sway/handlers.c')
-rw-r--r--sway/handlers.c88
1 files changed, 1 insertions, 87 deletions
diff --git a/sway/handlers.c b/sway/handlers.c
index 1c5abca6..510b4261 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -24,68 +24,6 @@
// Event handled by sway and should not be sent to client
#define EVENT_HANDLED true
-static bool pointer_test(swayc_t *view, void *_origin) {
- const struct mouse_origin *origin = _origin;
- // Determine the output that the view is under
- swayc_t *parent = swayc_parent_by_type(view, C_OUTPUT);
- if (origin->x >= view->x && origin->y >= view->y
- && origin->x < view->x + view->width && origin->y < view->y + view->height
- && view->visible && parent == root_container.focused) {
- return true;
- }
- return false;
-}
-
-swayc_t *container_under_pointer(void) {
- // root.output->workspace
- if (!root_container.focused || !root_container.focused->focused) {
- return NULL;
- }
- swayc_t *lookup = root_container.focused->focused;
- // Case of empty workspace
- if (lookup->children == 0) {
- return NULL;
- }
- while (lookup->type != C_VIEW) {
- int i;
- int len;
- // if tabbed/stacked go directly to focused container, otherwise search
- // children
- if (lookup->layout == L_TABBED || lookup->layout == L_STACKED) {
- lookup = lookup->focused;
- continue;
- }
- // if workspace, search floating
- if (lookup->type == C_WORKSPACE) {
- i = len = lookup->floating->length;
- bool got_floating = false;
- while (--i > -1) {
- if (pointer_test(lookup->floating->items[i], &pointer_state.origin)) {
- lookup = lookup->floating->items[i];
- got_floating = true;
- break;
- }
- }
- if (got_floating) {
- continue;
- }
- }
- // search children
- len = lookup->children->length;
- for (i = 0; i < len; ++i) {
- if (pointer_test(lookup->children->items[i], &pointer_state.origin)) {
- lookup = lookup->children->items[i];
- break;
- }
- }
- // when border and titles are done, this could happen
- if (i == len) {
- break;
- }
- }
- return lookup;
-}
-
/* Handles */
static bool handle_output_created(wlc_handle output) {
@@ -394,27 +332,7 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
}
}
- // Update pointer origin
- pointer_state.delta.x = origin->x - pointer_state.origin.x;
- pointer_state.delta.y = origin->y - pointer_state.origin.y;
- pointer_state.origin.x = origin->x;
- pointer_state.origin.y = origin->y;
-
- // Update view under pointer
- swayc_t *prev_view = pointer_state.view;
- pointer_state.view = container_under_pointer();
-
- // If pointer is in a mode, update it
- if (pointer_state.mode) {
- pointer_mode_update();
- }
- // Otherwise change focus if config is set an
- else if (prev_view != pointer_state.view && config->focus_follows_mouse) {
- if (pointer_state.view && pointer_state.view->type == C_VIEW) {
- set_focused_container(pointer_state.view);
- }
- }
- wlc_pointer_set_origin(&new_origin);
+ pointer_position_set(&new_origin, false);
return EVENT_PASSTHROUGH;
}
@@ -425,10 +343,6 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
// Update view pointer is on
pointer_state.view = container_under_pointer();
- // Update pointer origin
- pointer_state.origin.x = origin->x;
- pointer_state.origin.y = origin->y;
-
// Update pointer_state
switch (button) {
case M_LEFT_CLICK: