Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the menu accessible on stock GNOME3 as well #109

Open
bk138 opened this issue Dec 5, 2020 · 6 comments
Open

Make the menu accessible on stock GNOME3 as well #109

bk138 opened this issue Dec 5, 2020 · 6 comments
Assignees

Comments

@bk138
Copy link
Owner

bk138 commented Dec 5, 2020

Stock GNOME3 does not show any tray icon at all, thus there's no way to actually access the menu. Explore possibilities to make this happen.

Approach 1 - via Dock Icon -> ⛔

  • when there is a GTK_WINDOW_TOPLEVEL window, an icon is shown in the dock
  • activation could open the menu
  • or: explore .desktop actions

-> folllowing patch has desktop actions:

diff --git a/data/net.christianbeier.Gromit-MPX.desktop b/data/net.christianbeier.Gromit-MPX.desktop
index 2ac3a24..6097856 100644
--- a/data/net.christianbeier.Gromit-MPX.desktop
+++ b/data/net.christianbeier.Gromit-MPX.desktop
@@ -9,3 +9,9 @@ Keywords=presentation;overlay;markup;pointer;
 Terminal=false
 StartupNotify=false
 Categories=Graphics;
+
+Actions=Toggle;
+
+[Desktop Action Toggle]
+Name=Toggl
+Exec=gromit-mpx -t
\ No newline at end of file
diff --git a/src/callbacks.c b/src/callbacks.c
index 0498b33..36d4324 100644
--- a/src/callbacks.c
+++ b/src/callbacks.c
@@ -412,9 +412,19 @@ void on_mainapp_selection_get (GtkWidget          *widget,
   if(action == GA_TOGGLE)
     {
       /* ask back client for device id */
-      gtk_selection_convert (data->win, GA_DATA,
-                             GA_TOGGLEDATA, time);
-      gtk_main(); /* Wait for the response */
+      //gtk_selection_convert (data->win, GA_DATA,
+	//                      GA_TOGGLEDATA, time);
+      //gtk_main(); /* Wait for the response */
+
+        gtk_menu_popup_at_pointer(data->menu, NULL);
+        
+	/*
+	gtk_menu_popup_at_widget (data->menu,
+                          data->dummy,
+                         GDK_GRAVITY_CENTER,
+                          GDK_GRAVITY_CENTER,
+                          NULL);
+	*/
     }
   else if (action == GA_VISIBILITY)
     toggle_visibility (data);
diff --git a/src/gromit-mpx.c b/src/gromit-mpx.c
index 81319b9..b98d95f 100644
--- a/src/gromit-mpx.c
+++ b/src/gromit-mpx.c
@@ -955,6 +955,7 @@ void setup_main_app (GromitData *data, int argc, char ** argv)
 
   /* create the menu */
   GtkWidget *menu = gtk_menu_new ();
+  data->menu = menu;
 
   char labelBuf[128];
   /* Create the menu items */
@@ -1219,7 +1220,11 @@ int main (int argc, char **argv)
   /*
     init our window
   */
-  data->win = gtk_window_new (GTK_WINDOW_POPUP);
+   data->win = gtk_window_new (GTK_WINDOW_POPUP);
+
+  data->dummy = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  gtk_widget_show (data->dummy);
+  
   // this trys to set an alpha channel
   on_screen_changed(data->win, NULL, data);
 
diff --git a/src/gromit-mpx.h b/src/gromit-mpx.h
index f060163..6345f03 100644
--- a/src/gromit-mpx.h
+++ b/src/gromit-mpx.h
@@ -99,7 +99,8 @@ typedef struct
 {
   GtkWidget   *win;
   AppIndicator *trayicon;
-
+    GtkMenu *menu;
+    GtkWidget   *dummy;
   GdkCursor   *paint_cursor;
   GdkCursor   *erase_cursor;

--> -t toggle from cmdlne opens menu, is also called from desktop entry, but menu does not open in GNOME's app overview mode: ⛔

--> also,dock icon needs a toplevel window. we could make this transparent and undecorated, but it would still show up in the app overview ⛔ :-(

Approach 2 - via a persistent notification -> ⛔

  • which on click shows the menu - but where?
  • libnotify notifications can be persistent, but they're always closable 👎 we could maybe add an on-close listener and re-open, but that's not nice UX ⛔
    • re-open on close works, but the action buttons are not shown in the drawer thing that opens on clicking the clock :-( ⛔ ⛔
    • but action "default" works 🎉
  • cannot open menu on click using https://developer.gnome.org/gtk3/stable/GtkMenu.html#gtk-menu-popup-at-pointer : gtk_menu_popup_at_rect: assertion 'GDK_IS_WINDOW (rect_window)' failed 👎
  • gtk_menu_popup_at_widget () also does not work as the menu can only be popped up relative to data->win, but not to the pointer :-( -> bad UX

Approach 3 - via Shell Extension ⛔

copy shell extension code from flatpak to host ✔️

  • dest: ~/.local/share/gnome-shell/extensions
  • fb32a5b ✔️

make shell extension known to GNOME ⛔

toggle shell extension on/off from flatpak ✔️

flatpak run --talk-name=org.freedesktop.Flatpak --command=bash net.christianbeier.Gromit-MPX
and then
flatpak-spawn --host gnome-shell-extension-tool -e dark-mode@lossurdo.com; flatpak-spawn --host gnome-shell-extension-tool -d dark-mode@lossurdo.com ✔️

Approach 4 re-use the menu

@bk138 bk138 added this to the Release 1.5 milestone Dec 5, 2020
bk138 added a commit that referenced this issue Jan 25, 2021
@mikeperalta1
Copy link

mikeperalta1 commented Feb 4, 2021

I'm on XCFE4 (Ubuntu 20.10) and see no notification/tray icon either. It would be nice to have a CLI switch that simply shows a simple GUI window. I know the philosophy is "keep the desktop clean" but an opt-in window would be acceptable, and help whenever there are these types of issues.

I've just tried this program tonight and am already prevented from continuing due to the tray issue, and the hotkeys not binding. Not sure what to do now.

Seeing this in the console:

(gromit-mpx:114962): libappindicator-CRITICAL **: 23:16:33.585: app_indicator_set_icon_full: assertion 'IS_APP_INDICATOR (self)' failed

@mikeperalta1
Copy link

My apologies. The issue I reported happens only when building from the latest 1.4 tag. When I switched to 1.3.1 (Ubuntu repos), the tray icon works.

@bk138
Copy link
Owner Author

bk138 commented Feb 4, 2021

My apologies. The issue I reported happens only when building from the latest 1.4 tag. When I switched to 1.3.1 (Ubuntu repos), the tray icon works.

Hi Mike,
For the icon to appear when building from source, you have to also install the build via make install.

@mikeperalta1
Copy link

Ah derp. I should have guessed that. Thank you again!

@bk138 bk138 self-assigned this Feb 7, 2022
@bk138
Copy link
Owner Author

bk138 commented Sep 29, 2023

This is more of an excuse not to publish v1.5, moving to v1.6.

@bk138 bk138 modified the milestones: Release 1.5, Release 1.6 Sep 29, 2023
@bk138 bk138 removed this from the Release 1.6 milestone Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants