Lines 65-70
static constexpr size_t base_dpi = 96;
Link Here
|
65 |
struct WGL_LibDecor_Window { |
65 |
struct WGL_LibDecor_Window { |
66 |
libdecor_frame *frame = nullptr; |
66 |
libdecor_frame *frame = nullptr; |
67 |
|
67 |
|
|
|
68 |
/** |
69 |
* Store the last size applied from #libdecor_frame_interface::configure |
70 |
* This is meant to be equivalent of calling: |
71 |
* `libdecor_frame_get_content_width(frame)` |
72 |
* `libdecor_frame_get_content_height(frame)` |
73 |
* However these functions are only available via the plugin API, |
74 |
* so they need to be stored somewhere. |
75 |
*/ |
76 |
struct { |
77 |
int32_t size[2] = {0, 0}; |
78 |
} applied; |
79 |
|
68 |
/** |
80 |
/** |
69 |
* Used at startup to set the initial window size |
81 |
* Used at startup to set the initial window size |
70 |
* (before fractional scale information is available). |
82 |
* (before fractional scale information is available). |
Lines 73-78
struct WGL_LibDecor_Window {
Link Here
|
73 |
|
85 |
|
74 |
/** The window has been configured (see #xdg_surface_ack_configure). */ |
86 |
/** The window has been configured (see #xdg_surface_ack_configure). */ |
75 |
bool initial_configure_seen = false; |
87 |
bool initial_configure_seen = false; |
|
|
88 |
/** The window size has been configured. */ |
89 |
bool initial_configure_seen_with_size = false; |
76 |
/** The window state has been configured. */ |
90 |
/** The window state has been configured. */ |
77 |
bool initial_state_seen = false; |
91 |
bool initial_state_seen = false; |
78 |
}; |
92 |
}; |
Lines 1153-1164
static void libdecor_frame_handle_configure(libdecor_frame *frame,
Link Here
|
1153 |
GWL_WindowFrame *frame_pending = &static_cast<GWL_Window *>(data)->frame_pending; |
1167 |
GWL_WindowFrame *frame_pending = &static_cast<GWL_Window *>(data)->frame_pending; |
1154 |
|
1168 |
|
1155 |
/* Set the size. */ |
1169 |
/* Set the size. */ |
1156 |
int size_decor[2]{ |
|
|
1157 |
libdecor_frame_get_content_width(frame), |
1158 |
libdecor_frame_get_content_height(frame), |
1159 |
}; |
1160 |
int size_next[2] = {0, 0}; |
1170 |
int size_next[2] = {0, 0}; |
1161 |
bool has_size = false; |
1171 |
bool has_size = false; |
|
|
1172 |
|
1173 |
/* Keep track the current size of window decorations (last set by this function). */ |
1174 |
int size_decor[2] = {0, 0}; |
1175 |
|
1176 |
{ |
1177 |
const GWL_Window *win = static_cast<GWL_Window *>(data); |
1178 |
const WGL_LibDecor_Window &decor = *win->libdecor; |
1179 |
if (decor.initial_configure_seen_with_size) { |
1180 |
size_decor[0] = decor.applied.size[0]; |
1181 |
size_decor[1] = decor.applied.size[1]; |
1182 |
} |
1183 |
} |
1184 |
|
1162 |
{ |
1185 |
{ |
1163 |
GWL_Window *win = static_cast<GWL_Window *>(data); |
1186 |
GWL_Window *win = static_cast<GWL_Window *>(data); |
1164 |
const int fractional_scale = win->frame.fractional_scale ? |
1187 |
const int fractional_scale = win->frame.fractional_scale ? |
Lines 1259-1270
static void libdecor_frame_handle_configure(libdecor_frame *frame,
Link Here
|
1259 |
GWL_Window *win = static_cast<GWL_Window *>(data); |
1282 |
GWL_Window *win = static_cast<GWL_Window *>(data); |
1260 |
WGL_LibDecor_Window &decor = *win->libdecor; |
1283 |
WGL_LibDecor_Window &decor = *win->libdecor; |
1261 |
if (has_size == false) { |
1284 |
if (has_size == false) { |
|
|
1285 |
/* Keep the current decor size. */ |
1262 |
size_next[0] = size_decor[0]; |
1286 |
size_next[0] = size_decor[0]; |
1263 |
size_next[1] = size_decor[1]; |
1287 |
size_next[1] = size_decor[1]; |
1264 |
} |
1288 |
} |
1265 |
libdecor_state *state = libdecor_state_new(UNPACK2(size_next)); |
1289 |
else { |
1266 |
libdecor_frame_commit(frame, state, configuration); |
1290 |
/* Store the new size for later reuse. */ |
1267 |
libdecor_state_free(state); |
1291 |
decor.applied.size[0] = size_next[0]; |
|
|
1292 |
decor.applied.size[1] = size_next[1]; |
1293 |
} |
1294 |
|
1295 |
if (size_next[0] && size_next[1]) { |
1296 |
libdecor_state *state = libdecor_state_new(UNPACK2(size_next)); |
1297 |
libdecor_frame_commit(frame, state, configuration); |
1298 |
libdecor_state_free(state); |
1299 |
} |
1268 |
|
1300 |
|
1269 |
/* Only ever use this once, after initial creation: |
1301 |
/* Only ever use this once, after initial creation: |
1270 |
* #wp_fractional_scale_v1_listener::preferred_scale provides fractional scaling values. */ |
1302 |
* #wp_fractional_scale_v1_listener::preferred_scale provides fractional scaling values. */ |
Lines 1278-1283
static void libdecor_frame_handle_configure(libdecor_frame *frame,
Link Here
|
1278 |
decor.initial_state_seen = true; |
1310 |
decor.initial_state_seen = true; |
1279 |
} |
1311 |
} |
1280 |
} |
1312 |
} |
|
|
1313 |
if (decor.initial_configure_seen_with_size == false) { |
1314 |
if (is_main_thread) { |
1315 |
if (size_next[0] && size_next[1]) { |
1316 |
decor.initial_configure_seen_with_size = true; |
1317 |
} |
1318 |
} |
1319 |
} |
1281 |
} |
1320 |
} |
1282 |
} |
1321 |
} |
1283 |
|
1322 |
|