mirror of
https://github.com/swaywm/sway.git
synced 2024-12-30 17:06:40 +01:00
Merge pull request #79 from taiyu-len/master
fixed floating_modifier related things
This commit is contained in:
commit
8fb2e7e34e
10 changed files with 209 additions and 184 deletions
|
@ -10,6 +10,7 @@ extern swayc_t root_container;
|
||||||
void init_layout(void);
|
void init_layout(void);
|
||||||
|
|
||||||
void add_child(swayc_t *parent, swayc_t *child);
|
void add_child(swayc_t *parent, swayc_t *child);
|
||||||
|
void add_floating(swayc_t *ws, swayc_t *child);
|
||||||
// Returns parent container which needs to be rearranged.
|
// Returns parent container which needs to be rearranged.
|
||||||
swayc_t *add_sibling(swayc_t *sibling, swayc_t *child);
|
swayc_t *add_sibling(swayc_t *sibling, swayc_t *child);
|
||||||
swayc_t *replace_child(swayc_t *child, swayc_t *new_child);
|
swayc_t *replace_child(swayc_t *child, swayc_t *new_child);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef _SWAY_LOG_H
|
#ifndef _SWAY_LOG_H
|
||||||
#define _SWAY_LOG_H
|
#define _SWAY_LOG_H
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include "container.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
L_SILENT = 0,
|
L_SILENT = 0,
|
||||||
|
@ -15,4 +16,5 @@ void sway_log(int verbosity, const char* format, ...) __attribute__((format(prin
|
||||||
void sway_abort(const char* format, ...) __attribute__((format(printf,1,2)));
|
void sway_abort(const char* format, ...) __attribute__((format(printf,1,2)));
|
||||||
bool sway_assert(bool condition, const char* format, ...) __attribute__((format(printf,2,3)));
|
bool sway_assert(bool condition, const char* format, ...) __attribute__((format(printf,2,3)));
|
||||||
|
|
||||||
|
void layout_log(const swayc_t *c, int depth);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,6 +15,5 @@ void workspace_output_next();
|
||||||
void workspace_next();
|
void workspace_next();
|
||||||
void workspace_output_prev();
|
void workspace_output_prev();
|
||||||
void workspace_prev();
|
void workspace_prev();
|
||||||
void layout_log(const swayc_t *c, int depth);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -186,43 +186,28 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) {
|
||||||
if (view->type != C_VIEW) {
|
if (view->type != C_VIEW) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
int i;
|
|
||||||
// Change from nonfloating to floating
|
// Change from nonfloating to floating
|
||||||
if (!view->is_floating) {
|
if (!view->is_floating) {
|
||||||
view->is_floating = true;
|
//Remove view from its current location
|
||||||
for (i = 0; i < view->parent->children->length; i++) {
|
destroy_container(remove_child(view));
|
||||||
if (view->parent->children->items[i] == view) {
|
|
||||||
// Try to use desired geometry to set w/h
|
|
||||||
if (view->desired_width != -1) {
|
|
||||||
view->width = view->desired_width;
|
|
||||||
}
|
|
||||||
if (view->desired_height != -1) {
|
|
||||||
view->height = view->desired_height;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Swap from the list of whatever container the view was in
|
//and move it into workspace floating
|
||||||
// to the workspace->floating list
|
add_floating(active_workspace,view);
|
||||||
list_del(view->parent->children, i);
|
view->x = (active_workspace->width - view->width)/2;
|
||||||
list_add(active_workspace->floating, view);
|
view->y = (active_workspace->height - view->height)/2;
|
||||||
destroy_container(view->parent);
|
if (view->desired_width != -1) {
|
||||||
|
view->width = view->desired_width;
|
||||||
// Set the new position of the container and arrange windows
|
|
||||||
view->x = (active_workspace->width - view->width)/2;
|
|
||||||
view->y = (active_workspace->height - view->height)/2;
|
|
||||||
sway_log(L_INFO, "Setting container %p to floating at coordinates X:%d Y:%d, W:%d, H:%d", view, view->x, view->y, view->width, view->height);
|
|
||||||
// Change parent to active_workspace
|
|
||||||
view->parent = active_workspace;
|
|
||||||
arrange_windows(active_workspace, -1, -1);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (view->desired_height != -1) {
|
||||||
|
view->height = view->desired_height;
|
||||||
|
}
|
||||||
|
arrange_windows(active_workspace, -1, -1);
|
||||||
} else {
|
} else {
|
||||||
// Delete the view from the floating list and unset its is_floating flag
|
// Delete the view from the floating list and unset its is_floating flag
|
||||||
// Using length-1 as the index is safe because the view must be the currently
|
// Using length-1 as the index is safe because the view must be the currently
|
||||||
// focused floating output
|
// focused floating output
|
||||||
list_del(active_workspace->floating, active_workspace->floating->length - 1);
|
remove_child(view);
|
||||||
view->is_floating = false;
|
view->is_floating = false;
|
||||||
active_workspace->focused = NULL;
|
|
||||||
// Get the properly focused container, and add in the view there
|
// Get the properly focused container, and add in the view there
|
||||||
swayc_t *focused = container_under_pointer();
|
swayc_t *focused = container_under_pointer();
|
||||||
// If focused is null, it's because the currently focused container is a workspace
|
// If focused is null, it's because the currently focused container is a workspace
|
||||||
|
@ -242,10 +227,10 @@ static bool cmd_floating(struct sway_config *config, int argc, char **argv) {
|
||||||
add_sibling(focused, view);
|
add_sibling(focused, view);
|
||||||
}
|
}
|
||||||
// Refocus on the view once its been put back into the layout
|
// Refocus on the view once its been put back into the layout
|
||||||
set_focused_container(view);
|
|
||||||
arrange_windows(active_workspace, -1, -1);
|
arrange_windows(active_workspace, -1, -1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
set_focused_container(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -200,8 +200,9 @@ swayc_t *new_floating_view(wlc_handle handle) {
|
||||||
// Set the geometry of the floating view
|
// Set the geometry of the floating view
|
||||||
const struct wlc_geometry* geometry = wlc_view_get_geometry(handle);
|
const struct wlc_geometry* geometry = wlc_view_get_geometry(handle);
|
||||||
|
|
||||||
view->x = geometry->origin.x;
|
//give it requested geometry, but place in center
|
||||||
view->y = geometry->origin.y;
|
view->x = (active_workspace->width - geometry->size.w) / 2;
|
||||||
|
view->y = (active_workspace->height- geometry->size.h) / 2;
|
||||||
view->width = geometry->size.w;
|
view->width = geometry->size.w;
|
||||||
view->height = geometry->size.h;
|
view->height = geometry->size.h;
|
||||||
|
|
||||||
|
@ -260,7 +261,6 @@ swayc_t *destroy_container(swayc_t *container) {
|
||||||
sway_log(L_DEBUG, "Container: Destroying container '%p'", container);
|
sway_log(L_DEBUG, "Container: Destroying container '%p'", container);
|
||||||
swayc_t *parent = container->parent;
|
swayc_t *parent = container->parent;
|
||||||
free_swayc(container);
|
free_swayc(container);
|
||||||
|
|
||||||
container = parent;
|
container = parent;
|
||||||
}
|
}
|
||||||
return container;
|
return container;
|
||||||
|
|
|
@ -146,6 +146,9 @@ void set_focused_container(swayc_t *c) {
|
||||||
// update container focus from here to root, making necessary changes along
|
// update container focus from here to root, making necessary changes along
|
||||||
// the way
|
// the way
|
||||||
swayc_t *p = c;
|
swayc_t *p = c;
|
||||||
|
if (p->type != C_OUTPUT && p->type != C_ROOT) {
|
||||||
|
p->is_focused = true;
|
||||||
|
}
|
||||||
while (p != &root_container) {
|
while (p != &root_container) {
|
||||||
update_focus(p);
|
update_focus(p);
|
||||||
p = p->parent;
|
p = p->parent;
|
||||||
|
@ -168,8 +171,11 @@ void set_focused_container(swayc_t *c) {
|
||||||
}
|
}
|
||||||
// activate current focus
|
// activate current focus
|
||||||
if (p->type == C_VIEW) {
|
if (p->type == C_VIEW) {
|
||||||
wlc_view_focus(p->handle);
|
|
||||||
wlc_view_set_state(p->handle, WLC_BIT_ACTIVATED, true);
|
wlc_view_set_state(p->handle, WLC_BIT_ACTIVATED, true);
|
||||||
|
//set focus if view_focus is unlocked
|
||||||
|
if (!locked_view_focus) {
|
||||||
|
wlc_view_focus(p->handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
202
sway/handlers.c
202
sway/handlers.c
|
@ -15,6 +15,7 @@
|
||||||
#include "focus.h"
|
#include "focus.h"
|
||||||
|
|
||||||
uint32_t keys_pressed[32];
|
uint32_t keys_pressed[32];
|
||||||
|
int keys_pressed_length = 0;
|
||||||
|
|
||||||
static struct wlc_origin mouse_origin;
|
static struct wlc_origin mouse_origin;
|
||||||
|
|
||||||
|
@ -23,6 +24,15 @@ static bool dragging = false;
|
||||||
static bool m2_held = false;
|
static bool m2_held = false;
|
||||||
static bool resizing = false;
|
static bool resizing = false;
|
||||||
|
|
||||||
|
static bool floating_mod_pressed(void) {
|
||||||
|
int i = 0;
|
||||||
|
while (i < keys_pressed_length) {
|
||||||
|
if (keys_pressed[i++] == config->floating_mod)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static bool pointer_test(swayc_t *view, void *_origin) {
|
static bool pointer_test(swayc_t *view, void *_origin) {
|
||||||
const struct wlc_origin *origin = _origin;
|
const struct wlc_origin *origin = _origin;
|
||||||
// Determine the output that the view is under
|
// Determine the output that the view is under
|
||||||
|
@ -139,35 +149,54 @@ static void handle_output_focused(wlc_handle output, bool focus) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool handle_view_created(wlc_handle handle) {
|
static bool handle_view_created(wlc_handle handle) {
|
||||||
swayc_t *focused = get_focused_container(&root_container);
|
// if view is child of another view, the use that as focused container
|
||||||
|
wlc_handle parent = wlc_view_get_parent(handle);
|
||||||
|
swayc_t *focused = NULL;
|
||||||
swayc_t *newview = NULL;
|
swayc_t *newview = NULL;
|
||||||
|
|
||||||
|
// Get parent container, to add view in
|
||||||
|
if (parent) {
|
||||||
|
focused = get_swayc_for_handle(parent, &root_container);
|
||||||
|
}
|
||||||
|
if (!focused || focused->type == C_OUTPUT) {
|
||||||
|
focused = get_focused_container(&root_container);
|
||||||
|
}
|
||||||
|
sway_log(L_DEBUG, "creating view %ld with type %x, state %x, with parent %ld",
|
||||||
|
handle, wlc_view_get_type(handle), wlc_view_get_state(handle), parent);
|
||||||
|
|
||||||
|
// TODO properly figure out how each window should be handled.
|
||||||
switch (wlc_view_get_type(handle)) {
|
switch (wlc_view_get_type(handle)) {
|
||||||
// regular view created regularly
|
// regular view created regularly
|
||||||
case 0:
|
case 0:
|
||||||
newview = new_view(focused, handle);
|
newview = new_view(focused, handle);
|
||||||
wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, true);
|
wlc_view_set_state(handle, WLC_BIT_MAXIMIZED, true);
|
||||||
break;
|
break;
|
||||||
// takes keyboard focus
|
|
||||||
|
// Dmenu keeps viewfocus, but others with this flag dont, for now simulate
|
||||||
|
// dmenu
|
||||||
case WLC_BIT_OVERRIDE_REDIRECT:
|
case WLC_BIT_OVERRIDE_REDIRECT:
|
||||||
sway_log(L_DEBUG, "view %ld with OVERRIDE_REDIRECT", handle);
|
// locked_view_focus = true;
|
||||||
locked_view_focus = true;
|
|
||||||
wlc_view_focus(handle);
|
wlc_view_focus(handle);
|
||||||
wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true);
|
wlc_view_set_state(handle, WLC_BIT_ACTIVATED, true);
|
||||||
wlc_view_bring_to_front(handle);
|
wlc_view_bring_to_front(handle);
|
||||||
break;
|
break;
|
||||||
// Takes container focus
|
|
||||||
|
// Firefox popups have this flag set.
|
||||||
case WLC_BIT_OVERRIDE_REDIRECT|WLC_BIT_UNMANAGED:
|
case WLC_BIT_OVERRIDE_REDIRECT|WLC_BIT_UNMANAGED:
|
||||||
sway_log(L_DEBUG, "view %ld with OVERRIDE_REDIRECT|WLC_BIT_MANAGED", handle);
|
|
||||||
wlc_view_bring_to_front(handle);
|
wlc_view_bring_to_front(handle);
|
||||||
locked_container_focus = true;
|
locked_container_focus = true;
|
||||||
break;
|
break;
|
||||||
// set modals as floating containers
|
|
||||||
|
// Modals, get focus, popups do not
|
||||||
case WLC_BIT_MODAL:
|
case WLC_BIT_MODAL:
|
||||||
|
wlc_view_focus(handle);
|
||||||
wlc_view_bring_to_front(handle);
|
wlc_view_bring_to_front(handle);
|
||||||
newview = new_floating_view(handle);
|
newview = new_floating_view(handle);
|
||||||
case WLC_BIT_POPUP:
|
case WLC_BIT_POPUP:
|
||||||
|
wlc_view_bring_to_front(handle);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newview) {
|
if (newview) {
|
||||||
set_focused_container(newview);
|
set_focused_container(newview);
|
||||||
swayc_t *output = newview->parent;
|
swayc_t *output = newview->parent;
|
||||||
|
@ -187,19 +216,19 @@ static void handle_view_destroyed(wlc_handle handle) {
|
||||||
// regular view created regularly
|
// regular view created regularly
|
||||||
case 0:
|
case 0:
|
||||||
case WLC_BIT_MODAL:
|
case WLC_BIT_MODAL:
|
||||||
|
case WLC_BIT_POPUP:
|
||||||
if (view) {
|
if (view) {
|
||||||
swayc_t *parent = destroy_view(view);
|
swayc_t *parent = destroy_view(view);
|
||||||
arrange_windows(parent, -1, -1);
|
arrange_windows(parent, -1, -1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// takes keyboard focus
|
// DMENU has this flag, and takes view_focus, but other things with this
|
||||||
|
// flag dont
|
||||||
case WLC_BIT_OVERRIDE_REDIRECT:
|
case WLC_BIT_OVERRIDE_REDIRECT:
|
||||||
locked_view_focus = false;
|
// locked_view_focus = false;
|
||||||
break;
|
break;
|
||||||
// Takes container focus
|
|
||||||
case WLC_BIT_OVERRIDE_REDIRECT|WLC_BIT_UNMANAGED:
|
case WLC_BIT_OVERRIDE_REDIRECT|WLC_BIT_UNMANAGED:
|
||||||
locked_container_focus = false;
|
locked_container_focus = false;
|
||||||
case WLC_BIT_POPUP:
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
set_focused_container(get_focused_view(&root_container));
|
set_focused_container(get_focused_view(&root_container));
|
||||||
|
@ -267,7 +296,6 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
|
||||||
if (locked_view_focus && state == WLC_KEY_STATE_PRESSED) {
|
if (locked_view_focus && state == WLC_KEY_STATE_PRESSED) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
static uint8_t head = 0;
|
|
||||||
bool cmd_success = false;
|
bool cmd_success = false;
|
||||||
|
|
||||||
struct sway_mode *mode = config->current_mode;
|
struct sway_mode *mode = config->current_mode;
|
||||||
|
@ -276,13 +304,15 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
|
||||||
|
|
||||||
// Find key, if it has been pressed
|
// Find key, if it has been pressed
|
||||||
int mid = 0;
|
int mid = 0;
|
||||||
while (mid < head && keys_pressed[mid] != sym) {
|
while (mid < keys_pressed_length && keys_pressed[mid] != sym) {
|
||||||
++mid;
|
++mid;
|
||||||
}
|
}
|
||||||
if (state == WLC_KEY_STATE_PRESSED && mid == head && head + 1 < QSIZE) {
|
//Add or remove key depending on state
|
||||||
keys_pressed[head++] = sym;
|
if (state == WLC_KEY_STATE_PRESSED && mid == keys_pressed_length && keys_pressed_length + 1 < QSIZE) {
|
||||||
} else if (state == WLC_KEY_STATE_RELEASED && mid < head) {
|
keys_pressed[keys_pressed_length++] = sym;
|
||||||
memmove(keys_pressed + mid, keys_pressed + mid + 1, sizeof*keys_pressed * (--head - mid));
|
} else if (state == WLC_KEY_STATE_RELEASED && mid < keys_pressed_length) {
|
||||||
|
memmove(keys_pressed + mid, keys_pressed + mid + 1, sizeof*keys_pressed * (--keys_pressed_length - mid));
|
||||||
|
keys_pressed[keys_pressed_length] = 0;
|
||||||
}
|
}
|
||||||
// TODO: reminder to check conflicts with mod+q+a versus mod+q
|
// TODO: reminder to check conflicts with mod+q+a versus mod+q
|
||||||
int i;
|
int i;
|
||||||
|
@ -296,7 +326,7 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
|
||||||
match = false;
|
match = false;
|
||||||
xkb_keysym_t *key = binding->keys->items[j];
|
xkb_keysym_t *key = binding->keys->items[j];
|
||||||
uint8_t k;
|
uint8_t k;
|
||||||
for (k = 0; k < head; ++k) {
|
for (k = 0; k < keys_pressed_length; ++k) {
|
||||||
if (keys_pressed[k] == *key) {
|
if (keys_pressed[k] == *key) {
|
||||||
match = true;
|
match = true;
|
||||||
break;
|
break;
|
||||||
|
@ -312,8 +342,9 @@ static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifier
|
||||||
int j;
|
int j;
|
||||||
for (j = 0; j < binding->keys->length; ++j) {
|
for (j = 0; j < binding->keys->length; ++j) {
|
||||||
uint8_t k;
|
uint8_t k;
|
||||||
for (k = 0; k < head; ++k) {
|
for (k = 0; k < keys_pressed_length; ++k) {
|
||||||
memmove(keys_pressed + k, keys_pressed + k + 1, sizeof*keys_pressed * (--head - k));
|
memmove(keys_pressed + k, keys_pressed + k + 1, sizeof*keys_pressed * (--keys_pressed_length - k));
|
||||||
|
keys_pressed[keys_pressed_length] = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -333,84 +364,67 @@ static bool handle_pointer_motion(wlc_handle handle, uint32_t time, const struct
|
||||||
static wlc_handle prev_handle = 0;
|
static wlc_handle prev_handle = 0;
|
||||||
mouse_origin = *origin;
|
mouse_origin = *origin;
|
||||||
bool changed_floating = false;
|
bool changed_floating = false;
|
||||||
int i = 0;
|
|
||||||
if (!active_workspace) {
|
if (!active_workspace) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Do checks to determine if proper keys are being held
|
// Do checks to determine if proper keys are being held
|
||||||
swayc_t *view = active_workspace->focused;
|
swayc_t *view = get_focused_view(active_workspace);
|
||||||
uint32_t edge = 0;
|
uint32_t edge = 0;
|
||||||
if (dragging && view) {
|
if (dragging && view && view->is_floating) {
|
||||||
if (view->is_floating) {
|
int dx = mouse_origin.x - prev_pos.x;
|
||||||
while (keys_pressed[i++]) {
|
int dy = mouse_origin.y - prev_pos.y;
|
||||||
if (keys_pressed[i] == config->floating_mod) {
|
view->x += dx;
|
||||||
int dx = mouse_origin.x - prev_pos.x;
|
view->y += dy;
|
||||||
int dy = mouse_origin.y - prev_pos.y;
|
changed_floating = true;
|
||||||
view->x += dx;
|
} else if (resizing && view && view->is_floating) {
|
||||||
view->y += dy;
|
int dx = mouse_origin.x - prev_pos.x;
|
||||||
changed_floating = true;
|
int dy = mouse_origin.y - prev_pos.y;
|
||||||
break;
|
|
||||||
}
|
// Move and resize the view based on the dx/dy and mouse position
|
||||||
|
int midway_x = view->x + view->width/2;
|
||||||
|
int midway_y = view->y + view->height/2;
|
||||||
|
if (dx < 0) {
|
||||||
|
changed_floating = true;
|
||||||
|
if (mouse_origin.x > midway_x) {
|
||||||
|
view->width += dx;
|
||||||
|
edge += WLC_RESIZE_EDGE_RIGHT;
|
||||||
|
} else {
|
||||||
|
view->x += dx;
|
||||||
|
view->width -= dx;
|
||||||
|
edge += WLC_RESIZE_EDGE_LEFT;
|
||||||
|
}
|
||||||
|
} else if (dx > 0){
|
||||||
|
changed_floating = true;
|
||||||
|
if (mouse_origin.x > midway_x) {
|
||||||
|
view->width += dx;
|
||||||
|
edge += WLC_RESIZE_EDGE_RIGHT;
|
||||||
|
} else {
|
||||||
|
view->x += dx;
|
||||||
|
view->width -= dx;
|
||||||
|
edge += WLC_RESIZE_EDGE_LEFT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (resizing && view) {
|
|
||||||
if (view->is_floating) {
|
|
||||||
while (keys_pressed[i++]) {
|
|
||||||
if (keys_pressed[i] == config->floating_mod) {
|
|
||||||
int dx = mouse_origin.x - prev_pos.x;
|
|
||||||
int dy = mouse_origin.y - prev_pos.y;
|
|
||||||
|
|
||||||
// Move and resize the view based on the dx/dy and mouse position
|
if (dy < 0) {
|
||||||
int midway_x = view->x + view->width/2;
|
changed_floating = true;
|
||||||
int midway_y = view->y + view->height/2;
|
if (mouse_origin.y > midway_y) {
|
||||||
|
view->height += dy;
|
||||||
|
edge += WLC_RESIZE_EDGE_BOTTOM;
|
||||||
if (dx < 0) {
|
} else {
|
||||||
changed_floating = true;
|
view->y += dy;
|
||||||
if (mouse_origin.x > midway_x) {
|
view->height -= dy;
|
||||||
view->width += dx;
|
edge += WLC_RESIZE_EDGE_TOP;
|
||||||
edge += WLC_RESIZE_EDGE_RIGHT;
|
}
|
||||||
} else {
|
} else if (dy > 0) {
|
||||||
view->x += dx;
|
changed_floating = true;
|
||||||
view->width -= dx;
|
if (mouse_origin.y > midway_y) {
|
||||||
edge += WLC_RESIZE_EDGE_LEFT;
|
view->height += dy;
|
||||||
}
|
edge += WLC_RESIZE_EDGE_BOTTOM;
|
||||||
} else if (dx > 0){
|
} else {
|
||||||
changed_floating = true;
|
edge = WLC_RESIZE_EDGE_BOTTOM;
|
||||||
if (mouse_origin.x > midway_x) {
|
view->y += dy;
|
||||||
view->width += dx;
|
view->height -= dy;
|
||||||
edge += WLC_RESIZE_EDGE_RIGHT;
|
edge += WLC_RESIZE_EDGE_TOP;
|
||||||
} else {
|
|
||||||
view->x += dx;
|
|
||||||
view->width -= dx;
|
|
||||||
edge += WLC_RESIZE_EDGE_LEFT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dy < 0) {
|
|
||||||
changed_floating = true;
|
|
||||||
if (mouse_origin.y > midway_y) {
|
|
||||||
view->height += dy;
|
|
||||||
edge += WLC_RESIZE_EDGE_BOTTOM;
|
|
||||||
} else {
|
|
||||||
view->y += dy;
|
|
||||||
view->height -= dy;
|
|
||||||
edge += WLC_RESIZE_EDGE_TOP;
|
|
||||||
}
|
|
||||||
} else if (dy > 0) {
|
|
||||||
changed_floating = true;
|
|
||||||
if (mouse_origin.y > midway_y) {
|
|
||||||
view->height += dy;
|
|
||||||
edge += WLC_RESIZE_EDGE_BOTTOM;
|
|
||||||
} else {
|
|
||||||
edge = WLC_RESIZE_EDGE_BOTTOM;
|
|
||||||
view->y += dy;
|
|
||||||
view->height -= dy;
|
|
||||||
edge += WLC_RESIZE_EDGE_TOP;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -467,8 +481,12 @@ static bool handle_pointer_button(wlc_handle view, uint32_t time, const struct w
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
arrange_windows(pointer->parent, -1, -1);
|
arrange_windows(pointer->parent, -1, -1);
|
||||||
dragging = m1_held;
|
if (floating_mod_pressed()) {
|
||||||
resizing = m2_held;
|
dragging = m1_held;
|
||||||
|
resizing = m2_held;
|
||||||
|
}
|
||||||
|
//Dont want pointer sent to window while dragging or resizing
|
||||||
|
return (dragging || resizing);
|
||||||
}
|
}
|
||||||
return (pointer && pointer != focused);
|
return (pointer && pointer != focused);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -38,6 +38,17 @@ void add_child(swayc_t *parent, swayc_t *child) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void add_floating(swayc_t *ws, swayc_t *child) {
|
||||||
|
sway_log(L_DEBUG, "Adding %p (%d, %dx%d) to %p (%d, %dx%d)", child, child->type,
|
||||||
|
child->width, child->height, ws, ws->type, ws->width, ws->height);
|
||||||
|
list_add(ws->floating, child);
|
||||||
|
child->parent = ws;
|
||||||
|
child->is_floating = true;
|
||||||
|
if (!ws->focused) {
|
||||||
|
ws->focused = child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
swayc_t *add_sibling(swayc_t *sibling, swayc_t *child) {
|
swayc_t *add_sibling(swayc_t *sibling, swayc_t *child) {
|
||||||
swayc_t *parent = sibling->parent;
|
swayc_t *parent = sibling->parent;
|
||||||
int i = index_child(parent, sibling);
|
int i = index_child(parent, sibling);
|
||||||
|
@ -76,6 +87,7 @@ swayc_t *remove_child(swayc_t *child) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
i = 0;
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < parent->children->length; ++i) {
|
for (i = 0; i < parent->children->length; ++i) {
|
||||||
if (parent->children->items[i] == child) {
|
if (parent->children->items[i] == child) {
|
||||||
|
|
59
sway/log.c
59
sway/log.c
|
@ -82,3 +82,62 @@ bool sway_assert(bool condition, const char* format, ...) {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "workspace.h"
|
||||||
|
|
||||||
|
/* XXX:DEBUG:XXX */
|
||||||
|
static void container_log(const swayc_t *c) {
|
||||||
|
fprintf(stderr, "focus:%c|",
|
||||||
|
c->is_focused ? 'F' : //Focused
|
||||||
|
c == active_workspace ? 'W' : //active workspace
|
||||||
|
c == &root_container ? 'R' : //root
|
||||||
|
'X');//not any others
|
||||||
|
fprintf(stderr,"(%p)",c);
|
||||||
|
fprintf(stderr,"(p:%p)",c->parent);
|
||||||
|
fprintf(stderr,"(f:%p)",c->focused);
|
||||||
|
fprintf(stderr,"(h:%ld)",c->handle);
|
||||||
|
fprintf(stderr,"Type:");
|
||||||
|
fprintf(stderr,
|
||||||
|
c->type == C_ROOT ? "Root|" :
|
||||||
|
c->type == C_OUTPUT ? "Output|" :
|
||||||
|
c->type == C_WORKSPACE ? "Workspace|" :
|
||||||
|
c->type == C_CONTAINER ? "Container|" :
|
||||||
|
c->type == C_VIEW ? "View|" : "Unknown|");
|
||||||
|
fprintf(stderr,"layout:");
|
||||||
|
fprintf(stderr,
|
||||||
|
c->layout == L_NONE ? "NONE|" :
|
||||||
|
c->layout == L_HORIZ ? "Horiz|":
|
||||||
|
c->layout == L_VERT ? "Vert|":
|
||||||
|
c->layout == L_STACKED ? "Stacked|":
|
||||||
|
c->layout == L_FLOATING ? "Floating|":
|
||||||
|
"Unknown|");
|
||||||
|
fprintf(stderr, "w:%d|h:%d|", c->width, c->height);
|
||||||
|
fprintf(stderr, "x:%d|y:%d|", c->x, c->y);
|
||||||
|
fprintf(stderr, "vis:%c|", c->visible?'t':'f');
|
||||||
|
fprintf(stderr, "wgt:%d|", c->weight);
|
||||||
|
fprintf(stderr, "name:%.16s|", c->name);
|
||||||
|
fprintf(stderr, "children:%d\n",c->children?c->children->length:0);
|
||||||
|
}
|
||||||
|
void layout_log(const swayc_t *c, int depth) {
|
||||||
|
int i, d;
|
||||||
|
int e = c->children ? c->children->length : 0;
|
||||||
|
container_log(c);
|
||||||
|
if (e) {
|
||||||
|
for (i = 0; i < e; ++i) {
|
||||||
|
fputc('|',stderr);
|
||||||
|
for (d = 0; d < depth; ++d) fputc('-', stderr);
|
||||||
|
layout_log(c->children->items[i], depth + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (c->type == C_WORKSPACE) {
|
||||||
|
e = c->floating?c->floating->length:0;
|
||||||
|
if (e) {
|
||||||
|
for (i = 0; i < e; ++i) {
|
||||||
|
fputc('|',stderr);
|
||||||
|
for (d = 0; d < depth; ++d) fputc('=', stderr);
|
||||||
|
layout_log(c->floating->items[i], depth + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* XXX:DEBUG:XXX */
|
||||||
|
|
|
@ -187,60 +187,3 @@ void workspace_switch(swayc_t *workspace) {
|
||||||
set_focused_container(get_focused_view(workspace));
|
set_focused_container(get_focused_view(workspace));
|
||||||
arrange_windows(workspace, -1, -1);
|
arrange_windows(workspace, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX:DEBUG:XXX */
|
|
||||||
static void container_log(const swayc_t *c) {
|
|
||||||
fprintf(stderr, "focus:%c|",
|
|
||||||
c->is_focused ? 'F' : //Focused
|
|
||||||
c == active_workspace ? 'W' : //active workspace
|
|
||||||
c == &root_container ? 'R' : //root
|
|
||||||
'X');//not any others
|
|
||||||
fprintf(stderr,"(%p)",c);
|
|
||||||
fprintf(stderr,"(p:%p)",c->parent);
|
|
||||||
fprintf(stderr,"(f:%p)",c->focused);
|
|
||||||
fprintf(stderr,"(h:%ld)",c->handle);
|
|
||||||
fprintf(stderr,"Type:");
|
|
||||||
fprintf(stderr,
|
|
||||||
c->type == C_ROOT ? "Root|" :
|
|
||||||
c->type == C_OUTPUT ? "Output|" :
|
|
||||||
c->type == C_WORKSPACE ? "Workspace|" :
|
|
||||||
c->type == C_CONTAINER ? "Container|" :
|
|
||||||
c->type == C_VIEW ? "View|" : "Unknown|");
|
|
||||||
fprintf(stderr,"layout:");
|
|
||||||
fprintf(stderr,
|
|
||||||
c->layout == L_NONE ? "NONE|" :
|
|
||||||
c->layout == L_HORIZ ? "Horiz|":
|
|
||||||
c->layout == L_VERT ? "Vert|":
|
|
||||||
c->layout == L_STACKED ? "Stacked|":
|
|
||||||
c->layout == L_FLOATING ? "Floating|":
|
|
||||||
"Unknown|");
|
|
||||||
fprintf(stderr, "w:%d|h:%d|", c->width, c->height);
|
|
||||||
fprintf(stderr, "x:%d|y:%d|", c->x, c->y);
|
|
||||||
fprintf(stderr, "vis:%c|", c->visible?'t':'f');
|
|
||||||
fprintf(stderr, "wgt:%d|", c->weight);
|
|
||||||
fprintf(stderr, "name:%.16s|", c->name);
|
|
||||||
fprintf(stderr, "children:%d\n",c->children?c->children->length:0);
|
|
||||||
}
|
|
||||||
void layout_log(const swayc_t *c, int depth) {
|
|
||||||
int i, d;
|
|
||||||
int e = c->children ? c->children->length : 0;
|
|
||||||
container_log(c);
|
|
||||||
if (e) {
|
|
||||||
for (i = 0; i < e; ++i) {
|
|
||||||
fputc('|',stderr);
|
|
||||||
for (d = 0; d < depth; ++d) fputc('-', stderr);
|
|
||||||
layout_log(c->children->items[i], depth + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (c->type == C_WORKSPACE) {
|
|
||||||
e = c->floating?c->floating->length:0;
|
|
||||||
if (e) {
|
|
||||||
for (i = 0; i < e; ++i) {
|
|
||||||
fputc('|',stderr);
|
|
||||||
for (d = 0; d < depth; ++d) fputc('-', stderr);
|
|
||||||
layout_log(c->floating->items[i], depth + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* XXX:DEBUG:XXX */
|
|
||||||
|
|
Loading…
Reference in a new issue