Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor Scaling Support #3735

Open
wants to merge 25 commits into
base: main
Choose a base branch
from
Open

Conversation

tarek-y-ismail
Copy link
Contributor

Currently only implements cursor scaling for software cursors. Missing the actual configuration portion.

@tarek-y-ismail tarek-y-ismail self-assigned this Feb 4, 2025
src/server/CMakeLists.txt Outdated Show resolved Hide resolved
src/server/CMakeLists.txt Outdated Show resolved Hide resolved
@tarek-y-ismail tarek-y-ismail force-pushed the MIRENG-899/cursor-scaling-support branch 2 times, most recently from 9cd58cb to ed17b1f Compare February 5, 2025 12:12
@tarek-y-ismail tarek-y-ismail force-pushed the MIRENG-899/cursor-scaling-support branch 6 times, most recently from 4f3b5dc to b5ac991 Compare February 6, 2025 14:09
@tarek-y-ismail tarek-y-ismail force-pushed the MIRENG-899/cursor-scaling-support branch from b5ac991 to 080c35b Compare February 6, 2025 14:25
In the grand scheme of things, the cursor isn't scaled nor is it
shown/hidden that much. So this check doesn't help much, while breaking
tests
@tarek-y-ismail tarek-y-ismail force-pushed the MIRENG-899/cursor-scaling-support branch from 080c35b to bd302df Compare February 6, 2025 16:07
@@ -1,3 +1,5 @@
pkg_check_modules(PIXMAN REQUIRED IMPORTED_TARGET pixman-1)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not super sure about this but putting this line in src/platform/graphics/CMakeLists.txt causes a cmake error so this is the best I had in mind.

src/platforms/gbm-kms/server/kms/cursor.h Outdated Show resolved Hide resolved
src/platforms/gbm-kms/server/kms/cursor.h Outdated Show resolved Hide resolved
src/include/server/mir/default_server_configuration.h Outdated Show resolved Hide resolved
`create_scaled_renderable_for_current_cursor`
@tarek-y-ismail tarek-y-ismail marked this pull request as ready for review February 6, 2025 16:25
@tarek-y-ismail tarek-y-ismail requested a review from a team as a code owner February 6, 2025 16:25
@tarek-y-ismail
Copy link
Contributor Author

tarek-y-ismail commented Feb 7, 2025

SoftwareCursor can be scaled by updating the width and height returned from screen_position

geom::Rectangle screen_position() const override
{
std::lock_guard lock{position_mutex};
return {position, buffer_->size()};
}

Edit: done

Allows both `Cursor::{show, set_scale}` to lock to avoid races while
showing/scaling the cursor, while also not requiring a recursive lock.

We previously needed a recursive lock since `set_scale` called `show`,
and both would lock the mutex, requiring either a recursive lock, or
adding a non-locking version of `set_scale`. No other need for a
recursive lock.
@tarek-y-ismail
Copy link
Contributor Author

tarek-y-ismail commented Feb 7, 2025

Bug: If you change the cursor scale from inside the running compositor, a copy of the new cursor is displayed where the old cursor was.

Only happens if the cursor is over kgx/weston-terminal

Edit: Doesn't seem to happen anymore. Not sure why it came up in the first place

@tarek-y-ismail
Copy link
Contributor Author

tarek-y-ismail commented Feb 7, 2025

Another bug: the cursor doesn't work properly with x apps

False alarm, xterm launched from kgx inside mir_demo_sever was opening outside the intended compositor. Ported the changes to miral-shell and started xterm from there and the cursor works properly.

Copy link
Collaborator

@AlanGriffiths AlanGriffiths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bunch of "housekeeping"...

@@ -84,6 +84,7 @@ MIR_PLATFORM_2.19 {
mir::graphics::initialise_egl_logger*;
mir::graphics::operator*;
mir::graphics::red_channel_depth*;
mir::graphics::scale_cursor_image*;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR breaks the platform ABI, everything should move to a 2.20 stanza

Comment on lines -435 to +441
CachedPtr<shell::AccessibilityManager> accessibility_manager;
CachedPtr<shell::decoration::Manager> decoration_manager;
CachedPtr<scene::ApplicationNotRespondingDetector> application_not_responding_detector;
CachedPtr<cookie::Authority> cookie_authority;
CachedPtr<input::receiver::XKBMapperRegistrar> xkb_mapper_registrar;
std::shared_ptr<ConsoleServices> console_services;
std::shared_ptr<DecorationStrategy> decoration_strategy;
CachedPtr<shell::AccessibilityManager> accessibility_manager;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like an unnecessary reordering change?

Comment on lines +1423 to +1424
mir::shell::AccessibilityManager::cursor_scale_changed*;
mir::shell::AccessibilityManager::set_cursor*;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the layout of AccessibilityManager is an ABI break: we need to move to a 2.20 stanza

@@ -424,12 +426,12 @@ TEST_F(SoftwareCursor, handles_argb_8888_cursor_surface)
ON_CALL(mock_buffer_allocator, supported_pixel_formats())
.WillByDefault(Return(std::vector<MirPixelFormat>{ mir_pixel_format_argb_8888 }));

StubCursorImage test_image{{8, 8}};
auto test_image = std::make_shared<StubCursorImage>(geom::Displacement{8, 8});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto test_image = std::make_shared<StubCursorImage>(geom::Displacement{8, 8});
auto const test_image = std::make_shared<StubCursorImage>(geom::Displacement{8, 8});

@@ -478,12 +480,12 @@ TEST_F(SoftwareCursor, handles_argb_8888_buffer_with_stride)
ON_CALL(mock_buffer_allocator, supported_pixel_formats())
.WillByDefault(Return(std::vector<MirPixelFormat>{ mir_pixel_format_argb_8888 }));

StubCursorImage test_image{{8, 8}};
auto test_image = std::make_shared<StubCursorImage>(geom::Displacement{8, 8});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto test_image = std::make_shared<StubCursorImage>(geom::Displacement{8, 8});
auto const test_image = std::make_shared<StubCursorImage>(geom::Displacement{8, 8});

{
auto image = dynamic_cast<NamedCursorImage const*>(&i);
auto image = std::dynamic_pointer_cast<NamedCursorImage const>(i);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
auto image = std::dynamic_pointer_cast<NamedCursorImage const>(i);
auto const image = std::dynamic_pointer_cast<NamedCursorImage const>(i);

@@ -321,7 +322,7 @@ struct MesaCursorTest : ::testing::Test
}

testing::NiceMock<mtd::MockDRM> mock_drm;
StubCursorImage stub_image;
std::shared_ptr<StubCursorImage> stub_image = std::make_shared<StubCursorImage>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::shared_ptr<StubCursorImage> stub_image = std::make_shared<StubCursorImage>();
auto const stub_image = std::make_shared<StubCursorImage>();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants