diff options
| author | Hannes Schulze <contact@haschu.me> | 2026-04-26 01:22:34 +0200 |
|---|---|---|
| committer | Hannes Schulze <contact@haschu.me> | 2026-04-26 01:22:34 +0200 |
| commit | 00be66dad9d27fb9f271e7a645ef90a343753819 (patch) | |
| tree | 2d23b0598c3aa580b31bbf19b953a6e3c4d8aa83 /src/services/workspaces/hyprland-workspace-service.c | |
| parent | e80a97f5603658af3a444a3a8213024c0c9d36d6 (diff) | |
sway workspace service skeleton
Diffstat (limited to 'src/services/workspaces/hyprland-workspace-service.c')
| -rw-r--r-- | src/services/workspaces/hyprland-workspace-service.c | 58 |
1 files changed, 1 insertions, 57 deletions
diff --git a/src/services/workspaces/hyprland-workspace-service.c b/src/services/workspaces/hyprland-workspace-service.c index 27a01b7..3abe152 100644 --- a/src/services/workspaces/hyprland-workspace-service.c +++ b/src/services/workspaces/hyprland-workspace-service.c @@ -1,6 +1,4 @@ #include "services/workspaces/hyprland-workspace-service.h" -#include "glib-object.h" -#include "services/workspace-service.h" #include <json-glib/json-glib.h> #include <gtk/gtk.h> #include <string.h> @@ -135,9 +133,6 @@ static gint64 foobar_hyprland_workspace_service_parse_id static gchar* foobar_hyprland_workspace_service_get_hyprland_base_path ( void ); static gint foobar_hyprland_workspace_service_compare_ids ( gconstpointer a, gconstpointer b ); -static gint foobar_hyprland_workspace_service_sort_func ( gconstpointer item_a, - gconstpointer item_b, - gpointer userdata ); G_DEFINE_TYPE_WITH_CODE( @@ -457,7 +452,7 @@ void foobar_hyprland_workspace_service_init( FoobarHyprlandWorkspaceService* sel { self->workspaces = g_list_store_new( FOOBAR_TYPE_WORKSPACE ); - GtkCustomSorter* sorter = gtk_custom_sorter_new( foobar_hyprland_workspace_service_sort_func, NULL, NULL ); + GtkCustomSorter* sorter = gtk_custom_sorter_new( foobar_workspace_sort_func, NULL, NULL ); self->sorted_workspaces = gtk_sort_list_model_new( G_LIST_MODEL( g_object_ref( self->workspaces ) ), GTK_SORTER( sorter ) ); @@ -1288,57 +1283,6 @@ gint foobar_hyprland_workspace_service_compare_ids( } // -// Sorting callback for workspaces. Items are sorted to be in the following order: -// 1. normal -// 2. named persistent -// 3. named -// 4. special -// 5. named special -// -gint foobar_hyprland_workspace_service_sort_func( - gconstpointer item_a, - gconstpointer item_b, - gpointer userdata ) -{ - (void)userdata; - - FoobarWorkspace* workspace_a = (FoobarWorkspace*)item_a; - FoobarWorkspace* workspace_b = (FoobarWorkspace*)item_b; - gint64 id_a = foobar_workspace_get_id( workspace_a ); - gint64 id_b = foobar_workspace_get_id( workspace_b ); - gboolean special_a = ( foobar_workspace_get_flags( workspace_a ) & FOOBAR_WORKSPACE_FLAGS_SPECIAL ) != 0; - gboolean special_b = ( foobar_workspace_get_flags( workspace_b ) & FOOBAR_WORKSPACE_FLAGS_SPECIAL ) != 0; - gboolean named_a = id_a < 0; - gboolean named_b = id_b < 0; - - // both normal (includes numbered persistent) => sort by ID - if ( !named_a && !named_b ) - { - if ( id_a < id_b ) { return -1; } - if ( id_a > id_b ) { return 1; } - return 0; - } - - // one normal, one special => normal first - if ( special_a && !special_b ) { return 1; } - if ( !special_a && special_b ) { return -1; } - - // only one normal, one named - if ( named_a && !named_b ) { return -1; } - if ( !named_a && named_b ) { return 1; } - - // both special - if ( special_a && special_b ) - { - // if one is -99 => put it last - if ( id_a == -99 && id_b != -99 ) { return 1; } - if ( id_a != -99 && id_b == -99 ) { return -1; } - } - - return g_strcmp0( foobar_workspace_get_name( workspace_a ), foobar_workspace_get_name( workspace_b ) ); -} - -// // Create a new EventData structure. // static EventData* event_data_new( |
