From 14180d60be040e47511b65ea9f7d6b56cbf292f3 Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Fri, 6 Apr 2018 16:53:53 +0200 Subject: [PATCH] nitpicker: center initial pointer position --- repos/os/src/server/nitpicker/main.cc | 9 ++++++++- repos/os/src/server/nitpicker/user_state.h | 8 +++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/repos/os/src/server/nitpicker/main.cc b/repos/os/src/server/nitpicker/main.cc index 3917dd95a7..3eb35ef8fa 100644 --- a/repos/os/src/server/nitpicker/main.cc +++ b/repos/os/src/server/nitpicker/main.cc @@ -228,6 +228,12 @@ struct Nitpicker::Main : Focus_updater Reconstructible _fb_screen = { _env.rm(), _framebuffer }; + Point _initial_pointer_pos() + { + Area const scr_size = _fb_screen->screen.size(); + return Point(scr_size.w()/2, scr_size.h()/2); + } + void _handle_fb_mode(); Signal_handler
_fb_mode_handler = { _env.ep(), *this, &Main::_handle_fb_mode }; @@ -250,7 +256,7 @@ struct Nitpicker::Main : Focus_updater Focus _focus { }; View_stack _view_stack { _fb_screen->screen.size(), _focus }; - User_state _user_state { _focus, _global_keys, _view_stack }; + User_state _user_state { _focus, _global_keys, _view_stack, _initial_pointer_pos() }; View_owner _global_view_owner { }; @@ -361,6 +367,7 @@ struct Nitpicker::Main : Focus_updater { _view_stack.default_background(_builtin_background); _view_stack.stack(_pointer_origin); + _view_stack.geometry(_pointer_origin, Rect(_user_state.pointer_pos(), Area())); _view_stack.stack(_builtin_background); _config_rom.sigh(_config_handler); diff --git a/repos/os/src/server/nitpicker/user_state.h b/repos/os/src/server/nitpicker/user_state.h index 2eb48b5174..84122cb021 100644 --- a/repos/os/src/server/nitpicker/user_state.h +++ b/repos/os/src/server/nitpicker/user_state.h @@ -78,7 +78,7 @@ class Nitpicker::User_state /* * Current pointer position */ - Point _pointer_pos { }; + Point _pointer_pos; /* * Currently pointed-at view owner @@ -164,9 +164,11 @@ class Nitpicker::User_state * \param focus exported focus information, to be consumed by the * view stack to tailor its view drawing operations */ - User_state(Focus &focus, Global_keys &global_keys, View_stack &view_stack) + User_state(Focus &focus, Global_keys &global_keys, View_stack &view_stack, + Point initial_pointer_pos) : - _focus(focus), _global_keys(global_keys), _view_stack(view_stack) + _focus(focus), _global_keys(global_keys), _view_stack(view_stack), + _pointer_pos(initial_pointer_pos) { }