Instead of harcoding at 1080p, just grab the largest connected output and use that as the pool size. This allows us to be a bit more stingy on reallocing.
Unified · Split
| @@ -530,14 +530,40 @@ static const struct xdg_wm_base_listener xdg_wm_base_listener = { · 529 unmodified lines | |||
| 530 | .ping = xdg_wm_base_ping, | 530 | .ping = xdg_wm_base_ping, |
| 531 | }; | 531 | }; |
| 532 | 532 | ||
| 533 | static void | ||
| 534 | mode(void *data, struct wl_output*, uint, int x, int y, int) | ||
| 535 | { | ||
| 536 | Wlwin *wl; | ||
| 537 | |||
| 538 | wl = data; | ||
| 539 | if(x >= wl->monx && y >= wl->mony){ | ||
| 540 | wl->monx = x; | ||
| 541 | wl->mony = y; | ||
| 542 | } | ||
| 543 | } | ||
| 544 | static void done(void*, struct wl_output*){} | ||
| 545 | static void scale(void*, struct wl_output*, int){} | ||
| 546 | static void geometry(void*, struct wl_output*, int, int, int, int, int, const char*, const char*, int){} | ||
| 547 | |||
| 548 | static const struct wl_output_listener output_listener = { | ||
| 549 | .geometry = geometry, | ||
| 550 | .mode = mode, | ||
| 551 | .done = done, | ||
| 552 | .scale = scale, | ||
| 553 | }; | ||
| 554 | |||
| 533 | static void | 555 | static void |
| 534 | handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) | 556 | handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) |
| 535 | { | 557 | { |
| 536 | Wlwin *wl; | 558 | Wlwin *wl; |
| 559 | struct wl_output *out; | ||
| 537 | 560 | ||
| 538 | wl = data; | 561 | wl = data; |
| 539 | if(strcmp(interface, wl_shm_interface.name) == 0) { | 562 | if(strcmp(interface, wl_shm_interface.name) == 0) { |
| 540 | wl->shm = wl_registry_bind(registry, name, &wl_shm_interface, 1); | 563 | wl->shm = wl_registry_bind(registry, name, &wl_shm_interface, 1); |
| 564 | } else if(strcmp(interface, wl_output_interface.name) == 0) { | ||
| 565 | out = wl_registry_bind(registry, name, &wl_output_interface, 2); | ||
| 566 | wl_output_add_listener(out, &output_listener, wl); | ||
| 541 | } else if(strcmp(interface, wl_seat_interface.name) == 0) { | 567 | } else if(strcmp(interface, wl_seat_interface.name) == 0) { |
| 542 | //We don't support multiseat | 568 | //We don't support multiseat |
| 543 | if(wl->seat != nil) | 569 | if(wl->seat != nil) |
| @@ -39,8 +39,8 @@ newwlwin(void) · 38 unmodified lines | |||
| 39 | sysfatal("malloc Wlwin"); | 39 | sysfatal("malloc Wlwin"); |
| 40 | wl->dx = 1024; | 40 | wl->dx = 1024; |
| 41 | wl->dy = 1024; | 41 | wl->dy = 1024; |
| 42 | wl->monx = 1920; | 42 | wl->monx = wl->dx; |
| 43 | wl->mony = 1080; | 43 | wl->mony = wl->dy; |
| 44 | return wl; | 44 | return wl; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| @@ -60,6 +60,8 @@ wlflush(Wlwin *wl) · 13 unmodified lines | |||
| 60 | wl_surface_commit(wl->surface); | 60 | wl_surface_commit(wl->surface); |
| 61 | } | 61 | } |
| 62 | 62 | ||
| 63 | void _screenresize(Rectangle); | ||
| 64 | |||
| 63 | void | 65 | void |
| 64 | wlresize(Wlwin *wl, int x, int y) | 66 | wlresize(Wlwin *wl, int x, int y) |
| 65 | { | 67 | { |
| @@ -73,11 +75,7 @@ wlresize(Wlwin *wl, int x, int y) · 7 unmodified lines | |||
| 73 | r = Rect(0, 0, wl->dx, wl->dy); | 75 | r = Rect(0, 0, wl->dx, wl->dy); |
| 74 | gscreen = allocmemimage(r, XRGB32); | 76 | gscreen = allocmemimage(r, XRGB32); |
| 75 | gscreen->clipr = ZR; | 77 | gscreen->clipr = ZR; |
| 76 | qunlock(&drawlock); | 78 | _screenresize(r); |
| 77 | |||
| 78 | screenresize(r); | ||
| 79 | |||
| 80 | qlock(&drawlock); | ||
| 81 | wl->dirty = 1; | 79 | wl->dirty = 1; |
| 82 | wl->r = r; | 80 | wl->r = r; |
| 83 | wlflush(wl); | 81 | wlflush(wl); |
| @@ -50,7 +50,6 @@ wlcreateshm(off_t size) · 49 unmodified lines | |||
| 50 | void | 50 | void |
| 51 | wlallocpool(Wlwin *wl) | 51 | wlallocpool(Wlwin *wl) |
| 52 | { | 52 | { |
| 53 | int screenx, screeny; | ||
| 54 | int screensize, cursorsize; | 53 | int screensize, cursorsize; |
| 55 | int depth; | 54 | int depth; |
| 56 | int fd; | 55 | int fd; |
| @@ -59,9 +58,7 @@ wlallocpool(Wlwin *wl) · 2 unmodified lines | |||
| 59 | wl_shm_pool_destroy(wl->pool); | 58 | wl_shm_pool_destroy(wl->pool); |
| 60 | 59 | ||
| 61 | depth = 4; | 60 | depth = 4; |
| 62 | screenx = wl->dx > wl->monx ? wl->dx : wl->monx; | 61 | screensize = wl->monx * wl->mony * depth; |
| 63 | screeny = wl->dy > wl->mony ? wl->dy : wl->mony; | ||
| 64 | screensize = screenx * screeny * depth; | ||
| 65 | cursorsize = 16 * 16 * depth; | 62 | cursorsize = 16 * 16 * depth; |
| 66 | 63 | ||
| 67 | fd = wlcreateshm(screensize+cursorsize); | 64 | fd = wlcreateshm(screensize+cursorsize); |
| @@ -89,6 +86,8 @@ wlallocbuffer(Wlwin *wl) · 21 unmodified lines | |||
| 89 | if(wl->pool == nil || size+(16*16*depth) > wl->poolsize) | 86 | if(wl->pool == nil || size+(16*16*depth) > wl->poolsize) |
| 90 | wlallocpool(wl); | 87 | wlallocpool(wl); |
| 91 | 88 | ||
| 89 | assert(size+(16*16*depth) <= wl->poolsize); | ||
| 90 | |||
| 92 | if(wl->screenbuffer != nil) | 91 | if(wl->screenbuffer != nil) |
| 93 | wl_buffer_destroy(wl->screenbuffer); | 92 | wl_buffer_destroy(wl->screenbuffer); |
| 94 | if(wl->cursorbuffer != nil) | 93 | if(wl->cursorbuffer != nil) |