From 312cd550b1074c09e5f8c7e7a43f33ecb1c4dc00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 28 Nov 2024 11:42:33 +0100 Subject: [PATCH 1/2] notification-banner: Fix indent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gbp-Dch: Ignore Signed-off-by: Guido Günther Part-of: --- src/notifications/notification-banner.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/notifications/notification-banner.c b/src/notifications/notification-banner.c index b3b6a00b2..fd825252a 100644 --- a/src/notifications/notification-banner.c +++ b/src/notifications/notification-banner.c @@ -259,8 +259,7 @@ phosh_notification_banner_new (PhoshNotification *notification) PhoshMonitor *monitor = phosh_shell_get_primary_monitor (phosh_shell_get_default ()); int width = 360; - phosh_shell_get_usable_area (phosh_shell_get_default (), - NULL, NULL, &width, NULL); + phosh_shell_get_usable_area (phosh_shell_get_default (), NULL, NULL, &width, NULL); return g_object_new (PHOSH_TYPE_NOTIFICATION_BANNER, "notification", notification, -- GitLab From 5e01aa5558f294486e722eba107bf69ba8cf42c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 28 Nov 2024 11:07:52 +0100 Subject: [PATCH 2/2] notification-banner: Use minimal size for banner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Size the banner based on the allocation. This ensures areas around the notification will still remain touchable. We keep a min width of 360px to ensure the notification doesn't get too narrow. Fixes: c0b37ad5c ("notification-banner: Drop unused hard coded values") Signed-off-by: Guido Günther Part-of: --- src/notifications/notification-banner.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/notifications/notification-banner.c b/src/notifications/notification-banner.c index fd825252a..a5803fee7 100644 --- a/src/notifications/notification-banner.c +++ b/src/notifications/notification-banner.c @@ -16,6 +16,8 @@ #include +#define BANNER_MIN_WIDTH 360 + /** * PhoshNotificationBanner: * @@ -217,6 +219,18 @@ phosh_notification_banner_show (GtkWidget *widget) } +static void +phosh_notification_banner_map (GtkWidget *widget) +{ + int height; + + GTK_WIDGET_CLASS (phosh_notification_banner_parent_class)->map (widget); + + height = gtk_widget_get_allocated_height (widget); + phosh_layer_surface_set_size (PHOSH_LAYER_SURFACE (widget), -1, height); +} + + static void phosh_notification_banner_class_init (PhoshNotificationBannerClass *klass) { @@ -228,6 +242,7 @@ phosh_notification_banner_class_init (PhoshNotificationBannerClass *klass) object_class->get_property = phosh_notification_banner_get_property; widget_class->show = phosh_notification_banner_show; + widget_class->map = phosh_notification_banner_map; /** * PhoshNotificationBanner:notification: @@ -257,17 +272,20 @@ phosh_notification_banner_new (PhoshNotification *notification) { PhoshWayland *wl = phosh_wayland_get_default (); PhoshMonitor *monitor = phosh_shell_get_primary_monitor (phosh_shell_get_default ()); - int width = 360; + int width = BANNER_MIN_WIDTH; phosh_shell_get_usable_area (phosh_shell_get_default (), NULL, NULL, &width, NULL); return g_object_new (PHOSH_TYPE_NOTIFICATION_BANNER, "notification", notification, + "width-request", BANNER_MIN_WIDTH, /* layer surface */ "layer-shell", phosh_wayland_get_zwlr_layer_shell_v1 (wl), "wl-output", monitor ? monitor->wl_output : NULL, "anchor", ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP, "width", MIN (width, 450), + /* Initial height to not take up the whole screen */ + "height", 100, "layer", ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY, "kbd-interactivity", FALSE, "exclusive-zone", 0, -- GitLab