[gnome-games/wip/exalm/ui4: 4/7] fullscreen-box: Hide cursor independently of header bar
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/ui4: 4/7] fullscreen-box: Hide cursor independently of header bar
- Date: Sun, 9 Jun 2019 10:56:54 +0000 (UTC)
commit 14a495a6cb2d5f3ab1dc5e871211be632edcf5bc
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Sun Jun 9 15:35:19 2019 +0500
fullscreen-box: Hide cursor independently of header bar
We still need to reveal cursor every time it's moving, unlike the header bar.
src/ui/fullscreen-box.vala | 65 ++++++++++++++++++++++++++++++++++------------
1 file changed, 49 insertions(+), 16 deletions(-)
---
diff --git a/src/ui/fullscreen-box.vala b/src/ui/fullscreen-box.vala
index 16e1d3b4..8d95f183 100644
--- a/src/ui/fullscreen-box.vala
+++ b/src/ui/fullscreen-box.vala
@@ -35,12 +35,14 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
private Binding visible_binding;
private Binding fullscreen_binding;
- private uint timeout_id;
+ private uint ui_timeout_id;
+ private uint cursor_timeout_id;
construct {
visible_binding = bind_property ("is-fullscreen", header_bar_revealer,
"visible", BindingFlags.BIDIRECTIONAL);
- timeout_id = -1;
+ ui_timeout_id = -1;
+ cursor_timeout_id = -1;
}
public void add_child (Gtk.Builder builder, Object child, string? type) {
@@ -61,8 +63,10 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
[GtkCallback]
private void on_fullscreen_changed () {
- if (is_fullscreen)
- on_activity ();
+ if (is_fullscreen) {
+ show_ui ();
+ on_cursor_moved ();
+ }
else
on_restore ();
}
@@ -70,42 +74,71 @@ private class Games.FullscreenBox : Gtk.EventBox, Gtk.Buildable {
[GtkCallback]
private bool on_motion_event (Gdk.EventMotion event) {
if (event.y_root <= SHOW_HEADERBAR_DISTANCE)
- on_activity ();
+ show_ui ();
+
+ on_cursor_moved ();
return false;
}
- private void on_activity () {
- if (timeout_id != -1) {
- Source.remove (timeout_id);
- timeout_id = -1;
+ private void show_ui () {
+ if (ui_timeout_id != -1) {
+ Source.remove (ui_timeout_id);
+ ui_timeout_id = -1;
}
if (!is_fullscreen)
return;
- timeout_id = Timeout.add (INACTIVITY_TIME_MILLISECONDS, on_inactivity);
+ ui_timeout_id = Timeout.add (INACTIVITY_TIME_MILLISECONDS, hide_ui);
header_bar_revealer.reveal_child = true;
+ }
+
+ private bool hide_ui () {
+ ui_timeout_id = -1;
+
+ if (!is_fullscreen)
+ return false;
+
+ header_bar_revealer.reveal_child = false;
+ overlay.grab_focus ();
+
+ return false;
+ }
+
+ private void on_cursor_moved () {
+ if (cursor_timeout_id != -1) {
+ Source.remove (cursor_timeout_id);
+ cursor_timeout_id = -1;
+ }
+
+ if (!is_fullscreen)
+ return;
+
+ cursor_timeout_id = Timeout.add (INACTIVITY_TIME_MILLISECONDS, on_inactivity);
show_cursor (true);
}
private bool on_inactivity () {
- timeout_id = -1;
+ cursor_timeout_id = -1;
if (!is_fullscreen)
return false;
- header_bar_revealer.reveal_child = false;
show_cursor (false);
- overlay.grab_focus ();
return false;
}
private void on_restore () {
- if (timeout_id != -1) {
- Source.remove (timeout_id);
- timeout_id = -1;
+ if (ui_timeout_id != -1) {
+ Source.remove (ui_timeout_id);
+ ui_timeout_id = -1;
+ }
+
+ if (cursor_timeout_id != -1) {
+ Source.remove (cursor_timeout_id);
+ cursor_timeout_id = -1;
}
header_bar_revealer.reveal_child = false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]