Mir

Code review comment for lp:~brandontschaefer/mir/pointer-confinement

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

Not blocking: A piece is missing here: the handling of surface movements... I.e. imagine a window manager short cut that changes the window position on screen i.e. toggles form full screen to windows or back - without loosing focus.

I am not sure who should be in charge of that. In the past in mirserver we would use a surface change observer. With AbstractShell we might want to have a move_resize_surface_to(...) that handles that and more things...

Codewise a suggestion:

void mi::SeatInputDeviceTracker::set_confinement_regions(geometry::Rectangles const& regions)
+{
+ confine_function = [regions,this](mir::geometry::Point& pos)
+ {
+ regions.confine(pos);
+ input_region->confine(pos);
+ };
+}
+
+void mi::SeatInputDeviceTracker::reset_confinement_regions()
+{
+ confine_function = [this](geometry::Point& pos) {input_region->confine(pos);};
+}
+
+void mi::SeatInputDeviceTracker::confine_pointer()
+{
     mir::geometry::Point const old{cursor_x, cursor_y};
     auto confined = old;
- input_region->confine(confined);
+ confine_function(confined);
     if (confined.x != old.x) cursor_x = confined.x.as_int();
     if (confined.y != old.y) cursor_y = confined.y.as_int();
+}
+
+void mi::SeatInputDeviceTracker::update_cursor(MirPointerEvent const* event)
+{
+ cursor_x += mir_pointer_event_axis_value(event, mir_pointer_axis_relative_x);
+ cursor_y += mir_pointer_event_axis_value(event, mir_pointer_axis_relative_y);
+
+ confine_pointer();

and just let confine_function be a std::function<void(geometry::Point&)> confine_function initialized like reset_confinement_regions.

hmm is that a needs fixing..

« Back to merge proposal