mirror of
https://github.com/rozniak/xfce-winxp-tc.git
synced 2026-01-26 11:39:44 +00:00
Enhancement: Fixes #86, Support opening the Start menu with Super key (Windows key)
This commit is contained in:
@@ -55,6 +55,15 @@ static const GOptionEntry S_OPTIONS[] = {
|
||||
"Quit a running Windows taskband instance.",
|
||||
NULL
|
||||
},
|
||||
{
|
||||
"start",
|
||||
's',
|
||||
G_OPTION_FLAG_NONE,
|
||||
G_OPTION_ARG_NONE,
|
||||
NULL,
|
||||
"Toggle the Start menu open or closed.",
|
||||
NULL
|
||||
},
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
@@ -140,10 +149,13 @@ static gint wintc_taskband_application_command_line(
|
||||
GApplicationCommandLine* command_line
|
||||
)
|
||||
{
|
||||
WinTCTaskbandApplication* taskband_app =
|
||||
WINTC_TASKBAND_APPLICATION(application);
|
||||
|
||||
GVariantDict* options =
|
||||
g_application_command_line_get_options_dict(command_line);
|
||||
|
||||
// Just check for --quit
|
||||
// --quit takes priority
|
||||
//
|
||||
if (g_variant_dict_contains(options, "quit"))
|
||||
{
|
||||
@@ -151,6 +163,15 @@ static gint wintc_taskband_application_command_line(
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Handle action switches
|
||||
//
|
||||
if (g_variant_dict_contains(options, "start"))
|
||||
{
|
||||
wintc_taskband_window_toggle_start_menu(
|
||||
WINTC_TASKBAND_WINDOW(taskband_app->host_window)
|
||||
);
|
||||
}
|
||||
|
||||
g_application_activate(application);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1062,6 +1062,13 @@ static void on_personal_menu_hide(
|
||||
WinTCTaskbandToolbar* toolbar = WINTC_TASKBAND_TOOLBAR(user_data);
|
||||
WinTCToolbarStart* toolbar_start = WINTC_TOOLBAR_START(user_data);
|
||||
|
||||
// Track the last closed time, important for toggling the menu properly
|
||||
// (see toolbar.c)
|
||||
//
|
||||
toolbar_start->time_menu_closed = g_get_monotonic_time();
|
||||
|
||||
// Sync Start button state
|
||||
//
|
||||
toolbar_start->sync_button = TRUE;
|
||||
gtk_toggle_button_set_active(
|
||||
GTK_TOGGLE_BUTTON(toolbar->widget_root),
|
||||
|
||||
@@ -49,6 +49,8 @@ typedef struct _WinTCToolbarStart
|
||||
//
|
||||
gboolean sync_button;
|
||||
gboolean sync_menu_should_close;
|
||||
|
||||
gint64 time_menu_closed;
|
||||
} WinTCToolbarStart;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -123,6 +123,32 @@ static void wintc_toolbar_start_dispose(
|
||||
(G_OBJECT_CLASS(wintc_toolbar_start_parent_class))->dispose(object);
|
||||
}
|
||||
|
||||
//
|
||||
// PUBLIC FUNCTIONS
|
||||
//
|
||||
void wintc_toolbar_start_toggle_menu(
|
||||
WinTCToolbarStart* toolbar_start
|
||||
)
|
||||
{
|
||||
WinTCTaskbandToolbar* toolbar = WINTC_TASKBAND_TOOLBAR(toolbar_start);
|
||||
|
||||
GtkToggleButton* start_button = GTK_TOGGLE_BUTTON(toolbar->widget_root);
|
||||
|
||||
// Rate-limit toggling, prevents glitchy behaviour especially when launched
|
||||
// via cmdline/keyboard shortcut (so the menu loses focus then immediately
|
||||
// toggles open)
|
||||
//
|
||||
if (g_get_monotonic_time() - toolbar_start->time_menu_closed < 150000)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_toggle_button_set_active(
|
||||
start_button,
|
||||
!gtk_toggle_button_get_active(start_button)
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// CALLBACKS
|
||||
//
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <glib.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "shared.h"
|
||||
|
||||
//
|
||||
// GTK OOP BOILERPLATE
|
||||
//
|
||||
@@ -16,5 +18,12 @@
|
||||
|
||||
GType wintc_toolbar_start_get_type(void) G_GNUC_CONST;
|
||||
|
||||
//
|
||||
// PUBLIC FUNCTIONS
|
||||
//
|
||||
void wintc_toolbar_start_toggle_menu(
|
||||
WinTCToolbarStart* toolbar_start
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ static void wintc_taskband_window_dispose(
|
||||
GObject* object
|
||||
);
|
||||
|
||||
static void wintc_taskband_window_create_toolbar(
|
||||
static WinTCTaskbandToolbar* wintc_taskband_window_create_toolbar(
|
||||
WinTCTaskbandWindow* taskband,
|
||||
GType toolbar_type,
|
||||
gboolean expand
|
||||
@@ -71,13 +71,13 @@ struct _WinTCTaskbandWindow
|
||||
|
||||
// UI
|
||||
//
|
||||
GtkWidget* main_box;
|
||||
|
||||
GtkWidget* notification_area;
|
||||
GtkWidget* start_button;
|
||||
GtkWidget* taskbuttons;
|
||||
GtkWidget* main_box;
|
||||
|
||||
GSList* toolbars;
|
||||
|
||||
WinTCTaskbandToolbar* toolbar_notifarea;
|
||||
WinTCTaskbandToolbar* toolbar_start;
|
||||
WinTCTaskbandToolbar* toolbar_taskbuttons;
|
||||
};
|
||||
|
||||
//
|
||||
@@ -168,10 +168,19 @@ GtkWidget* wintc_taskband_window_new(
|
||||
);
|
||||
}
|
||||
|
||||
void wintc_taskband_window_toggle_start_menu(
|
||||
WinTCTaskbandWindow* taskband
|
||||
)
|
||||
{
|
||||
wintc_toolbar_start_toggle_menu(
|
||||
WINTC_TOOLBAR_START(taskband->toolbar_start)
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// PRIVATE FUNCTIONS
|
||||
//
|
||||
static void wintc_taskband_window_create_toolbar(
|
||||
static WinTCTaskbandToolbar* wintc_taskband_window_create_toolbar(
|
||||
WinTCTaskbandWindow* taskband,
|
||||
GType toolbar_type,
|
||||
gboolean expand
|
||||
@@ -197,6 +206,8 @@ static void wintc_taskband_window_create_toolbar(
|
||||
);
|
||||
|
||||
gtk_widget_show_all(root);
|
||||
|
||||
return toolbar;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -217,27 +228,30 @@ static gboolean on_window_map_event(
|
||||
switch (s_layout[i])
|
||||
{
|
||||
case WINTC_TASKBAND_TOOLBAR_START:
|
||||
wintc_taskband_window_create_toolbar(
|
||||
taskband,
|
||||
WINTC_TYPE_TOOLBAR_START,
|
||||
FALSE
|
||||
);
|
||||
taskband->toolbar_start =
|
||||
wintc_taskband_window_create_toolbar(
|
||||
taskband,
|
||||
WINTC_TYPE_TOOLBAR_START,
|
||||
FALSE
|
||||
);
|
||||
break;
|
||||
|
||||
case WINTC_TASKBAND_TOOLBAR_BUTTONS:
|
||||
wintc_taskband_window_create_toolbar(
|
||||
taskband,
|
||||
WINTC_TYPE_TOOLBAR_TASK_BUTTONS,
|
||||
TRUE
|
||||
);
|
||||
taskband->toolbar_taskbuttons =
|
||||
wintc_taskband_window_create_toolbar(
|
||||
taskband,
|
||||
WINTC_TYPE_TOOLBAR_TASK_BUTTONS,
|
||||
TRUE
|
||||
);
|
||||
break;
|
||||
|
||||
case WINTC_TASKBAND_TOOLBAR_NOTIFICATION_AREA:
|
||||
wintc_taskband_window_create_toolbar(
|
||||
taskband,
|
||||
WINTC_TYPE_TOOLBAR_NOTIF_AREA,
|
||||
FALSE
|
||||
);
|
||||
taskband->toolbar_notifarea =
|
||||
wintc_taskband_window_create_toolbar(
|
||||
taskband,
|
||||
WINTC_TYPE_TOOLBAR_NOTIF_AREA,
|
||||
FALSE
|
||||
);
|
||||
break;
|
||||
|
||||
case WINTC_TASKBAND_TOOLBAR_QUICK_ACCESS:
|
||||
|
||||
@@ -28,5 +28,9 @@ GtkWidget* wintc_taskband_window_new(
|
||||
WinTCTaskbandApplication* app
|
||||
);
|
||||
|
||||
void wintc_taskband_window_toggle_start_menu(
|
||||
WinTCTaskbandWindow* taskband
|
||||
);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user