Skip to content

Commit fbfdf97

Browse files
committed
Nicer hover behavior
1 parent 6e8a992 commit fbfdf97

File tree

1 file changed

+14
-38
lines changed

1 file changed

+14
-38
lines changed

src/Widgets/WindowClone.vala

Lines changed: 14 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ public class Gala.WindowClone : Clutter.Actor {
146146

147147
window.notify["title"].connect (() => window_title.set_text (window.get_title () ?? ""));
148148
window_title.set_text (window.get_title () ?? "");
149+
150+
notify["has-pointer"].connect (() => update_hover_widgets ());
149151
}
150152

151153
~WindowClone () {
@@ -289,7 +291,7 @@ public class Gala.WindowClone : Clutter.Actor {
289291
var target_y = outer_rect.y - offset_y;
290292

291293
active = false;
292-
in_slot_animation = true;
294+
update_hover_widgets (true);
293295

294296
GestureTracker.OnUpdate on_animation_update = (percentage) => {
295297
var x = GestureTracker.animation_value (initial_x, target_x, percentage);
@@ -342,10 +344,10 @@ public class Gala.WindowClone : Clutter.Actor {
342344
var transition = window_icon.get_transition ("opacity");
343345
if (transition != null) {
344346
transition.completed.connect (() => {
345-
in_slot_animation = false;
347+
update_hover_widgets (false);
346348
});
347349
} else {
348-
in_slot_animation = false;
350+
update_hover_widgets (false);
349351
}
350352
};
351353

@@ -374,7 +376,7 @@ public class Gala.WindowClone : Clutter.Actor {
374376
unowned var display = wm.get_display ();
375377
var scale = display.get_monitor_scale (display.get_monitor_index_for_rect (rect));
376378

377-
in_slot_animation = true;
379+
update_hover_widgets (true);
378380

379381
GestureTracker.OnUpdate on_animation_update = (percentage) => {
380382
var x = GestureTracker.animation_value (initial_x, rect.x, percentage);
@@ -420,10 +422,10 @@ public class Gala.WindowClone : Clutter.Actor {
420422
var transition = window_icon.get_transition ("opacity");
421423
if (transition != null) {
422424
transition.completed.connect (() => {
423-
in_slot_animation = false;
425+
update_hover_widgets (false);
424426
});
425427
} else {
426-
in_slot_animation = false;
428+
update_hover_widgets (false);
427429
}
428430
};
429431

@@ -495,52 +497,26 @@ public class Gala.WindowClone : Clutter.Actor {
495497
return Clutter.EVENT_STOP;
496498
}
497499

498-
#if HAS_MUTTER45
499-
public override bool enter_event (Clutter.Event event) {
500-
#else
501-
public override bool enter_event (Clutter.CrossingEvent event) {
502-
#endif
503-
if (drag_action != null && drag_action.dragging) {
504-
return Clutter.EVENT_PROPAGATE;
500+
private void update_hover_widgets (bool? animating = null) {
501+
if (animating != null) {
502+
in_slot_animation = animating;
505503
}
506504

507505
var duration = wm.enable_animations ? FADE_ANIMATION_DURATION : 0;
508506

509-
close_button.save_easing_state ();
510-
close_button.set_easing_mode (Clutter.AnimationMode.LINEAR);
511-
close_button.set_easing_duration (duration);
512-
close_button.opacity = in_slot_animation ? 0 : 255;
513-
close_button.restore_easing_state ();
514-
515-
window_title.save_easing_state ();
516-
window_title.set_easing_mode (Clutter.AnimationMode.LINEAR);
517-
window_title.set_easing_duration (duration);
518-
window_title.opacity = in_slot_animation ? 0 : 255;
519-
window_title.restore_easing_state ();
520-
521-
return Clutter.EVENT_PROPAGATE;
522-
}
523-
524-
#if HAS_MUTTER45
525-
public override bool leave_event (Clutter.Event event) {
526-
#else
527-
public override bool leave_event (Clutter.CrossingEvent event) {
528-
#endif
529-
var duration = wm.enable_animations ? FADE_ANIMATION_DURATION : 0;
507+
var show = has_pointer && !in_slot_animation;
530508

531509
close_button.save_easing_state ();
532510
close_button.set_easing_mode (Clutter.AnimationMode.LINEAR);
533511
close_button.set_easing_duration (duration);
534-
close_button.opacity = 0;
512+
close_button.opacity = show ? 255 : 0;
535513
close_button.restore_easing_state ();
536514

537515
window_title.save_easing_state ();
538516
window_title.set_easing_mode (Clutter.AnimationMode.LINEAR);
539517
window_title.set_easing_duration (duration);
540-
window_title.opacity = 0;
518+
window_title.opacity = show ? 255 : 0;
541519
window_title.restore_easing_state ();
542-
543-
return Clutter.EVENT_PROPAGATE;
544520
}
545521

546522
private void toggle_shadow (bool show) {

0 commit comments

Comments
 (0)