feat: size arena to ~80% of output with resize-aware grid
Store wl_output mode dimensions and compute the default logical window size as 80% of the output divided by the active scale, with a fallback. Grid dimensions continue to update on resize.
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
|
||||
## 1. Output handling
|
||||
|
||||
- [ ] 1.1 Store output mode dimensions in the output listener.
|
||||
- [ ] 1.2 Compute default logical window size as 80% of output divided by scale, with fallback.
|
||||
- [x] 1.1 Store output mode dimensions in the output listener.
|
||||
- [x] 1.2 Compute default logical window size as 80% of output divided by scale, with fallback.
|
||||
|
||||
## 2. Verification
|
||||
|
||||
- [ ] 2.1 Build and run, verifying window is ~80% of screen.
|
||||
- [ ] 2.2 Resize window and verify grid updates.
|
||||
- [x] 2.1 Build and run, verifying window is ~80% of screen.
|
||||
- [x] 2.2 Resize window and verify grid updates.
|
||||
@@ -31,6 +31,8 @@ struct xdg_wm_base *xdg_shell;
|
||||
struct wl_seat *wl_seat;
|
||||
struct wl_output *wl_output = NULL;
|
||||
int output_scale_factor = 1;
|
||||
int output_width = 0;
|
||||
int output_height = 0;
|
||||
|
||||
struct keyboard_data keyboard_data;
|
||||
struct pointer_data pointer_data;
|
||||
@@ -83,7 +85,13 @@ struct wp_fractional_scale_v1 *fractional_scale = NULL;
|
||||
|
||||
// output listener
|
||||
static void output_geometry_handler(void *data, struct wl_output *output, int32_t x, int32_t y, int32_t phys_w, int32_t phys_h, int32_t subpixel, const char *make, const char *model, int32_t transform) { (void)data;(void)output;(void)x;(void)y;(void)phys_w;(void)phys_h;(void)subpixel;(void)make;(void)model;(void)transform; }
|
||||
static void output_mode_handler(void *data, struct wl_output *output, uint32_t flags, int32_t width, int32_t height, int32_t refresh) { (void)data;(void)output;(void)flags;(void)width;(void)height;(void)refresh; }
|
||||
static void output_mode_handler(void *data, struct wl_output *output, uint32_t flags, int32_t width, int32_t height, int32_t refresh) {
|
||||
(void)data;(void)output;(void)flags;(void)refresh;
|
||||
if (width > 0 && height > 0) {
|
||||
output_width = width;
|
||||
output_height = height;
|
||||
}
|
||||
}
|
||||
static void output_done_handler(void *data, struct wl_output *output) { (void)data;(void)output; }
|
||||
static void output_scale_handler(void *data, struct wl_output *output, int32_t factor) {
|
||||
(void)data;(void)output;
|
||||
@@ -426,12 +434,21 @@ int main(void)
|
||||
wl_pointer_add_listener(pointer_data.pointer, &pointer_listener, &pointer_data);
|
||||
|
||||
canvas.fd = -1;
|
||||
logical_width = 1024;
|
||||
logical_height = 576;
|
||||
grid_init(&grid, logical_width / 8, logical_height / 8);
|
||||
grid.show_lines = 1;
|
||||
|
||||
// wait for the surface to be configured
|
||||
wl_display_roundtrip(display);
|
||||
|
||||
if (output_width > 0 && output_height > 0 && current_scale > 0) {
|
||||
logical_width = (int)(output_width * 0.8 / current_scale);
|
||||
logical_height = (int)(output_height * 0.8 / current_scale);
|
||||
}
|
||||
if (logical_width < 8) logical_width = 8;
|
||||
if (logical_height < 8) logical_height = 8;
|
||||
|
||||
/* initial scale may arrive via fractional/output after roundtrip */
|
||||
if (fractional_manager && !fractional_scale) {
|
||||
/* already created above */
|
||||
|
||||
Reference in New Issue
Block a user