@@ -40,8 +40,9 @@ void CXWM::handleCreate(xcb_create_notify_event_t* e) {
40
40
if (isWMWindow (e->window ))
41
41
return ;
42
42
43
- 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 )));
44
- XSURF->m_self = XSURF;
43
+ const auto XSURF = m_surfaces.emplace_back (
44
+ SP<CXWaylandSurface>(new CXWaylandSurface (e->window , CBox{applyUnScale (e->x ), applyUnScale (e->y ), applyUnScale (e->width ), applyUnScale (e->height )}, e->override_redirect )));
45
+ XSURF->m_self = XSURF;
45
46
Debug::log (LOG, " [xwm] New XSurface at {:x} with xid of {}" , (uintptr_t )XSURF.get (), e->window );
46
47
47
48
const auto WINDOW = CWindow::create (XSURF);
@@ -71,9 +72,9 @@ void CXWM::handleConfigureRequest(xcb_configure_request_event_t* e) {
71
72
if (!(MASK & GEOMETRY))
72
73
return ;
73
74
74
- 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 ,
75
- MASK & XCB_CONFIG_WINDOW_WIDTH ? e->width : XSURF->m_geometry .width ,
76
- MASK & XCB_CONFIG_WINDOW_HEIGHT ? e->height : XSURF->m_geometry .height });
75
+ XSURF->m_events .configureRequest .emit (CBox{
76
+ MASK & XCB_CONFIG_WINDOW_X ? applyUnScale (e-> x ) : XSURF-> m_geometry . x , MASK & XCB_CONFIG_WINDOW_Y ? applyUnScale ( e->y ) : XSURF->m_geometry .y ,
77
+ MASK & XCB_CONFIG_WINDOW_WIDTH ? applyUnScale (e-> width ) : XSURF-> m_geometry . width , MASK & XCB_CONFIG_WINDOW_HEIGHT ? applyUnScale ( e->height ) : XSURF->m_geometry .height });
77
78
}
78
79
79
80
void CXWM::handleConfigureNotify (xcb_configure_notify_event_t * e) {
@@ -82,10 +83,11 @@ void CXWM::handleConfigureNotify(xcb_configure_notify_event_t* e) {
82
83
if (!XSURF)
83
84
return ;
84
85
85
- if (XSURF->m_geometry == CBox{e->x , e->y , e->width , e->height })
86
+ const auto GEOM = CBox{applyUnScale (e->x ), applyUnScale (e->y ), applyUnScale (e->width ), applyUnScale (e->height )};
87
+ if (XSURF->m_geometry == GEOM)
86
88
return ;
87
89
88
- XSURF->m_geometry = {e-> x , e-> y , e-> width , e-> height } ;
90
+ XSURF->m_geometry = GEOM ;
89
91
updateOverrideRedirect (XSURF, e->override_redirect );
90
92
XSURF->m_events .setGeometry .emit ();
91
93
}
@@ -263,6 +265,17 @@ void CXWM::readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_
263
265
264
266
xcb_icccm_get_wm_size_hints_from_reply (XSURF->m_sizeHints .get (), reply);
265
267
268
+ XSURF->m_sizeHints ->x = applyUnScale (XSURF->m_sizeHints ->x );
269
+ XSURF->m_sizeHints ->y = applyUnScale (XSURF->m_sizeHints ->y );
270
+ XSURF->m_sizeHints ->width = applyUnScale (XSURF->m_sizeHints ->width );
271
+ XSURF->m_sizeHints ->height = applyUnScale (XSURF->m_sizeHints ->height );
272
+ XSURF->m_sizeHints ->min_width = applyUnScale (XSURF->m_sizeHints ->min_width );
273
+ XSURF->m_sizeHints ->min_height = applyUnScale (XSURF->m_sizeHints ->min_height );
274
+ XSURF->m_sizeHints ->max_width = applyUnScale (XSURF->m_sizeHints ->max_width );
275
+ XSURF->m_sizeHints ->max_height = applyUnScale (XSURF->m_sizeHints ->max_height );
276
+ XSURF->m_sizeHints ->base_width = applyUnScale (XSURF->m_sizeHints ->base_width );
277
+ XSURF->m_sizeHints ->base_height = applyUnScale (XSURF->m_sizeHints ->base_height );
278
+
266
279
const int32_t FLAGS = XSURF->m_sizeHints ->flags ;
267
280
const bool HASMIN = (FLAGS & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE);
268
281
const bool HASBASE = (FLAGS & XCB_ICCCM_SIZE_HINT_BASE_SIZE);
@@ -306,8 +319,20 @@ void CXWM::readProp(SP<CXWaylandSurface> XSURF, uint32_t atom, xcb_get_property_
306
319
void CXWM::handlePropertyNotify (xcb_property_notify_event_t * e) {
307
320
const auto XSURF = windowForXID (e->window );
308
321
309
- if (!XSURF)
322
+ if (!XSURF) {
323
+ if (e->atom == HYPRATOMS[" _XWAYLAND_GLOBAL_OUTPUT_SCALE" ]) {
324
+ xcb_get_property_cookie_t cookie = xcb_get_property (m_connection, 0 , e->window , e->atom , XCB_ATOM_ANY, 0 , 2048 );
325
+ xcb_get_property_reply_t * reply = xcb_get_property_reply (m_connection, cookie, nullptr );
326
+ if (!reply) {
327
+ return ;
328
+ }
329
+ if (reply->type == XCB_ATOM_CARDINAL) {
330
+ m_scale = *(uint32_t *)xcb_get_property_value (reply);
331
+ }
332
+ free (reply);
333
+ }
310
334
return ;
335
+ }
311
336
312
337
xcb_get_property_cookie_t cookie = xcb_get_property (m_connection, 0 , XSURF->m_xID , e->atom , XCB_ATOM_ANY, 0 , 2048 );
313
338
xcb_get_property_reply_t * reply = xcb_get_property_reply (m_connection, cookie, nullptr );
@@ -1331,6 +1356,18 @@ SP<IDataOffer> CXWM::createX11DataOffer(SP<CWLSurfaceResource> surf, SP<IDataSou
1331
1356
return offer;
1332
1357
}
1333
1358
1359
+ double CXWM::getScale () {
1360
+ return m_scale;
1361
+ }
1362
+
1363
+ double CXWM::applyScale (double val) {
1364
+ return std::floor (val * m_scale);
1365
+ }
1366
+
1367
+ double CXWM::applyUnScale (double val) {
1368
+ return std::ceil (val / m_scale);
1369
+ }
1370
+
1334
1371
void SXSelection::onSelection () {
1335
1372
if ((this == &g_pXWayland->m_wm ->m_clipboard && g_pSeatManager->m_selection .currentSelection && g_pSeatManager->m_selection .currentSelection ->type () == DATA_SOURCE_TYPE_X11) ||
1336
1373
(this == &g_pXWayland->m_wm ->m_primarySelection && g_pSeatManager->m_selection .currentPrimarySelection &&
0 commit comments