@@ -39,8 +39,9 @@ void CXWM::handleCreate(xcb_create_notify_event_t* e) {
39
39
if (isWMWindow (e->window ))
40
40
return ;
41
41
42
- const auto XSURF = surfaces.emplace_back (SP<CXWaylandSurface>(new CXWaylandSurface (e->window , CBox{e->x , e->y , e->width , e->height }, e->override_redirect )));
43
- XSURF->self = XSURF;
42
+ const auto XSURF = surfaces.emplace_back (
43
+ SP<CXWaylandSurface>(new CXWaylandSurface (e->window , CBox{applyUnScale (e->x ), applyUnScale (e->y ), applyUnScale (e->width ), applyUnScale (e->height )}, e->override_redirect )));
44
+ XSURF->self = XSURF;
44
45
Debug::log (LOG, " [xwm] New XSurface at {:x} with xid of {}" , (uintptr_t )XSURF.get (), e->window );
45
46
46
47
const auto WINDOW = CWindow::create (XSURF);
@@ -70,9 +71,9 @@ void CXWM::handleConfigureRequest(xcb_configure_request_event_t* e) {
70
71
if (!(MASK & GEOMETRY))
71
72
return ;
72
73
73
- XSURF->events .configureRequest .emit (CBox{MASK & XCB_CONFIG_WINDOW_X ? e-> x : XSURF-> geometry . x , MASK & XCB_CONFIG_WINDOW_Y ? e-> y : XSURF-> geometry . y ,
74
- MASK & XCB_CONFIG_WINDOW_WIDTH ? e->width : XSURF->geometry .width ,
75
- MASK & XCB_CONFIG_WINDOW_HEIGHT ? e->height : XSURF->geometry .height });
74
+ XSURF->events .configureRequest .emit (
75
+ CBox{MASK & XCB_CONFIG_WINDOW_X ? applyUnScale (e-> x ) : XSURF-> geometry . x , MASK & XCB_CONFIG_WINDOW_Y ? applyUnScale ( e->y ) : XSURF->geometry .y ,
76
+ MASK & XCB_CONFIG_WINDOW_WIDTH ? applyUnScale (e-> width ) : XSURF-> geometry . width , MASK & XCB_CONFIG_WINDOW_HEIGHT ? applyUnScale ( e->height ) : XSURF->geometry .height });
76
77
}
77
78
78
79
void CXWM::handleConfigureNotify (xcb_configure_notify_event_t * e) {
@@ -81,10 +82,11 @@ void CXWM::handleConfigureNotify(xcb_configure_notify_event_t* e) {
81
82
if (!XSURF)
82
83
return ;
83
84
84
- if (XSURF->geometry == CBox{e->x , e->y , e->width , e->height })
85
+ const CBox geom = {applyUnScale (e->x ), applyUnScale (e->y ), applyUnScale (e->width ), applyUnScale (e->height )};
86
+ if (XSURF->geometry == geom)
85
87
return ;
86
88
87
- XSURF->geometry = {e-> x , e-> y , e-> width , e-> height } ;
89
+ XSURF->geometry = geom ;
88
90
updateOverrideRedirect (XSURF, e->override_redirect );
89
91
XSURF->events .setGeometry .emit ();
90
92
}
@@ -261,6 +263,17 @@ void CXWM::readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_
261
263
262
264
xcb_icccm_get_wm_size_hints_from_reply (XSURF->sizeHints .get (), reply);
263
265
266
+ XSURF->sizeHints ->x = applyUnScale (XSURF->sizeHints ->x );
267
+ XSURF->sizeHints ->y = applyUnScale (XSURF->sizeHints ->y );
268
+ XSURF->sizeHints ->width = applyUnScale (XSURF->sizeHints ->width );
269
+ XSURF->sizeHints ->height = applyUnScale (XSURF->sizeHints ->height );
270
+ XSURF->sizeHints ->min_width = applyUnScale (XSURF->sizeHints ->min_width );
271
+ XSURF->sizeHints ->min_height = applyUnScale (XSURF->sizeHints ->min_height );
272
+ XSURF->sizeHints ->max_width = applyUnScale (XSURF->sizeHints ->max_width );
273
+ XSURF->sizeHints ->max_height = applyUnScale (XSURF->sizeHints ->max_height );
274
+ XSURF->sizeHints ->base_width = applyUnScale (XSURF->sizeHints ->base_width );
275
+ XSURF->sizeHints ->base_height = applyUnScale (XSURF->sizeHints ->base_height );
276
+
264
277
const int32_t FLAGS = XSURF->sizeHints ->flags ;
265
278
const bool HASMIN = (FLAGS & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE);
266
279
const bool HASBASE = (FLAGS & XCB_ICCCM_SIZE_HINT_BASE_SIZE);
@@ -294,8 +307,20 @@ void CXWM::readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_
294
307
void CXWM::handlePropertyNotify (xcb_property_notify_event_t * e) {
295
308
const auto XSURF = windowForXID (e->window );
296
309
297
- if (!XSURF)
310
+ if (!XSURF) {
311
+ if (e->atom == HYPRATOMS[" _XWAYLAND_GLOBAL_OUTPUT_SCALE" ]) {
312
+ xcb_get_property_cookie_t cookie = xcb_get_property (connection, 0 , e->window , e->atom , XCB_ATOM_ANY, 0 , 2048 );
313
+ xcb_get_property_reply_t * reply = xcb_get_property_reply (connection, cookie, nullptr );
314
+ if (!reply) {
315
+ return ;
316
+ }
317
+ if (reply->type == XCB_ATOM_CARDINAL) {
318
+ scale = *(uint32_t *)xcb_get_property_value (reply);
319
+ }
320
+ free (reply);
321
+ }
298
322
return ;
323
+ }
299
324
300
325
xcb_get_property_cookie_t cookie = xcb_get_property (connection, 0 , XSURF->xID , e->atom , XCB_ATOM_ANY, 0 , 2048 );
301
326
xcb_get_property_reply_t * reply = xcb_get_property_reply (connection, cookie, nullptr );
@@ -1304,6 +1329,14 @@ SP<IDataOffer> CXWM::createX11DataOffer(SP<CWLSurfaceResource> surf, SP<IDataSou
1304
1329
return offer;
1305
1330
}
1306
1331
1332
+ double CXWM::applyScale (double val) {
1333
+ return std::floor (val * scale);
1334
+ }
1335
+
1336
+ double CXWM::applyUnScale (double val) {
1337
+ return std::ceil (val / scale);
1338
+ }
1339
+
1307
1340
void SXSelection::onSelection () {
1308
1341
if (g_pSeatManager->selection .currentSelection && g_pSeatManager->selection .currentSelection ->type () == DATA_SOURCE_TYPE_X11)
1309
1342
return ;
0 commit comments