@@ -41,8 +41,9 @@ void CXWM::handleCreate(xcb_create_notify_event_t* e) {
41
41
if (isWMWindow (e->window ))
42
42
return ;
43
43
44
- const auto XSURF = m_surfaces.emplace_back (SP<CXWaylandSurface>(new CXWaylandSurface (e->window , CBox{e->x , e->y , e->width , e->height }, e->override_redirect )));
45
- XSURF->m_self = XSURF;
44
+ const auto XSURF = m_surfaces.emplace_back (
45
+ SP<CXWaylandSurface>(new CXWaylandSurface (e->window , CBox{applyUnScale (e->x ), applyUnScale (e->y ), applyUnScale (e->width ), applyUnScale (e->height )}, e->override_redirect )));
46
+ XSURF->m_self = XSURF;
46
47
Debug::log (LOG, " [xwm] New XSurface at {:x} with xid of {}" , (uintptr_t )XSURF.get (), e->window );
47
48
48
49
const auto WINDOW = CWindow::create (XSURF);
@@ -72,9 +73,9 @@ void CXWM::handleConfigureRequest(xcb_configure_request_event_t* e) {
72
73
if (!(MASK & GEOMETRY))
73
74
return ;
74
75
75
- XSURF->m_events .configureRequest .emit (CBox{MASK & XCB_CONFIG_WINDOW_X ? e-> x : XSURF-> m_geometry . x , MASK & XCB_CONFIG_WINDOW_Y ? e-> y : XSURF-> m_geometry . y ,
76
- MASK & XCB_CONFIG_WINDOW_WIDTH ? e->width : XSURF->m_geometry .width ,
77
- MASK & XCB_CONFIG_WINDOW_HEIGHT ? e->height : XSURF->m_geometry .height });
76
+ XSURF->m_events .configureRequest .emit (CBox{
77
+ MASK & XCB_CONFIG_WINDOW_X ? applyUnScale (e-> x ) : XSURF-> m_geometry . x , MASK & XCB_CONFIG_WINDOW_Y ? applyUnScale ( e->y ) : XSURF->m_geometry .y ,
78
+ MASK & XCB_CONFIG_WINDOW_WIDTH ? applyUnScale (e-> width ) : XSURF-> m_geometry . width , MASK & XCB_CONFIG_WINDOW_HEIGHT ? applyUnScale ( e->height ) : XSURF->m_geometry .height });
78
79
}
79
80
80
81
void CXWM::handleConfigureNotify (xcb_configure_notify_event_t * e) {
@@ -83,10 +84,11 @@ void CXWM::handleConfigureNotify(xcb_configure_notify_event_t* e) {
83
84
if (!XSURF)
84
85
return ;
85
86
86
- if (XSURF->m_geometry == CBox{e->x , e->y , e->width , e->height })
87
+ const auto GEOM = CBox{applyUnScale (e->x ), applyUnScale (e->y ), applyUnScale (e->width ), applyUnScale (e->height )};
88
+ if (XSURF->m_geometry == GEOM)
87
89
return ;
88
90
89
- XSURF->m_geometry = {e-> x , e-> y , e-> width , e-> height } ;
91
+ XSURF->m_geometry = GEOM ;
90
92
updateOverrideRedirect (XSURF, e->override_redirect );
91
93
XSURF->m_events .setGeometry .emit ();
92
94
}
@@ -273,6 +275,17 @@ void CXWM::readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_
273
275
std::memset (XSURF->m_sizeHints .get (), 0 , sizeof (xcb_size_hints_t ));
274
276
xcb_icccm_get_wm_size_hints_from_reply (XSURF->m_sizeHints .get (), reply);
275
277
278
+ XSURF->m_sizeHints ->x = applyUnScale (XSURF->m_sizeHints ->x );
279
+ XSURF->m_sizeHints ->y = applyUnScale (XSURF->m_sizeHints ->y );
280
+ XSURF->m_sizeHints ->width = applyUnScale (XSURF->m_sizeHints ->width );
281
+ XSURF->m_sizeHints ->height = applyUnScale (XSURF->m_sizeHints ->height );
282
+ XSURF->m_sizeHints ->min_width = applyUnScale (XSURF->m_sizeHints ->min_width );
283
+ XSURF->m_sizeHints ->min_height = applyUnScale (XSURF->m_sizeHints ->min_height );
284
+ XSURF->m_sizeHints ->max_width = applyUnScale (XSURF->m_sizeHints ->max_width );
285
+ XSURF->m_sizeHints ->max_height = applyUnScale (XSURF->m_sizeHints ->max_height );
286
+ XSURF->m_sizeHints ->base_width = applyUnScale (XSURF->m_sizeHints ->base_width );
287
+ XSURF->m_sizeHints ->base_height = applyUnScale (XSURF->m_sizeHints ->base_height );
288
+
276
289
const int32_t FLAGS = XSURF->m_sizeHints ->flags ;
277
290
const bool HASMIN = FLAGS & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE;
278
291
const bool HASBASE = FLAGS & XCB_ICCCM_SIZE_HINT_BASE_SIZE;
@@ -328,8 +341,20 @@ void CXWM::readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_
328
341
void CXWM::handlePropertyNotify (xcb_property_notify_event_t * e) {
329
342
const auto XSURF = windowForXID (e->window );
330
343
331
- if (!XSURF)
344
+ if (!XSURF) {
345
+ if (e->atom == HYPRATOMS[" _XWAYLAND_GLOBAL_OUTPUT_SCALE" ]) {
346
+ xcb_get_property_cookie_t cookie = xcb_get_property (m_connection, 0 , e->window , e->atom , XCB_ATOM_ANY, 0 , 2048 );
347
+ xcb_get_property_reply_t * reply = xcb_get_property_reply (m_connection, cookie, nullptr );
348
+ if (!reply) {
349
+ return ;
350
+ }
351
+ if (reply->type == XCB_ATOM_CARDINAL) {
352
+ m_scale = *(uint32_t *)xcb_get_property_value (reply);
353
+ }
354
+ free (reply);
355
+ }
332
356
return ;
357
+ }
333
358
334
359
xcb_get_property_cookie_t cookie = xcb_get_property (m_connection, 0 , XSURF->m_xID , e->atom , XCB_ATOM_ANY, 0 , 2048 );
335
360
xcb_get_property_reply_t * reply = xcb_get_property_reply (m_connection, cookie, nullptr );
@@ -1355,6 +1380,18 @@ SP<IDataOffer> CXWM::createX11DataOffer(SP<CWLSurfaceResource> surf, SP<IDataSou
1355
1380
return offer;
1356
1381
}
1357
1382
1383
+ double CXWM::getScale () {
1384
+ return m_scale;
1385
+ }
1386
+
1387
+ double CXWM::applyScale (double val) {
1388
+ return std::floor (val * m_scale);
1389
+ }
1390
+
1391
+ double CXWM::applyUnScale (double val) {
1392
+ return std::ceil (val / m_scale);
1393
+ }
1394
+
1358
1395
void SXSelection::onSelection () {
1359
1396
const bool isClipboard = this == &g_pXWayland->m_wm ->m_clipboard ;
1360
1397
const bool isPrimary = this == &g_pXWayland->m_wm ->m_primarySelection ;
0 commit comments