diff options
author | kotontrion <[email protected]> | 2024-09-27 08:47:32 +0200 |
---|---|---|
committer | kotontrion <[email protected]> | 2024-09-27 08:47:32 +0200 |
commit | 6916d59373948c8bc23cbb198795fe4608a73ba3 (patch) | |
tree | eff7616d4c13930ad5ad919fb96c9b915e184f84 /core | |
parent | 628f89453764bfab97d3507d351d0dfa4b50c964 (diff) |
core: idle inhibitor fix code style
Diffstat (limited to 'core')
-rw-r--r-- | core/src/idle-inhibit.c | 56 | ||||
-rw-r--r-- | core/src/idle-inhibit.h | 3 | ||||
-rw-r--r-- | core/vapi/AstalInhibitManager.vapi | 20 |
3 files changed, 38 insertions, 41 deletions
diff --git a/core/src/idle-inhibit.c b/core/src/idle-inhibit.c index 95eaa45..48f2471 100644 --- a/core/src/idle-inhibit.c +++ b/core/src/idle-inhibit.c @@ -1,16 +1,16 @@ +#include "idle-inhibit.h" + +#include <gdk/gdk.h> +#include <gdk/gdkwayland.h> #include <gio/gio.h> +#include <glib-object.h> +#include <glib.h> +#include <gtk/gtk.h> #include <wayland-client-protocol.h> #include <wayland-client.h> -#include <gtk/gtk.h> -#include <gdk/gdkwayland.h> -#include "idle-inhibit.h" -#include "gdk/gdk.h" -#include "glib-object.h" -#include "glib.h" #include "idle-inhibit-unstable-v1-client.h" - struct _AstalInhibitManager { GObject parent_instance; }; @@ -19,18 +19,17 @@ typedef struct { gboolean init; struct wl_registry* wl_registry; struct wl_display* display; - struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager; + struct zwp_idle_inhibit_manager_v1* idle_inhibit_manager; } AstalInhibitManagerPrivate; - G_DEFINE_TYPE_WITH_PRIVATE(AstalInhibitManager, astal_inhibit_manager, G_TYPE_OBJECT) -AstalInhibitor* astal_inhibit_manager_inhibit(AstalInhibitManager *self, GtkWindow *window) { - AstalInhibitManagerPrivate* priv = astal_inhibit_manager_get_instance_private(self); - g_assert_true(priv->init); - GdkWindow *gdk_window = gtk_widget_get_window(GTK_WIDGET(window)); - struct wl_surface *surface = gdk_wayland_window_get_wl_surface(gdk_window); - return zwp_idle_inhibit_manager_v1_create_inhibitor(priv->idle_inhibit_manager, surface); +AstalInhibitor* astal_inhibit_manager_inhibit(AstalInhibitManager* self, GtkWindow* window) { + AstalInhibitManagerPrivate* priv = astal_inhibit_manager_get_instance_private(self); + g_assert_true(priv->init); + GdkWindow* gdk_window = gtk_widget_get_window(GTK_WIDGET(window)); + struct wl_surface* surface = gdk_wayland_window_get_wl_surface(gdk_window); + return zwp_idle_inhibit_manager_v1_create_inhibitor(priv->idle_inhibit_manager, surface); } static void global_registry_handler(void* data, struct wl_registry* registry, uint32_t id, @@ -42,31 +41,29 @@ static void global_registry_handler(void* data, struct wl_registry* registry, ui priv->idle_inhibit_manager = wl_registry_bind(registry, id, &zwp_idle_inhibit_manager_v1_interface, 1); } - } static void global_registry_remover(void* data, struct wl_registry* registry, uint32_t id) { - //neither inhibit_manager nor inhibitor is going to be removed by the compositor, so we don't need do anything here. + // neither inhibit_manager nor inhibitor is going to be removed by the compositor, so we don't + // need do anything here. } static const struct wl_registry_listener registry_listener = {global_registry_handler, global_registry_remover}; - -static gboolean astal_inhibit_manager_wayland_init(AstalInhibitManager *self) { - +static gboolean astal_inhibit_manager_wayland_init(AstalInhibitManager* self) { AstalInhibitManagerPrivate* priv = astal_inhibit_manager_get_instance_private(self); if (priv->init) return TRUE; - GdkDisplay *gdk_display = gdk_display_get_default(); + GdkDisplay* gdk_display = gdk_display_get_default(); priv->display = gdk_wayland_display_get_wl_display(gdk_display); priv->wl_registry = wl_display_get_registry(priv->display); wl_registry_add_listener(priv->wl_registry, ®istry_listener, self); wl_display_roundtrip(priv->display); - + if (priv->idle_inhibit_manager == NULL) { g_critical("Can not connect idle inhibitor protocol"); return FALSE; @@ -80,11 +77,11 @@ AstalInhibitManager* astal_inhibit_manager_get_default() { static AstalInhibitManager* self = NULL; if (self == NULL) { - self = g_object_new(ASTAL_TYPE_INHIBIT_MANAGER, NULL); - if(!astal_inhibit_manager_wayland_init(self)) { - g_object_unref(self); - self = NULL; - } + self = g_object_new(ASTAL_TYPE_INHIBIT_MANAGER, NULL); + if (!astal_inhibit_manager_wayland_init(self)) { + g_object_unref(self); + self = NULL; + } } return self; @@ -99,14 +96,14 @@ static void astal_inhibit_manager_init(AstalInhibitManager* self) { } static void astal_inhibit_manager_finalize(GObject* object) { - AstalInhibitManager* self = ASTAL_INHIBIT_MANAGER(object); AstalInhibitManagerPrivate* priv = astal_inhibit_manager_get_instance_private(self); if (priv->display != NULL) wl_display_roundtrip(priv->display); if (priv->wl_registry != NULL) wl_registry_destroy(priv->wl_registry); - if (priv->idle_inhibit_manager != NULL) zwp_idle_inhibit_manager_v1_destroy(priv->idle_inhibit_manager); + if (priv->idle_inhibit_manager != NULL) + zwp_idle_inhibit_manager_v1_destroy(priv->idle_inhibit_manager); G_OBJECT_CLASS(astal_inhibit_manager_parent_class)->finalize(object); } @@ -114,5 +111,4 @@ static void astal_inhibit_manager_finalize(GObject* object) { static void astal_inhibit_manager_class_init(AstalInhibitManagerClass* class) { GObjectClass* object_class = G_OBJECT_CLASS(class); object_class->finalize = astal_inhibit_manager_finalize; - } diff --git a/core/src/idle-inhibit.h b/core/src/idle-inhibit.h index a33fd69..5e9a3ab 100644 --- a/core/src/idle-inhibit.h +++ b/core/src/idle-inhibit.h @@ -3,6 +3,7 @@ #include <glib-object.h> #include <gtk/gtk.h> + #include "idle-inhibit-unstable-v1-client.h" G_BEGIN_DECLS @@ -14,7 +15,7 @@ G_DECLARE_FINAL_TYPE(AstalInhibitManager, astal_inhibit_manager, ASTAL, INHIBIT_ typedef struct zwp_idle_inhibitor_v1 AstalInhibitor; AstalInhibitManager* astal_inhibit_manager_get_default(); -AstalInhibitor* astal_inhibit_manager_inhibit(AstalInhibitManager *self, GtkWindow *window); +AstalInhibitor* astal_inhibit_manager_inhibit(AstalInhibitManager* self, GtkWindow* window); G_END_DECLS diff --git a/core/vapi/AstalInhibitManager.vapi b/core/vapi/AstalInhibitManager.vapi index 4902f94..6232a3c 100644 --- a/core/vapi/AstalInhibitManager.vapi +++ b/core/vapi/AstalInhibitManager.vapi @@ -1,13 +1,13 @@ [CCode (cprefix = "Astal", gir_namespace = "Astal", lower_case_cprefix = "astal_")] namespace Astal { - [CCode (cheader_filename = "idle-inhibit.h", type_id = "astal_idle_inhibit_manager_get_type()")] - public class InhibitManager : GLib.Object { - public static unowned InhibitManager? get_default(); - public Inhibitor inhibit (Gtk.Window window); - } - [CCode (cheader_filename = "idle-inhibit.h", free_function = "zwp_idle_inhibitor_v1_destroy")] - [Compact] - public class Inhibitor { - } - + [CCode (cheader_filename = "idle-inhibit.h", type_id = "astal_idle_inhibit_manager_get_type()")] + public class InhibitManager : GLib.Object { + public static unowned InhibitManager? get_default(); + public Inhibitor inhibit (Gtk.Window window); + } + + [CCode (cheader_filename = "idle-inhibit.h", free_function = "zwp_idle_inhibitor_v1_destroy")] + [Compact] + public class Inhibitor { + } } |