Revert "Fix #113059: file selector shrinks on each display under KDE"

This reverts commit 85e2dd66a0.

Remove the hack in favor of a different fix.
This commit is contained in:
Campbell Barton 2023-12-01 14:08:00 +11:00
parent d304ba7906
commit aba3fad33c
4 changed files with 17 additions and 90 deletions

View File

@ -1133,9 +1133,6 @@ struct GWL_Display {
#ifdef WITH_GHOST_WAYLAND_LIBDECOR
GWL_LibDecor_System *libdecor = nullptr;
bool libdecor_required = false;
#endif
#ifdef USE_XDG_INIT_WINDOW_SIZE_HACK
bool xdg_decor_ignore_initial_window_size = false;
#endif
GWL_XDG_Decor_System *xdg_decor = nullptr;
@ -6031,18 +6028,11 @@ static void global_handle_add(void *data,
else {
/* Not found. */
#ifdef USE_GNOME_NEEDS_LIBDECOR_HACK
/* `gtk_shell1` at time of writing. */
if (STRPREFIX(interface, "gtk_shell")) {
if (STRPREFIX(interface, "gtk_shell")) { /* `gtk_shell1` at time of writing. */
/* Only require `libdecor` when built with X11 support,
* otherwise there is nothing to fall back on. */
display->libdecor_required = true;
}
#endif
#ifdef USE_XDG_INIT_WINDOW_SIZE_HACK
/* `org_kde_plasma_shell` at time of writing. */
if (STRPREFIX(interface, "org_kde_plasma_shell")) {
display->xdg_decor_ignore_initial_window_size = true;
}
#endif
}
@ -7674,13 +7664,6 @@ zxdg_decoration_manager_v1 *GHOST_SystemWayland::xdg_decor_manager_get()
return display_->xdg_decor->manager;
}
#ifdef USE_XDG_INIT_WINDOW_SIZE_HACK
bool GHOST_SystemWayland::xdg_decor_needs_window_size_hack() const
{
return display_->xdg_decor_ignore_initial_window_size;
}
#endif
/* End `xdg_decor`. */
const std::vector<GWL_Output *> &GHOST_SystemWayland::outputs_get() const
@ -7688,20 +7671,6 @@ const std::vector<GWL_Output *> &GHOST_SystemWayland::outputs_get() const
return display_->outputs;
}
const GWL_Output *GHOST_SystemWayland::outputs_get_max_native_size() const
{
uint64_t area_best = 0;
const GWL_Output *output_best = nullptr;
for (const GWL_Output *output : display_->outputs) {
const uint64_t area_test = (uint64_t)output->size_native[0] * (uint64_t)output->size_native[1];
if (output_best == nullptr || area_best < area_test) {
output_best = output;
area_best = area_test;
}
}
return output_best;
}
wl_shm *GHOST_SystemWayland::wl_shm_get() const
{
return display_->wl.shm;

View File

@ -230,14 +230,9 @@ class GHOST_SystemWayland : public GHOST_System {
#endif
struct xdg_wm_base *xdg_decor_shell_get();
struct zxdg_decoration_manager_v1 *xdg_decor_manager_get();
#ifdef USE_XDG_INIT_WINDOW_SIZE_HACK
bool xdg_decor_needs_window_size_hack() const;
#endif
/* End `xdg_decor`. */
const std::vector<GWL_Output *> &outputs_get() const;
/** Return the output with the largest pixel-area. */
const GWL_Output *outputs_get_max_native_size() const;
struct wl_shm *wl_shm_get() const;

View File

@ -103,9 +103,6 @@ struct WGL_XDG_Decor_Window {
/** The window has been configured (see #xdg_surface_ack_configure). */
bool initial_configure_seen = false;
#ifdef USE_XDG_INIT_WINDOW_SIZE_HACK
bool initial_configure_seen_with_size = false;
#endif
};
static void gwl_xdg_decor_window_destroy(WGL_XDG_Decor_Window *decor)
@ -991,8 +988,11 @@ static int outputs_uniform_scale_or_default(const std::vector<GWL_Output *> &out
static CLG_LogRef LOG_WL_XDG_TOPLEVEL = {"ghost.wl.handle.xdg_toplevel"};
#define LOG (&LOG_WL_XDG_TOPLEVEL)
static void xdg_toplevel_handle_configure(
void *data, xdg_toplevel * /*xdg_toplevel*/, int32_t width, int32_t height, wl_array *states)
static void xdg_toplevel_handle_configure(void *data,
xdg_toplevel * /*xdg_toplevel*/,
const int32_t width,
const int32_t height,
wl_array *states)
{
/* TODO: log `states`, not urgent. */
CLOG_INFO(LOG, 2, "configure (size=[%d, %d])", width, height);
@ -1003,6 +1003,17 @@ static void xdg_toplevel_handle_configure(
std::lock_guard lock_frame_guard{win->frame_pending_mutex};
#endif
const int32_t size[2] = {width, height};
for (int i = 0; i < 2; i++) {
if (size[i] == 0) {
/* Values may be zero, in this case the client should choose. */
continue;
}
win->frame_pending.size[i] = win->frame.fractional_scale ?
gwl_window_fractional_to_viewport_round(win->frame, size[i]) :
(size[i] * win->frame.buffer_scale);
}
win->frame_pending.is_maximised = false;
win->frame_pending.is_fullscreen = false;
win->frame_pending.is_active = false;
@ -1023,46 +1034,6 @@ static void xdg_toplevel_handle_configure(
break;
}
}
#ifdef USE_XDG_INIT_WINDOW_SIZE_HACK
if (width || height) {
WGL_XDG_Decor_Window &decor = *win->xdg_decor;
if (decor.initial_configure_seen_with_size == false) {
if (win->ghost_system->xdg_decor_needs_window_size_hack() &&
(decor.mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE) &&
(win->frame_pending.is_maximised == false &&
win->frame_pending.is_fullscreen == false) &&
/* Account for the initial size being smaller. */
((width <= win->frame.size[0]) && (height <= win->frame.size[1])))
{
/* Fail safe, check the window is *not* larger than all available outputs
* as this could cause files saved on other peoples systems to create
* unreasonably large windows. */
const GWL_Output *output_big = win->ghost_system->outputs_get_max_native_size();
if (output_big &&
((output_big->size_native[0] < width) || (output_big->size_native[1] < height))) {
/* Pass, the window exceeds the size of the largest output, ignore initial size. */
}
else {
width = win->frame.size[0];
height = win->frame.size[1];
}
}
decor.initial_configure_seen_with_size = true;
}
}
#endif /* USE_XDG_INIT_WINDOW_SIZE_HACK */
const int32_t size[2] = {width, height};
for (int i = 0; i < 2; i++) {
if (size[i] == 0) {
/* Values may be zero, in this case the client should choose. */
continue;
}
win->frame_pending.size[i] = win->frame.fractional_scale ?
gwl_window_fractional_to_viewport_round(win->frame, size[i]) :
(size[i] * win->frame.buffer_scale);
}
}
static void xdg_toplevel_handle_close(void *data, xdg_toplevel * /*xdg_toplevel*/)

View File

@ -54,14 +54,6 @@
*/
#define USE_EVENT_BACKGROUND_THREAD
/**
* Hack for KDE where the initial window size includes window decorations (title-bar, borders etc),
* making the usable region smaller than requested. As the size of decorations is unknown:
* account for this by ignoring the initial size and using the size requested from GHOST instead
* (with some exceptions & sanity checks for overly large windows), see: #113059.
*/
#define USE_XDG_INIT_WINDOW_SIZE_HACK
class GHOST_SystemWayland;
struct GWL_Output;