66 */
77
88public class Gala.Plugins.PIP.SelectionArea : CanvasActor {
9- public const int MIN_SELECTION = 100 ;
10-
119 private const int HANDLER_RADIUS = 6 ;
1210 private const int BORDER_WIDTH = 2 ;
1311 private const int RESIZE_THRESHOLD = 10 ;
1412 private const int CONFIRM_BUTTON_SIZE = 60 ;
1513
16- public signal void captured (int x , int y , int width , int height );
14+ public signal void captured (Mtk . Rectangle selection );
1715 public signal void closed ();
1816
1917 public Gala . WindowManager wm { get ; construct; }
@@ -34,11 +32,11 @@ public class Gala.Plugins.PIP.SelectionArea : CanvasActor {
3432 /**
3533 * If the user is resizing the selection area and the resize handler used.
3634 */
37- private bool resizing = false ;
38- private bool resizing_top = false ;
39- private bool resizing_bottom = false ;
40- private bool resizing_left = false ;
41- private bool resizing_right = false ;
35+ private bool resizing = false ;
36+ private bool resizing_top = false ;
37+ private bool resizing_bottom = false ;
38+ private bool resizing_left = false ;
39+ private bool resizing_right = false ;
4240
4341 /**
4442 * If the user is dragging the selection area and the starting point.
@@ -133,7 +131,7 @@ public class Gala.Plugins.PIP.SelectionArea : CanvasActor {
133131
134132 private void capture_selected_area () {
135133 close ();
136- captured (selection. x, selection . y, selection . width, selection . height );
134+ captured (selection);
137135 }
138136
139137 public override bool button_press_event (Clutter .Event event ) {
@@ -158,7 +156,11 @@ public class Gala.Plugins.PIP.SelectionArea : CanvasActor {
158156 return Clutter . EVENT_STOP ;
159157 }
160158
161- dragging = selection. contains_rect ({ (int ) event_x, (int ) event_y, 1 , 1 });
159+ #if HAS_MUTTER48
160+ dragging = selection. contains_pointf (event_x, event_y);
161+ #else
162+ dragging = selection. contains_rect ({ (int ) event_x, (int ) event_y, 0 , 0 });
163+ #endif
162164 if (dragging) {
163165 drag_x = event_x - selection. x;
164166 drag_y = event_y - selection. y;
@@ -172,9 +174,6 @@ public class Gala.Plugins.PIP.SelectionArea : CanvasActor {
172174 return Clutter . EVENT_STOP ;
173175 }
174176
175- selection. x = (int ) event_x;
176- selection. y = (int ) event_y;
177-
178177 return Clutter . EVENT_STOP ;
179178 }
180179
@@ -191,7 +190,11 @@ public class Gala.Plugins.PIP.SelectionArea : CanvasActor {
191190 float event_x, event_y;
192191 event. get_coords (out event_x, out event_y);
193192
193+ #if HAS_MUTTER48
194+ if (! resizing && ! dragging && ! selection. contains_pointf (event_x, event_y)) {
195+ #else
194196 if (! resizing && ! dragging && ! selection. contains_rect ({ (int ) event_x, (int ) event_y, 0 , 0 })) {
197+ #endif
195198 close ();
196199 closed ();
197200 return true ;
@@ -232,25 +235,25 @@ public class Gala.Plugins.PIP.SelectionArea : CanvasActor {
232235 var end_y = selection. y + selection. height;
233236
234237 if (resizing_top) {
235- start_y = (int ) event_y. clamp (max_size. y, end_y - MIN_SELECTION );
238+ start_y = (int ) event_y. clamp (max_size. y, end_y - Plugin . MIN_SELECTION_SIZE );
236239 } else if (resizing_bottom) {
237- end_y = (int ) event_y. clamp (start_y + MIN_SELECTION , max_size. y + max_size. height);
240+ end_y = (int ) event_y. clamp (start_y + Plugin . MIN_SELECTION_SIZE , max_size. y + max_size. height);
238241 }
239242
240243 if (resizing_left) {
241- start_x = (int ) event_x. clamp (max_size. x, end_x - MIN_SELECTION );
244+ start_x = (int ) event_x. clamp (max_size. x, end_x - Plugin . MIN_SELECTION_SIZE );
242245 } else if (resizing_right) {
243- end_x = (int ) event_x. clamp (start_x + MIN_SELECTION , max_size. x + max_size. width);
246+ end_x = (int ) event_x. clamp (start_x + Plugin . MIN_SELECTION_SIZE , max_size. x + max_size. width);
244247 }
245248
246249 selection = { start_x, start_y, end_x - start_x, end_y - start_y };
247250
248251 update_confirm_button_position ();
249252 }
250253
251- private void drag_selection_area (Clutter .Event e ) {
254+ private void drag_selection_area (Clutter . Event event ) {
252255 float event_x, event_y;
253- e . get_coords (out event_x, out event_y);
256+ event . get_coords (out event_x, out event_y);
254257
255258 selection. x = (int ) (event_x - drag_x). clamp (max_size. x, max_size. x + max_size. width - selection. width);
256259 selection. y = (int ) (event_y - drag_y). clamp (max_size. y, max_size. y + max_size. height - selection. height);
@@ -265,13 +268,13 @@ public class Gala.Plugins.PIP.SelectionArea : CanvasActor {
265268 );
266269 }
267270
268- private void set_mouse_cursor_on_motion (Clutter .Event e ) {
271+ private void set_mouse_cursor_on_motion (Clutter . Event event ) {
269272 if (resizing || dragging) {
270273 return ;
271274 }
272275
273276 float event_x, event_y;
274- e . get_coords (out event_x, out event_y);
277+ event . get_coords (out event_x, out event_y);
275278
276279 var top = is_close_to_coord (event_y, selection. y, RESIZE_THRESHOLD );
277280 var bottom = is_close_to_coord (event_y, selection. y + selection. height, RESIZE_THRESHOLD );
0 commit comments