mirror of
https://github.com/labwc/labwc.git
synced 2026-02-21 01:40:26 -05:00
action: add 'MoveToEdge'
Currently only moves view to edges of outputs
Example keybind:
<keybind key="A-Left">
<action name="MoveToEdge">
<direction>left</direction>
</action>
</keybind>
This commit is contained in:
parent
10264110f1
commit
49a73befdb
4 changed files with 57 additions and 0 deletions
|
|
@ -32,6 +32,11 @@
|
||||||
<keybind key="A-F3"><action name="Execute"><command>bemenu-run</command></action></keybind>
|
<keybind key="A-F3"><action name="Execute"><command>bemenu-run</command></action></keybind>
|
||||||
<keybind key="A-F4"><action name="Close" /></keybind>
|
<keybind key="A-F4"><action name="Close" /></keybind>
|
||||||
<keybind key="W-a"><action name="ToggleMaximize" /></keybind>
|
<keybind key="W-a"><action name="ToggleMaximize" /></keybind>
|
||||||
|
|
||||||
|
<keybind key="A-Left"><action name="MoveToEdge"><direction>left</direction></action></keybind>
|
||||||
|
<keybind key="A-Right"><action name="MoveToEdge"><direction>right</direction></action></keybind>
|
||||||
|
<keybind key="A-Up"><action name="MoveToEdge"><direction>up</direction></action></keybind>
|
||||||
|
<keybind key="A-Down"><action name="MoveToEdge"><direction>down</direction></action></keybind>
|
||||||
</keyboard>
|
</keyboard>
|
||||||
|
|
||||||
</labwc_config>
|
</labwc_config>
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,8 @@ action(struct server *server, const char *action, const char *command)
|
||||||
free(cmd.buf);
|
free(cmd.buf);
|
||||||
} else if (!strcasecmp(action, "Exit")) {
|
} else if (!strcasecmp(action, "Exit")) {
|
||||||
wl_display_terminate(server->wl_display);
|
wl_display_terminate(server->wl_display);
|
||||||
|
} else if (!strcasecmp(action, "MoveToEdge")) {
|
||||||
|
view_move_to_edge(topmost_mapped_view(server), command);
|
||||||
} else if (!strcasecmp(action, "NextWindow")) {
|
} else if (!strcasecmp(action, "NextWindow")) {
|
||||||
server->cycle_view =
|
server->cycle_view =
|
||||||
desktop_cycle_view(server, server->cycle_view);
|
desktop_cycle_view(server, server->cycle_view);
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,8 @@ fill_keybind(char *nodename, char *content)
|
||||||
current_keybind->action = strdup(content);
|
current_keybind->action = strdup(content);
|
||||||
} else if (!strcmp(nodename, "command.action")) {
|
} else if (!strcmp(nodename, "command.action")) {
|
||||||
current_keybind->command = strdup(content);
|
current_keybind->command = strdup(content);
|
||||||
|
} else if (!strcmp(nodename, "direction.action")) {
|
||||||
|
current_keybind->command = strdup(content);
|
||||||
} else if (!strcmp(nodename, "menu.action")) {
|
} else if (!strcmp(nodename, "menu.action")) {
|
||||||
current_keybind->command = strdup(content);
|
current_keybind->command = strdup(content);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
48
src/view.c
48
src/view.c
|
|
@ -1,4 +1,5 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <strings.h>
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "ssd.h"
|
#include "ssd.h"
|
||||||
|
|
||||||
|
|
@ -130,3 +131,50 @@ view_for_each_popup_surface(struct view *view, wlr_surface_iterator_func_t itera
|
||||||
view->impl->for_each_popup_surface(view, iterator, data);
|
view->impl->for_each_popup_surface(view, iterator, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct border
|
||||||
|
view_border(struct view *view)
|
||||||
|
{
|
||||||
|
struct border border = {
|
||||||
|
.left = view->margin.left - view->padding.left,
|
||||||
|
.top = view->margin.top - view->padding.top,
|
||||||
|
.right = view->margin.right + view->padding.right,
|
||||||
|
.bottom = view->margin.bottom + view->padding.bottom,
|
||||||
|
};
|
||||||
|
return border;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GAP (3)
|
||||||
|
void
|
||||||
|
view_move_to_edge(struct view *view, char *direction)
|
||||||
|
{
|
||||||
|
if (!view) {
|
||||||
|
wlr_log(WLR_ERROR, "no view");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
struct output *output = view_output(view);
|
||||||
|
struct border border = view_border(view);
|
||||||
|
struct wlr_box usable;
|
||||||
|
memcpy(&usable, &output->usable_area, sizeof(struct wlr_box));
|
||||||
|
|
||||||
|
double ox = 0, oy = 0;
|
||||||
|
wlr_output_layout_output_coords(view->server->output_layout,
|
||||||
|
output->wlr_output, &ox, &oy);
|
||||||
|
usable.x -= ox;
|
||||||
|
usable.y -= oy;
|
||||||
|
|
||||||
|
int x, y;
|
||||||
|
if (!strcasecmp(direction, "left")) {
|
||||||
|
x = usable.x + border.left + GAP;
|
||||||
|
y = view->y;
|
||||||
|
} else if (!strcasecmp(direction, "up")) {
|
||||||
|
x = view->x;
|
||||||
|
y = usable.y + border.top + GAP;
|
||||||
|
} else if (!strcasecmp(direction, "right")) {
|
||||||
|
x = usable.x + usable.width - view->w - border.right - GAP;
|
||||||
|
y = view->y;
|
||||||
|
} else if (!strcasecmp(direction, "down")) {
|
||||||
|
x = view->x;
|
||||||
|
y = usable.y + usable.height - view->h - border.bottom - GAP;
|
||||||
|
}
|
||||||
|
view_move(view, x, y);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue