Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • gtk gtk
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 1.6k
    • Issues 1.6k
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 266
    • Merge requests 266
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
    • Model experiments
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • gtkgtk
  • Issues
  • #2914

Native OS functionality of window switching (cmd+`) does not work on MacOS.

Steps to reproduce

  1. Create an app with two TopLevel windows (sample code attached)
#include <gtk/gtk.h>

int main(int argc, char* argv[]) {

  gtk_init(&argc, &argv);

  GtkWidget* first = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(first), "first");
  GtkWidget* second = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(second), "second");

  gtk_widget_show(first);
  gtk_widget_show(second);

  gtk_main();

  return 0;
}
	gcc app.c `pkg-config --cflags --libs gtk+-3.0` -o app
  1. Run it on MacOS
  2. Try to switch between application windows using standard osx key binding (CMD+`)

Current behavior

There's no reaction whatsoever. Event is swallowed by GTK and no default action is triggered.

You can observe it on this video (first I show stable gtk, then I show customized version I prepared to overcome the issue):

Cmd+` Issue

Expected outcome

Active application window should change each time you hit CMD+`

Version information

3.24

Additional information

The origin of the issue for me is this ticket on xpra bug-tracker:

https://xpra.org/trac/ticket/708

I digged into this problem only to find out that xpra has nothing to do with swallowing the event and in fact it's GTK which does not propagate event back to the system if event was NOT handled.

I prepared some workaround for the problem which works like this:

At the bubbling phase of keyboard events see if the event was handled, if not send the native event back to the OS for some default behavior.

I implemented it by adding new GdkDisplayClass method called "event_propagate_native". By default it does nothing but returning "FALSE" (meaning event was not handled). However Quartz implementation forwards keyboard events back to the system which makes the shortcuts like CMD+` work just fine. I got the inspiration from chromium where that's the way they handle it (by passing the native keyboard events back to NSApp).

Edited Jul 05, 2020 by Mateusz Szygenda
Assignee
Assign to
Time tracking