@@ -25,27 +25,6 @@ public class Dock.Launcher : BaseItem {
2525
2626 public App app { get ; construct; }
2727
28- private bool _moving = false ;
29- public bool moving {
30- get {
31- return _moving;
32- }
33-
34- set {
35- _moving = value ;
36-
37- if (value ) {
38- image. clear ();
39- } else {
40- image. gicon = app. app_info. get_icon ();
41- }
42-
43- update_badge_revealer ();
44- update_progress_revealer ();
45- update_running_revealer ();
46- }
47- }
48-
4928 private Gtk . Image image;
5029 private Gtk . Revealer progress_revealer;
5130 private Gtk . Revealer badge_revealer;
@@ -63,7 +42,7 @@ public class Dock.Launcher : BaseItem {
6342 private bool flagged_for_removal = false ;
6443
6544 public Launcher (App app ) {
66- Object (app: app);
45+ Object (app: app, group : Group . LAUNCHER );
6746 }
6847
6948 class construct {
@@ -158,25 +137,6 @@ public class Dock.Launcher : BaseItem {
158137 };
159138 bounce_up. done. connect (bounce_down. play);
160139
161- var drag_source = new Gtk .DragSource () {
162- actions = MOVE
163- };
164- add_controller (drag_source);
165- drag_source. prepare. connect (on_drag_prepare);
166- drag_source. drag_begin. connect (on_drag_begin);
167- drag_source. drag_cancel. connect (on_drag_cancel);
168- drag_source. drag_end. connect (() = > {
169- if (! flagged_for_removal) {
170- moving = false ;
171- }
172- });
173-
174- var drop_target = new Gtk .DropTarget (typeof (Launcher ), MOVE ) {
175- preload = true
176- };
177- add_controller (drop_target);
178- drop_target. enter. connect (on_drop_enter);
179-
180140 gesture_click. button = 0 ;
181141 gesture_click. released. connect (on_click_released);
182142
@@ -212,29 +172,9 @@ public class Dock.Launcher : BaseItem {
212172 app. notify[" progress-visible" ]. connect (update_progress_revealer);
213173 update_progress_revealer ();
214174
215- app. bind_property (" running-on-active-workspace" , running_revealer, " sensitive" , SYNC_CREATE );
216-
217- app. notify[" running" ]. connect (update_running_revealer);
218- update_running_revealer ();
219-
220- var drop_target_file = new Gtk .DropTarget (typeof (File ), COPY );
221- add_controller (drop_target_file);
222-
223- drop_target_file. enter. connect ((x, y) = > {
224- var _launcher_manager = ItemManager . get_default ();
225- if (_launcher_manager. added_launcher != null ) {
226- calculate_dnd_move (_launcher_manager. added_launcher, x, y);
227- }
228- return COPY ;
229- });
230-
231- drop_target_file. drop. connect (() = > {
232- var _launcher_manager = ItemManager . get_default ();
233- if (_launcher_manager. added_launcher != null ) {
234- _launcher_manager. added_launcher. moving = false ;
235- _launcher_manager. added_launcher = null ;
236- }
237- });
175+ app. notify[" running-on-active-workspace" ]. connect (update_active_state);
176+ app. notify[" running" ]. connect (update_active_state);
177+ update_active_state ();
238178
239179 var drop_controller_motion = new Gtk .DropControllerMotion ();
240180 add_controller (drop_controller_motion);
@@ -291,24 +231,7 @@ public class Dock.Launcher : BaseItem {
291231 bounce_up. play ();
292232 }
293233
294- private Gdk .ContentProvider ? on_drag_prepare (double x , double y ) {
295- drag_offset_x = (int ) x;
296- drag_offset_y = (int ) y;
297-
298- var val = Value (typeof (Launcher ));
299- val. set_object (this );
300- return new Gdk .ContentProvider .for_value (val);
301- }
302-
303- private void on_drag_begin (Gtk .DragSource drag_source , Gdk .Drag drag ) {
304- var paintable = new Gtk .WidgetPaintable (image); // Maybe TODO How TF can I get a paintable from a gicon?!?!?
305- drag_source. set_icon (paintable. get_current_image (), drag_offset_x, drag_offset_y);
306- moving = true ;
307-
308- app. pinned = true ; // Dragging communicates an implicit intention to pin the app
309- }
310-
311- private bool on_drag_cancel (Gdk .Drag drag , Gdk .DragCancelReason reason ) {
234+ protected override bool drag_cancelled (Gdk .Drag drag , Gdk .DragCancelReason reason ) {
312235 if (app. pinned && reason == NO_TARGET ) {
313236 var popover = new PoofPopover ();
314237
@@ -343,52 +266,8 @@ public class Dock.Launcher : BaseItem {
343266
344267 return true ;
345268 } else {
346- moving = false ;
347- return false ;
348- }
349- }
350-
351- private Gdk .DragAction on_drop_enter (Gtk .DropTarget drop_target , double x , double y ) {
352- var val = drop_target. get_value ();
353- if (val != null ) {
354- var obj = val. get_object ();
355-
356- if (obj != null && obj is Launcher ) {
357- calculate_dnd_move ((Launcher ) obj, x, y);
358- }
359- }
360-
361- return MOVE ;
362- }
363-
364- /**
365- * Calculates which side of #this source should be moved to.
366- * Depends on the direction from which the mouse cursor entered
367- * and whether source is already next to #this.
368- *
369- * @param source the launcher that's currently being reordered
370- * @param x pointer x position
371- * @param y pointer y position
372- */
373- private void calculate_dnd_move (Launcher source , double x , double y ) {
374- var launcher_manager = ItemManager . get_default ();
375-
376- int target_index = launcher_manager. get_index_for_launcher (this );
377- int source_index = launcher_manager. get_index_for_launcher (source);
378-
379- if (source_index == target_index) {
380- return ;
269+ return base . drag_cancelled (drag, reason);
381270 }
382-
383- if (((x > get_width () / 2 ) && target_index + 1 == source_index) || // Cursor entered from the RIGHT and source IS our neighbouring launcher to the RIGHT
384- ((x < get_width () / 2 ) && target_index - 1 != source_index) // Cursor entered from the LEFT and source is NOT our neighbouring launcher to the LEFT
385- ) {
386- // Move it to the left of us
387- target_index = target_index > 0 ? target_index-- : target_index;
388- }
389- // Else move it to the right of us
390-
391- launcher_manager. move_launcher_after (source, target_index);
392271 }
393272
394273 private void queue_dnd_cycle () {
@@ -406,12 +285,12 @@ public class Dock.Launcher : BaseItem {
406285 }
407286
408287 private void update_badge_revealer () {
409- badge_revealer. reveal_child = ! moving && app. count_visible
288+ badge_revealer. reveal_child = app. count_visible
410289 && (notify_settings == null || ! notify_settings. get_boolean (" do-not-disturb" ));
411290 }
412291
413292 private void update_progress_revealer () {
414- progress_revealer. reveal_child = ! moving && app. progress_visible;
293+ progress_revealer. reveal_child = app. progress_visible;
415294
416295 // See comment above and https://github.com/elementary/dock/issues/279
417296 if (progress_revealer. reveal_child && progress_revealer. child == null ) {
@@ -424,7 +303,11 @@ public class Dock.Launcher : BaseItem {
424303 }
425304 }
426305
427- private void update_running_revealer () {
428- running_revealer. reveal_child = ! moving && app. running;
306+ private void update_active_state () {
307+ if (! app. running) {
308+ state = HIDDEN ;
309+ } else {
310+ state = app. running_on_active_workspace ? State . ACTIVE : State . INACTIVE ;
311+ }
429312 }
430313}
0 commit comments