Skip to content

Commit

Permalink
Merge branch 'main' into feature/mirtest-internal-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkae committed Jan 17, 2025
2 parents 63c8c8a + 835f5fb commit c4afaf4
Show file tree
Hide file tree
Showing 27 changed files with 549 additions and 356 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/spread.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ jobs:
TASKS+='"lxd:alpine-3.19:spread/build/alpine:amd64"
"lxd:alpine-3.20:spread/build/alpine:amd64"
"lxd:alpine-3.21:spread/build/alpine:amd64"
"lxd:alpine-edge:spread/build/alpine:amd64"
"lxd:ubuntu-24.04:spread/build/sbuild:debian_sid"
"lxd:ubuntu-24.04:spread/build/sbuild:ubuntu"
"lxd:ubuntu-24.04:spread/build/sbuild:ubuntu_oracular"
"lxd:ubuntu-24.04:spread/build/sbuild:ubuntu_arm64"
"lxd:ubuntu-24.04:spread/build/sbuild:ubuntu_armhf"
"lxd:ubuntu-24.04:spread/build/ubuntu:clang"
"lxd:fedora-39:spread/build/fedora:amd64"
"lxd:fedora-40:spread/build/fedora:amd64"
"lxd:fedora-rawhide:spread/build/fedora:amd64"
"lxd:ubuntu-24.04:spread/build/sbuild:ubuntu_devel"
Expand Down
2 changes: 1 addition & 1 deletion spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ backends:
systems:
- alpine-3.19
- alpine-3.20
- alpine-3.21
- alpine-edge
- ubuntu-24.04
- fedora-39
- fedora-40
- fedora-rawhide:
image: images:fedora/40
Expand Down
28 changes: 0 additions & 28 deletions src/include/server/mir/shell/decoration.h

This file was deleted.

5 changes: 1 addition & 4 deletions src/miral/basic_window_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,6 @@ void miral::BasicWindowManager::refocus(
if (hint && select_active_window(hint))
return;

if (can_activate_window_for_session_in_workspace(application, workspaces_containing_window))
return;

// Try to activate to recently active window of any application in a shared workspace
{
miral::Window new_focus;
Expand Down Expand Up @@ -2993,4 +2990,4 @@ void miral::BasicWindowManager::move_cursor_to(mir::geometry::PointF point)
sink->handle_input(std::move(event));
});
});
}
}
2 changes: 1 addition & 1 deletion src/platform/graphics/egl_buffer_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class mg::EGLBufferCopier::Impl
~Impl()
{
// Ensure EGL resources are cleaned up in the right context
egl_delegate->spawn([state = state]() mutable { state = nullptr; });
egl_delegate->spawn([state = std::move(state)]() mutable { state = nullptr; });
}

auto blit(EGLImage from, EGLImage to, geometry::Size size) -> std::optional<mir::Fd>
Expand Down
6 changes: 5 additions & 1 deletion src/platforms/atomic-kms/server/kms/quirks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,12 @@ class mga::Quirks::Impl
*
* At least as of drivers ≤ version 550, the NVIDIA atomic implementation is buggy in a way that prevents
* Mir from working. Quirk off atomic-kms on NVIDIA.
*
* Simple-framebuffer should be evicted before Mir even gets there.
* https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2084046
* https://github.com/canonical/mir/issues/3710
*/
std::unordered_set<std::string> drivers_to_skip = { "nvidia", "ast" };
std::unordered_set<std::string> drivers_to_skip = { "nvidia", "ast", "simple-framebuffer"};
std::unordered_set<std::string> devnodes_to_skip;
// We know this is currently useful for virtio_gpu, vc4-drm and v3d
std::unordered_set<std::string> skip_modesetting_support = { "virtio_gpu", "vc4-drm", "v3d" };
Expand Down
6 changes: 5 additions & 1 deletion src/platforms/gbm-kms/server/kms/quirks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,12 @@ class mgg::Quirks::Impl
*
* At least as of drivers ≤ version 550, the NVIDIA gbm implementation is buggy in a way that prevents
* Mir from working. Quirk off gbm-kms on NVIDIA.
*
* Simple-framebuffer should be evicted before Mir even gets there.
* https://bugs.launchpad.net/ubuntu/+source/linux/+bug/2084046
* https://github.com/canonical/mir/issues/3710
*/
std::unordered_set<std::string> drivers_to_skip = { "nvidia", "ast" };
std::unordered_set<std::string> drivers_to_skip = { "nvidia", "ast", "simple-framebuffer"};
std::unordered_set<std::string> devnodes_to_skip;
// We know this is currently useful for virtio_gpu, vc4-drm and v3d
std::unordered_set<std::string> skip_modesetting_support = { "virtio_gpu", "vc4-drm", "v3d" };
Expand Down
1 change: 1 addition & 0 deletions src/server/frontend_wayland/text_input_v3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ mf::TextInputV3::TextInputV3(
mf::TextInputV3::~TextInputV3()
{
seat.remove_focus_listener(client, this);
ctx->device_registry->remove_device(keyboard_device);
ctx->text_input_hub->deactivate_handler(handler);
}

Expand Down
5 changes: 2 additions & 3 deletions src/server/shell/abstract_shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

#include "mir/shell/abstract_shell.h"

#include "mir/shell/decoration.h"
#include "mir/shell/input_targeter.h"
#include "mir/shell/shell_report.h"
#include "mir/shell/surface_specification.h"
Expand Down Expand Up @@ -233,7 +232,7 @@ auto msh::AbstractShell::create_surface(
if (wm_visible_spec.server_side_decorated.value_or(false) && wm_visible_spec.width.is_set() && wm_visible_spec.height.is_set())
{
geom::Size const content_size{wm_visible_spec.width.value(), wm_visible_spec.height.value()};
auto const size = decoration::compute_size_with_decorations(
auto const size = decoration_manager->compute_size_with_decorations(
content_size,
wm_visible_spec.type.value(),
wm_visible_spec.state.value());
Expand Down Expand Up @@ -302,7 +301,7 @@ void msh::AbstractShell::modify_surface(std::shared_ptr<scene::Session> const& s
wm_relevant_mods.height = content_size.height;

// When adding decorations we need to resize the window for WM
window_size = decoration::compute_size_with_decorations(
window_size = decoration_manager->compute_size_with_decorations(
content_size,
modifications.type.value_or(surface->type()),
modifications.state.value_or(surface->state()));
Expand Down
3 changes: 2 additions & 1 deletion src/server/shell/decoration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ set(
basic_decoration.h basic_decoration.cpp
window.h window.cpp
input.h input.cpp
renderer.h renderer.cpp renderer_default.cpp
renderer.h renderer.cpp
decoration_strategy.h decoration_strategy.cpp
)

add_library(
Expand Down
45 changes: 15 additions & 30 deletions src/server/shell/decoration/basic_decoration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,6 @@ namespace geom = mir::geometry;
namespace msh = mir::shell;
namespace msd = mir::shell::decoration;

namespace mir::shell::decoration
{
// See src/server/shell/decoration/window.h for a full description of each property
StaticGeometry const default_geometry {
geom::Height{24}, // titlebar_height
geom::Width{6}, // side_border_width
geom::Height{6}, // bottom_border_height
geom::Size{16, 16}, // resize_corner_input_size
geom::Width{24}, // button_width
geom::Width{6}, // padding_between_buttons
geom::Height{14}, // title_font_height
geom::Point{8, 2}, // title_font_top_left
geom::Displacement{5, 5}, // icon_padding
geom::Width{1}, // detail_line_width
};
}

namespace
{
template<typename OBJ>
Expand Down Expand Up @@ -146,37 +129,30 @@ msd::BasicDecoration::BufferStreams::~BufferStreams()
session->destroy_buffer_stream(bottom_border);
}

auto msd::BasicDecoration::BufferStreams::create_buffer_stream() -> std::shared_ptr<mc::BufferStream>
{
auto const stream = session->create_buffer_stream(mg::BufferProperties{
geom::Size{1, 1},
buffer_format,
mg::BufferUsage::software});
return stream;
}

msd::BasicDecoration::BasicDecoration(
std::shared_ptr<msh::Shell> const& shell,
std::shared_ptr<mg::GraphicBufferAllocator> const& buffer_allocator,
std::shared_ptr<Executor> const& executor,
std::shared_ptr<input::CursorImages> const& cursor_images,
std::shared_ptr<ms::Surface> const& window_surface)
std::shared_ptr<ms::Surface> const& window_surface,
std::shared_ptr<DecorationStrategy> decoration_strategy)
: threadsafe_self{std::make_shared<ThreadsafeAccess<BasicDecoration>>(executor)},
static_geometry{std::make_shared<StaticGeometry>(default_geometry)},
decoration_strategy{decoration_strategy},
static_geometry{decoration_strategy->static_geometry()},
shell{shell},
buffer_allocator{buffer_allocator},
cursor_images{cursor_images},
session{window_surface->session().lock()},
buffer_streams{std::make_unique<BufferStreams>(session, static_geometry->buffer_format)},
renderer{std::make_unique<Renderer>(buffer_allocator, RendererStrategy::default_strategy(static_geometry))},
renderer{std::make_unique<Renderer>(buffer_allocator, decoration_strategy->render_strategy())},
window_surface{window_surface},
decoration_surface{create_surface()},
window_state{new_window_state()},
window_surface_observer_manager{std::make_unique<WindowSurfaceObserverManager>(
window_surface,
threadsafe_self)},
input_manager{std::make_unique<InputManager>(
static_geometry,
decoration_strategy,
decoration_surface,
*window_state,
threadsafe_self)},
Expand All @@ -194,6 +170,15 @@ msd::BasicDecoration::BasicDecoration(
threadsafe_self->initialize(this);
}

auto msd::BasicDecoration::BufferStreams::create_buffer_stream() -> std::shared_ptr<mc::BufferStream>
{
auto const stream = session->create_buffer_stream(mg::BufferProperties{
geom::Size{1, 1},
buffer_format,
mg::BufferUsage::software});
return stream;
}

msd::BasicDecoration::~BasicDecoration()
{
threadsafe_self->invalidate();
Expand Down
7 changes: 5 additions & 2 deletions src/server/shell/decoration/basic_decoration.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define MIR_SHELL_DECORATION_BASIC_DECORATION_H_

#include "decoration.h"
#include "decoration_strategy.h"

#include "mir/geometry/rectangle.h"
#include "mir_toolkit/common.h"
Expand Down Expand Up @@ -72,7 +73,8 @@ class BasicDecoration
std::shared_ptr<graphics::GraphicBufferAllocator> const& buffer_allocator,
std::shared_ptr<Executor> const& executor,
std::shared_ptr<input::CursorImages> const& cursor_images,
std::shared_ptr<scene::Surface> const& window_surface);
std::shared_ptr<scene::Surface> const& window_surface,
std::shared_ptr<DecorationStrategy> decoration_strategy);
~BasicDecoration();

void window_state_updated();
Expand Down Expand Up @@ -103,7 +105,8 @@ class BasicDecoration
std::optional<InputState const*> previous_input_state);

std::shared_ptr<ThreadsafeAccess<BasicDecoration>> const threadsafe_self;
std::shared_ptr<StaticGeometry const> const static_geometry;
std::shared_ptr<DecorationStrategy> const decoration_strategy;
std::shared_ptr<StaticGeometry> const static_geometry;

std::shared_ptr<shell::Shell> const shell;
std::shared_ptr<graphics::GraphicBufferAllocator> const buffer_allocator;
Expand Down
30 changes: 28 additions & 2 deletions src/server/shell/decoration/basic_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "basic_manager.h"
#include "decoration.h"
#include "decoration_strategy.h"

#include <mir/graphics/display_configuration.h>
#include <mir/graphics/null_display_configuration_observer.h>
Expand Down Expand Up @@ -49,8 +50,10 @@ class msd::DisplayConfigurationListener : public mg::NullDisplayConfigurationOb
};

msd::BasicManager::BasicManager(
std::shared_ptr<DecorationStrategy> const& decoration_strategy,
ObserverRegistrar<mg::DisplayConfigurationObserver>& display_configuration_observers,
DecorationBuilder&& decoration_builder) :
decoration_strategy{decoration_strategy},
decoration_builder{std::move(decoration_builder)},
display_config_monitor{std::make_shared<DisplayConfigurationListener>(
[&](mg::DisplayConfiguration const& config)
Expand Down Expand Up @@ -92,7 +95,7 @@ void msd::BasicManager::decorate(std::shared_ptr<ms::Surface> const& surface)
{
decorations[surface.get()] = nullptr;
lock.unlock();
auto decoration = decoration_builder(locked_shell, surface);
auto decoration = decoration_builder(decoration_strategy, locked_shell, surface);
lock.lock();
decoration->set_scale(scale);
decorations[surface.get()] = std::move(decoration);
Expand Down Expand Up @@ -128,6 +131,29 @@ void msd::BasicManager::undecorate_all()
to_destroy.clear();
}

using mir::geometry::Size;

auto msd::BasicManager::compute_size_with_decorations(Size content_size,
MirWindowType type, MirWindowState state) -> Size
{
auto const geometry = decoration_strategy->static_geometry();

switch (border_type_for(type, state))
{
case msd::BorderType::Full:
content_size.width += geometry->side_border_width * 2;
content_size.height += geometry->titlebar_height + geometry->bottom_border_height;
break;
case msd::BorderType::Titlebar:
content_size.height += geometry->titlebar_height;
break;
case msd::BorderType::None:
break;
}

return content_size;
}

void msd::BasicManager::set_scale(float new_scale)
{
std::lock_guard lock{mutex};
Expand All @@ -139,4 +165,4 @@ void msd::BasicManager::set_scale(float new_scale)
it.second->set_scale(scale);
}
}
}
}
6 changes: 6 additions & 0 deletions src/server/shell/decoration/basic_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Shell;
namespace decoration
{
class Decoration;
class DecorationStrategy;
class DisplayConfigurationListener;

/// Facilitates decorating windows with Mir's built-in server size decorations
Expand All @@ -48,10 +49,12 @@ class BasicManager :
{
public:
using DecorationBuilder = std::function<std::unique_ptr<Decoration>(
std::shared_ptr<DecorationStrategy> const& decoration_strategy,
std::shared_ptr<shell::Shell> const& shell,
std::shared_ptr<scene::Surface> const& surface)>;

BasicManager(
std::shared_ptr<DecorationStrategy> const& decoration_strategy,
mir::ObserverRegistrar<mir::graphics::DisplayConfigurationObserver>& display_configuration_observers,
DecorationBuilder&& decoration_builder);
~BasicManager();
Expand All @@ -60,8 +63,11 @@ class BasicManager :
void decorate(std::shared_ptr<scene::Surface> const& surface) override;
void undecorate(std::shared_ptr<scene::Surface> const& surface) override;
void undecorate_all() override;
auto compute_size_with_decorations(geometry::Size content_size, MirWindowType type,
MirWindowState state) -> geometry::Size override;

private:
std::shared_ptr<DecorationStrategy> const decoration_strategy;
DecorationBuilder const decoration_builder;
std::shared_ptr<DisplayConfigurationListener> const display_config_monitor;
std::weak_ptr<shell::Shell> shell;
Expand Down
Loading

0 comments on commit c4afaf4

Please sign in to comment.