Skip to content

Commit e116362

Browse files
authored
Merge pull request #159 from sysprog21/fix-no-wm
Let no-WM window to match backend dimensions
2 parents b2f2c39 + 125e617 commit e116362

2 files changed

Lines changed: 22 additions & 13 deletions

File tree

backend/fbdev.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static bool twin_fbdev_work(void *closure)
235235
return true;
236236
}
237237

238-
twin_context_t *twin_fbdev_init(int width, int height)
238+
twin_context_t *twin_fbdev_init(int width maybe_unused, int height maybe_unused)
239239
{
240240
char *fbdev_path = getenv(FBDEV_NAME);
241241
if (!fbdev_path) {
@@ -283,15 +283,24 @@ twin_context_t *twin_fbdev_init(int width, int height)
283283
goto bail_vt_fd;
284284
}
285285

286+
/* Use actual framebuffer resolution instead of caller-supplied dimensions.
287+
* The physical display size is authoritative -- the caller's width/height
288+
* are only hints suitable for resizable backends like SDL.
289+
* Read directly from fb_var which was already validated by
290+
* twin_fbdev_apply_config() above -- no redundant ioctl needed.
291+
*/
292+
int fb_width = tx->fb_var.xres;
293+
int fb_height = tx->fb_var.yres;
294+
286295
const twin_put_span_t fbdev_put_spans[] = {
287296
_twin_fbdev_put_span16,
288297
_twin_fbdev_put_span24,
289298
_twin_fbdev_put_span32,
290299
};
291300
/* Create TWIN screen */
292301
ctx->screen = twin_screen_create(
293-
width, height, NULL, fbdev_put_spans[tx->fb_var.bits_per_pixel / 8 - 2],
294-
ctx);
302+
fb_width, fb_height, NULL,
303+
fbdev_put_spans[tx->fb_var.bits_per_pixel / 8 - 2], ctx);
295304
if (!ctx->screen) {
296305
log_error("Failed to create screen");
297306
goto bail_fb_unmap;

src/window.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,19 @@ twin_window_t *twin_window_create(twin_screen_t *screen,
6363
width += left + right;
6464
height += top + bottom;
6565
#else
66-
/* No-WM: ignore position, clamp to screen, no decorations */
66+
/* No-WM: the single window always covers the entire screen
67+
* regardless of what the application requested. The screen
68+
* dimensions are authoritative -- they come from the backend
69+
* (hardware resolution for fbdev, window size for SDL, etc.).
70+
*/
6771
left = 0;
6872
top = 0;
6973
right = 0;
7074
bottom = 0;
7175
x = 0;
7276
y = 0;
73-
if (width > screen->width)
74-
width = screen->width;
75-
if (height > screen->height)
76-
height = screen->height;
77+
width = screen->width;
78+
height = screen->height;
7779
#endif
7880

7981
window->client.left = left;
@@ -156,14 +158,12 @@ void twin_window_configure(twin_window_t *window,
156158
#if defined(CONFIG_WINDOW_MANAGER)
157159
_twin_window_style_size(style, &border);
158160
#else
159-
/* No-WM: ignore position, clamp to screen, zero margins */
161+
/* No-WM: always match the screen provided by the backend. */
160162
border.left = border.right = border.top = border.bottom = 0;
161163
x = 0;
162164
y = 0;
163-
if (width > window->screen->width)
164-
width = window->screen->width;
165-
if (height > window->screen->height)
166-
height = window->screen->height;
165+
width = window->screen->width;
166+
height = window->screen->height;
167167
#endif
168168

169169
twin_pixmap_disable_update(window->pixmap);

0 commit comments

Comments
 (0)