@@ -1198,6 +1198,7 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
1198
1198
bool tiled = false;
1199
1199
bool suspended = false;
1200
1200
bool resizing = false;
1201
+ wind -> toplevel_constraints = 0 ;
1201
1202
1202
1203
static const enum libdecor_window_state tiled_states = (LIBDECOR_WINDOW_STATE_TILED_LEFT | LIBDECOR_WINDOW_STATE_TILED_RIGHT |
1203
1204
LIBDECOR_WINDOW_STATE_TILED_TOP | LIBDECOR_WINDOW_STATE_TILED_BOTTOM );
@@ -1213,8 +1214,20 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
1213
1214
#endif
1214
1215
#if SDL_LIBDECOR_CHECK_VERSION (0 , 3 , 0 )
1215
1216
resizing = (window_state & LIBDECOR_WINDOW_STATE_RESIZING ) != 0 ;
1217
+
1218
+ if (window_state & LIBDECOR_WINDOW_STATE_CONSTRAINED_LEFT ) {
1219
+ wind -> toplevel_constraints |= WAYLAND_TOPLEVEL_CONSTRAINED_LEFT ;
1220
+ }
1221
+ if (window_state & LIBDECOR_WINDOW_STATE_CONSTRAINED_RIGHT ) {
1222
+ wind -> toplevel_constraints |= WAYLAND_TOPLEVEL_CONSTRAINED_RIGHT ;
1223
+ }
1224
+ if (window_state & LIBDECOR_WINDOW_STATE_CONSTRAINED_TOP ) {
1225
+ wind -> toplevel_constraints |= WAYLAND_TOPLEVEL_CONSTRAINED_TOP ;
1226
+ }
1227
+ if (window_state & LIBDECOR_WINDOW_STATE_CONSTRAINED_BOTTOM ) {
1228
+ wind -> toplevel_constraints |= WAYLAND_TOPLEVEL_CONSTRAINED_BOTTOM ;
1229
+ }
1216
1230
#endif
1217
- // TODO: Toplevel constraint passthrough is waiting on upstream libdecor changes.
1218
1231
}
1219
1232
const bool floating = !(fullscreen || maximized || tiled );
1220
1233
@@ -1289,6 +1302,13 @@ static void decoration_frame_configure(struct libdecor_frame *frame,
1289
1302
if (floating ) {
1290
1303
width = window -> floating .w ;
1291
1304
height = window -> floating .h ;
1305
+
1306
+ // Clamp the window to the toplevel bounds, if any are set.
1307
+ if (wind -> shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE &&
1308
+ wind -> toplevel_bounds .width && wind -> toplevel_bounds .height ) {
1309
+ width = SDL_min (wind -> toplevel_bounds .width , width );
1310
+ height = SDL_min (wind -> toplevel_bounds .height , height );
1311
+ }
1292
1312
} else {
1293
1313
width = window -> windowed .w ;
1294
1314
height = window -> windowed .h ;
@@ -1451,11 +1471,25 @@ static void decoration_dismiss_popup(struct libdecor_frame *frame, const char *s
1451
1471
// NOP
1452
1472
}
1453
1473
1474
+ static void decoration_frame_bounds (struct libdecor_frame * frame , int width , int height , void * user_data )
1475
+ {
1476
+ SDL_WindowData * window = (SDL_WindowData * )user_data ;
1477
+ window -> toplevel_bounds .width = width ;
1478
+ window -> toplevel_bounds .height = height ;
1479
+ }
1480
+
1481
+ #if SDL_LIBDECOR_CHECK_VERSION (0 , 3 , 0 )
1482
+ #define FRAME_BOUNDS_FUNC_CAST (func ) func
1483
+ #else
1484
+ #define FRAME_BOUNDS_FUNC_CAST (func ) (void(*)(void))func
1485
+ #endif
1486
+
1454
1487
static struct libdecor_frame_interface libdecor_frame_interface = {
1455
1488
decoration_frame_configure ,
1456
1489
decoration_frame_close ,
1457
1490
decoration_frame_commit ,
1458
- decoration_dismiss_popup
1491
+ decoration_dismiss_popup ,
1492
+ FRAME_BOUNDS_FUNC_CAST (decoration_frame_bounds )
1459
1493
};
1460
1494
#endif
1461
1495
0 commit comments