diff --git a/src/view/view-impl.cpp b/src/view/view-impl.cpp index 672012f84..207875a1f 100644 --- a/src/view/view-impl.cpp +++ b/src/view/view-impl.cpp @@ -9,6 +9,8 @@ #include "wayfire/unstable/wlr-surface-node.hpp" #include "wayfire/view.hpp" #include "wayfire/output-layout.hpp" +#include "wayfire/window-manager.hpp" +#include "wayfire/workarea.hpp" #include "wayfire/workspace-set.hpp" #include #include @@ -437,3 +439,31 @@ void wf::fini_desktop_apis() fini_layer_shell(); // xwayland destroyed separately by core } + +void wf::adjust_view_pending_geometry_on_start_map(wf::toplevel_view_interface_t *self, + wf::geometry_t map_geometry_client, bool map_fs, bool map_maximized) +{ + if (map_fs) + { + self->toplevel()->pending().fullscreen = true; + wf::get_core().default_wm->fullscreen_request(self, self->get_output(), true); + } else if (map_maximized) + { + self->toplevel()->pending().tiled_edges = wf::TILED_EDGES_ALL; + if (self->get_output()) + { + self->toplevel()->pending().geometry = self->get_output()->workarea->get_workarea(); + } + } else + { + auto map_geometry = wf::expand_geometry_by_margins(map_geometry_client, + self->toplevel()->pending().margins); + + if (self->get_output()) + { + map_geometry = wf::clamp(map_geometry, self->get_output()->workarea->get_workarea()); + } + + self->toplevel()->pending().geometry = map_geometry; + } +} diff --git a/src/view/view-impl.hpp b/src/view/view-impl.hpp index 97cfd8987..2af07df6e 100644 --- a/src/view/view-impl.hpp +++ b/src/view/view-impl.hpp @@ -60,6 +60,8 @@ class view_interface_t::view_priv_impl void adjust_geometry_for_gravity(wf::toplevel_state_t& desired_state, wf::dimensions_t actual_size); void adjust_view_output_on_map(wf::toplevel_view_interface_t *self); +void adjust_view_pending_geometry_on_start_map(wf::toplevel_view_interface_t *self, + wf::geometry_t map_geometry_client, bool map_fs, bool map_maximized); /** Emit the map signal for the given view */ void init_xdg_shell(); diff --git a/src/view/xdg-shell/xdg-toplevel-view.cpp b/src/view/xdg-shell/xdg-toplevel-view.cpp index b69da63f5..32d94e31e 100644 --- a/src/view/xdg-shell/xdg-toplevel-view.cpp +++ b/src/view/xdg-shell/xdg-toplevel-view.cpp @@ -508,12 +508,14 @@ void wf::xdg_toplevel_view_t::start_map_tx() LOGC(VIEWS, "Start mapping ", self()); wlr_box box; wlr_xdg_surface_get_geometry(xdg_toplevel->base, &box); + auto margins = wtoplevel->pending().margins; + box.x = wtoplevel->pending().geometry.x + margins.left; + box.y = wtoplevel->pending().geometry.y + margins.top; wtoplevel->pending().mapped = true; - wtoplevel->pending().geometry.width = box.width + margins.left + margins.right; - wtoplevel->pending().geometry.height = box.height + margins.top + margins.bottom; priv->set_mapped_surface_contents(main_surface); + adjust_view_pending_geometry_on_start_map(this, box, pending_fullscreen(), pending_tiled_edges()); wf::get_core().tx_manager->schedule_object(wtoplevel); } diff --git a/src/view/xwayland/xwayland-toplevel-view.hpp b/src/view/xwayland/xwayland-toplevel-view.hpp index bf2352935..32b67084b 100644 --- a/src/view/xwayland/xwayland-toplevel-view.hpp +++ b/src/view/xwayland/xwayland-toplevel-view.hpp @@ -337,44 +337,27 @@ class wayfire_xwayland_view : public wf::toplevel_view_interface_t, public wayfi toplevel->set_main_surface(main_surface); toplevel->pending().mapped = true; - if (xw->fullscreen) - { - store_xw_geometry_unmapped(); - toplevel->pending().fullscreen = true; - if (get_output()) - { - toplevel->pending().geometry = get_output()->workarea->get_workarea(); - } + bool map_maximized = xw->maximized_horz || xw->maximized_vert; + bool map_fs = xw->fullscreen; - wf::get_core().default_wm->fullscreen_request({this}, get_output(), true); - } else if (xw->maximized_horz && xw->maximized_vert) + if (map_maximized || map_fs) { store_xw_geometry_unmapped(); - toplevel->pending().tiled_edges = wf::TILED_EDGES_ALL; - if (get_output()) - { - toplevel->pending().geometry = get_output()->workarea->get_workarea(); - } - } else - { - wf::geometry_t desired_geometry = { - xw->x, - xw->y, - xw->surface->current.width, - xw->surface->current.height - }; + } - if (get_output()) - { - desired_geometry = desired_geometry + -wf::origin(get_output()->get_layout_geometry()); - desired_geometry = - wf::expand_geometry_by_margins(desired_geometry, toplevel->pending().margins); - desired_geometry = wf::clamp(desired_geometry, get_output()->workarea->get_workarea()); - } + wf::geometry_t desired_geometry = { + xw->x, + xw->y, + xw->surface->current.width, + xw->surface->current.height + }; - toplevel->pending().geometry = desired_geometry; + if (get_output()) + { + desired_geometry = desired_geometry + -wf::origin(get_output()->get_layout_geometry()); } + wf::adjust_view_pending_geometry_on_start_map(this, desired_geometry, map_fs, map_maximized); wf::get_core().tx_manager->schedule_object(toplevel); }