Skip to content

Commit

Permalink
Simplifying fullscreen checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkae committed Feb 12, 2025
1 parent 546bbae commit 1191f1e
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 27 deletions.
13 changes: 6 additions & 7 deletions src/leaf_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void LeafContainer::set_parent(std::shared_ptr<ParentContainer> const& in_parent

miral::WindowSpecification spec;
spec.depth_layer() = get_depth_layer(
window_controller->is_fullscreen(window_),
is_fullscreen(),
in_parent->anchored());
window_controller->modify(window_, spec);
}
Expand Down Expand Up @@ -227,7 +227,7 @@ geom::Rectangle LeafContainer::get_visible_area() const

void LeafContainer::constrain()
{
if (window_controller->is_fullscreen(window_) || is_dragging_)
if (is_fullscreen() || is_dragging_)
window_controller->noclip(window_);
else
window_controller->clip(window_, get_visible_area());
Expand Down Expand Up @@ -265,7 +265,7 @@ void LeafContainer::handle_modify(miral::WindowSpecification const& modification
{
state = mods.state().value();
mods.depth_layer() = get_depth_layer(
window_helpers::is_window_fullscreen(mods.state().value()),
mods.state().value() == mir_window_state_fullscreen,
parent.lock()->anchored());

if (mods.state().value() == mir_window_state_restored)
Expand Down Expand Up @@ -451,7 +451,7 @@ void LeafContainer::hide()

bool LeafContainer::toggle_fullscreen()
{
if (window_controller->is_fullscreen(window_))
if (is_fullscreen())
{
next_state = mir_window_state_restored;
next_logical_area = get_logical_area();
Expand Down Expand Up @@ -498,7 +498,7 @@ void LeafContainer::on_move_to(geom::Point const&)

bool LeafContainer::is_fullscreen() const
{
return window_controller->is_fullscreen(window_);
return window_controller->get_state(window_) == mir_window_state_fullscreen;
}

void LeafContainer::commit_changes()
Expand All @@ -522,7 +522,7 @@ void LeafContainer::commit_changes()
auto previous = get_visible_area();
logical_area = next_logical_area.value();
next_logical_area.reset();
if (!window_controller->is_fullscreen(window_))
if (!is_fullscreen())
{
auto next_visible_area = get_visible_area();
if (is_dragging_ && next_visible_area.top_left != dragged_position)
Expand Down Expand Up @@ -883,7 +883,6 @@ MirDepthLayer LeafContainer::get_depth_layer(bool is_fullscreen, bool is_anchore
return !is_fullscreen ? mir_depth_layer_above : mir_depth_layer_application;
}


nlohmann::json LeafContainer::to_json(bool is_workspace_visible) const
{
auto const app = window_.application();
Expand Down
1 change: 0 additions & 1 deletion src/window_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class Container;
class WindowController
{
public:
virtual bool is_fullscreen(miral::Window const&) = 0;
virtual void set_rectangle(miral::Window const&, geom::Rectangle const&, geom::Rectangle const&, bool with_animations = true) = 0;
virtual MirWindowState get_state(miral::Window const&) = 0;
virtual void change_state(miral::Window const&, MirWindowState state) = 0;
Expand Down
11 changes: 0 additions & 11 deletions src/window_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define MIR_LOG_COMPONENT "window_helpers"

#include "window_helpers.h"
#include "container.h"
#include "leaf_container.h"

#include <mir/log.h>

bool miracle::window_helpers::is_window_fullscreen(MirWindowState state)
{
return state == mir_window_state_fullscreen
|| state == mir_window_state_maximized
|| state == mir_window_state_horizmaximized
|| state == mir_window_state_vertmaximized;
}

miral::WindowSpecification miracle::window_helpers::copy_from(miral::WindowInfo const& info)
{
miral::WindowSpecification spec;
Expand Down
1 change: 0 additions & 1 deletion src/window_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class LeafContainer;

namespace window_helpers
{
bool is_window_fullscreen(MirWindowState state);
miral::WindowSpecification copy_from(miral::WindowInfo const&);
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/window_manager_tools_window_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ void WindowManagerToolsWindowController::open(miral::Window const& window)
animator->append(animation);
}

bool WindowManagerToolsWindowController::is_fullscreen(miral::Window const& window)
{
auto& info = tools.info_for(window);
return window_helpers::is_window_fullscreen(info.state());
}

void WindowManagerToolsWindowController::set_rectangle(
miral::Window const& window, geom::Rectangle const& from, geom::Rectangle const& to, bool with_animations)
{
Expand Down
1 change: 0 additions & 1 deletion src/window_manager_tools_window_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class WindowManagerToolsWindowController : public WindowController
std::shared_ptr<mir::ServerActionQueue> const& server_action_queue,
Policy* policy);
void open(miral::Window const&) override;
bool is_fullscreen(miral::Window const&) override;
void set_rectangle(miral::Window const&, geom::Rectangle const&, geom::Rectangle const&, bool with_animations = true) override;
MirWindowState get_state(miral::Window const&) override;
void change_state(miral::Window const&, MirWindowState state) override;
Expand Down

0 comments on commit 1191f1e

Please sign in to comment.