gimp but for windows: a wayland compositor
git clone https://github.com/m-col/wimp
Files | Refs | Readme

Commit ba59c57d4ac751fdb186cd90507891ba7e58be1c
Parent: 0c51792c3b4909edcc797bec9f906a03b12522a4
Author: mcol <mcol@posteo.net>
Date: 2021-01-31 20:26:12 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2021-01-31 20:26:12 +0000

add maximize action

wimp.conf Modified

@@ -59,6 +59,7 @@
 bind		h		focus left
 bind		l		focus right
 bind		f		toggle_fullscreen
+bind	Shift	m		maximize
 bind	Shift	1		send_to_desk 1
 bind	Shift	2		send_to_desk 2
 

src/config.c Modified

@@ -157,6 +157,7 @@
     { "go_to_mark", &go_to_mark, NULL },
     { "toggle_fullscreen", &toggle_fullscreen, NULL },
     { "halfimize", &halfimize, &dir_handler },
+    { "maximize", &maximize, NULL },
     { "reload_config", &reload_config, NULL },
     { "send_to_desk", &send_to_desk, &str_handler },
 };

src/action.h Modified

@@ -23,6 +23,7 @@
 void actually_go_to_mark(const xkb_keysym_t sym);
 void toggle_fullscreen(void *data);
 void halfimize(void *data);
+void maximize(void *data);
 void reload_config(void *data);
 void send_to_desk(void *data);
 

src/action.c Modified

@@ -349,6 +349,28 @@
 }
 
 
+void maximize(void *data) {
+    if (wl_list_empty(&wimp.current_desk->views))
+	return;
+
+    struct view *view = wl_container_of(wimp.current_desk->views.next, view, link);
+    double vx = view->x + view->surface->geometry.width / 2;
+    double vy = view->y + view->surface->geometry.height / 2;
+    double x, y;
+    wlr_output_layout_closest_point(wimp.output_layout, NULL, vx, vy, &x, &y);
+    struct wlr_output *output = wlr_output_layout_output_at(wimp.output_layout, x, y);
+    unfullscreen();
+
+    double zoom = wimp.current_desk->zoom;
+    int border_width = wimp.current_desk->border_width;
+    view->x = border_width;
+    view->y = border_width;
+    double width = (output->width - border_width * 2) / zoom;
+    double height = (output->height - border_width * 2) / zoom;
+    wlr_xdg_toplevel_set_size(view->surface, width, height);
+    wlr_xdg_toplevel_set_tiled(view->surface, true);
+}
+
 void reload_config(void *data) {
     load_config();
 }