Commit 85060cb7f371ff1c70764a67860652511920bff2 Parent: 7ffd559a6022b659e94cd54970cdf04f7a4f2af9 Author: mcol <mcol@posteo.net> Date: 2021-01-22 00:18:26 +0000 Committer: mcol <mcol@posteo.net> Committed: 2021-01-22 00:18:26 +0000 add actions to halfmize windows to take half screen area
src/config.c Modified
@@ -92,6 +92,11 @@ } else if (strcasecmp(name, "toggle_fullscreen") == 0) kb->action = &toggle_fullscreen; + else if (strcasecmp(name, "halfimize") == 0) { + kb->action = &halfimize; + kb->data = calloc(1, sizeof(enum direction)); + *(enum direction *)(kb->data) = direction_from_name(data); + } } @@ -121,7 +126,10 @@ } // key - kb->key = xkb_keysym_from_name(s, XKB_KEYSYM_CASE_INSENSITIVE); + kb->key = xkb_keysym_from_name(s, XKB_KEYSYM_NO_FLAGS); + if (kb->key == XKB_KEY_NoSymbol) + kb->key = xkb_keysym_from_name(s, XKB_KEYSYM_CASE_INSENSITIVE); + if (kb->key == XKB_KEY_NoSymbol) { kb->key = mouse_key_from_name(s); if (kb->key == 0) {
src/action.h Modified
@@ -19,5 +19,6 @@ void go_to_mark(struct server *server, void *data); void actually_go_to_mark(struct server *server, const xkb_keysym_t sym); void toggle_fullscreen(struct server *server, void *data); +void halfimize(struct server *server, void *data); #endif
src/action.c Modified
@@ -268,3 +268,54 @@ struct view *view = wl_container_of(server->current_desk->views.next, view, link); fullscreen_xdg_surface(view, xdg_surface, NULL); } + + +void halfimize(struct server *server, void *data) { + struct view *view = wl_container_of(server->current_desk->views.next, view, link); + if (!view) + return; + + if (server->current_desk->fullscreened == view->surface) + fullscreen_xdg_surface(view, view->surface, NULL); + + enum direction dir = *(enum direction*)data; + double vx = view->x + view->surface->geometry.width / 2; + double vy = view->y + view->surface->geometry.height / 2; + double x, y, width, height; + wlr_output_layout_closest_point(server->output_layout, NULL, vx, vy, &x, &y); + struct wlr_output *output = wlr_output_layout_output_at(server->output_layout, x, y); + + switch (dir) { + case RIGHT: + x = output->width / 2; + y = 0; + width = output->width / 2; + height = output->height; + break; + case LEFT: + x = 0; + y = 0; + width = output->width / 2; + height = output->height; + break; + case UP: + x = 0; + y = 0; + width = output->width; + height = output->height / 2; + break; + case DOWN: + x = 0; + y = output->height / 2; + width = output->width; + height = output->height / 2; + break; + case NONE: + return; + } + + double zoom = server->current_desk->zoom; + view->x = (x - view->surface->geometry.x) / zoom; + view->y = (y - view->surface->geometry.y) / zoom; + wlr_xdg_toplevel_set_size(view->surface, width / zoom, height / zoom); +}
readme.rst Modified
@@ -18,6 +18,7 @@ - make configuration much nicer and remove all the strcmps - read default configuration as string - then add action to read config + - fix issue where Shift-using key bindings require pre-shifted key in config - xwayland - functions to shift desk view - pinch gestures for desk zooming
deskwm.conf Modified
@@ -44,6 +44,12 @@ bind l focus right bind f toggle_fullscreen +# These give the focussed window half of the screen +bind Shift J halfimize down +bind Shift K halfimize up +bind Shift H halfimize left +bind Shift L halfimize right + # And these act on desks bind Tab next_desk bind ISO_Left_Tab prev_desk