[epiphany/wip/exalm/fullscreen: 1/3] fullscreen-box: Hide header bar when touch is used
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/exalm/fullscreen: 1/3] fullscreen-box: Hide header bar when touch is used
- Date: Tue, 23 Mar 2021 09:36:25 +0000 (UTC)
commit 31a4a9fa84b0aa4ccc1c19177bd137e0b1dcd069
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Mon Mar 22 20:04:19 2021 +0500
fullscreen-box: Hide header bar when touch is used
src/ephy-fullscreen-box.c | 39 +++++++++++++++++++++++++++++++--------
1 file changed, 31 insertions(+), 8 deletions(-)
---
diff --git a/src/ephy-fullscreen-box.c b/src/ephy-fullscreen-box.c
index c8e3fe9ce..591d2bf99 100644
--- a/src/ephy-fullscreen-box.c
+++ b/src/ephy-fullscreen-box.c
@@ -31,6 +31,7 @@ struct _EphyFullscreenBox {
HdyFlap *flap;
GtkEventController *controller;
+ GtkGesture *gesture;
gboolean fullscreen;
gboolean autohide;
@@ -39,6 +40,7 @@ struct _EphyFullscreenBox {
GtkWidget *last_focus;
gdouble last_y;
+ gboolean is_touch;
};
static void ephy_fullscreen_box_buildable_init (GtkBuildableIface *iface);
@@ -127,18 +129,20 @@ static void
update (EphyFullscreenBox *self,
gboolean hide_immediately)
{
- gdouble height;
-
if (!self->autohide || !self->fullscreen)
return;
- height = gtk_widget_get_allocated_height (hdy_flap_get_flap (self->flap));
- height *= hdy_flap_get_reveal_progress (self->flap);
- height = MAX (height, SHOW_HEADERBAR_DISTANCE_PX);
+ if (!self->is_touch) {
+ gdouble height;
- if (self->last_y <= height) {
- show_ui (self);
- return;
+ height = gtk_widget_get_allocated_height (hdy_flap_get_flap (self->flap));
+ height *= hdy_flap_get_reveal_progress (self->flap);
+ height = MAX (height, SHOW_HEADERBAR_DISTANCE_PX);
+
+ if (self->last_y <= height) {
+ show_ui (self);
+ return;
+ }
}
if (self->last_focus && is_descendant_of (self->last_focus,
@@ -155,11 +159,22 @@ motion_cb (EphyFullscreenBox *self,
gdouble x,
gdouble y)
{
+ self->is_touch = FALSE;
self->last_y = y;
update (self, FALSE);
}
+static void
+press_cb (EphyFullscreenBox *self)
+{
+ gtk_gesture_set_state (self->gesture, GTK_EVENT_SEQUENCE_DENIED);
+
+ self->is_touch = TRUE;
+
+ update (self, TRUE);
+}
+
static void
set_focus_cb (EphyFullscreenBox *self,
GtkWidget *widget)
@@ -306,6 +321,7 @@ ephy_fullscreen_box_dispose (GObject *object)
EphyFullscreenBox *self = EPHY_FULLSCREEN_BOX (object);
g_clear_object (&self->controller);
+ g_clear_object (&self->gesture);
G_OBJECT_CLASS (ephy_fullscreen_box_parent_class)->dispose (object);
}
@@ -390,6 +406,13 @@ ephy_fullscreen_box_init (EphyFullscreenBox *self)
gtk_event_controller_set_propagation_phase (self->controller, GTK_PHASE_CAPTURE);
g_signal_connect_object (self->controller, "motion",
G_CALLBACK (motion_cb), self, G_CONNECT_SWAPPED);
+
+ self->gesture = gtk_gesture_multi_press_new (GTK_WIDGET (self));
+ gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (self->gesture),
+ GTK_PHASE_CAPTURE);
+ gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (self->gesture), TRUE);
+ g_signal_connect_object (self->gesture, "pressed",
+ G_CALLBACK (press_cb), self, G_CONNECT_SWAPPED);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]