Commit Graph

30 Commits

Author SHA1 Message Date
Matthias Clasen
d006ee65f5 application: Add a query-end signal
This lets us take just-in-time inhibitors, and makes
the session support a little more real.
2019-02-19 00:56:31 -05:00
Matthias Clasen
65e9d71da5 Application: Support sandboxed session state changes
React to the session-state in StateChanged signals from
the inhibit portal and call QueryEndResponse as appropriate.
2019-02-19 00:56:31 -05:00
Matthias Clasen
7e7c90961c Check for the session bus before using it
Patch by Chris Allen, #475
2019-01-02 20:35:19 -05:00
Matthias Clasen
8099669466 Move the should_use_portal helper to gdk
We want to use it there too, in the future.
Update all callers.
2018-11-04 08:17:32 -05:00
Jan Alexander Steffens (heftig)
d90e2733ea GtkApplication: Fix CRITICAL on shutdown when register_session=FALSE
Close https://gitlab.gnome.org/GNOME/gtk/issues/1323#note_327705
2018-09-22 17:56:38 +01:00
Matthias Clasen
d7a5dcba0b gtk_application_inihit: allow no reason
We document this argument as nullable, so treat it as such.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/1327
2018-09-13 23:31:48 -04:00
Matthias Clasen
d4d12171f4 Avoid a pointless goto
We can just return here.
2018-08-31 13:24:17 -04:00
Matthias Clasen
b82a32676b GtkApplication: track screensaver state
A number of applications want to track the state of the screensaver.
Make this information available as a boolean property. We only listen
for state changes when ::register-session is set to TRUE.

This is implemented for unsandboxed D-Bus access by talking
directly to org.gnome.ScreenSaver or org.freedesktop.ScreenSaver,
and for sandboxed D-Bus by using a (new) portal API.
A Quartz implementation is missing.
2018-08-30 22:53:36 -04:00
Matthias Clasen
d7228ae025 GtkApplication: Respect GTK_USE_PORTAL
When the environment variable is set, don't connect
to the session manager, but instead rely on the
inhibit portal.
2018-08-30 22:53:36 -04:00
Matthias Clasen
a01feae15b Use defines for bus names
This helps eradicate typos (we had some here).

Closes https://gitlab.gnome.org/GNOME/gtk/issues/1267
2018-08-15 15:54:34 -07:00
Matthias Clasen
22269902ed Avoid calling unsetenv too late
Stash the DESKTOP_AUTOSTART_ID env var in a constructor,
before any threads have been created.

https://bugzilla.gnome.org/show_bug.cgi?id=790963
2017-12-17 17:32:05 -05:00
Matthias Clasen
65808418e1 Drop gtk_application_is_inhibited
This function returns global session state that may
not be available to applications (e.g. in sandboxed
environments), and is not needed by applications,
so just drop it, instead of keeping a function around
that can't be guaranteed to work.
2017-11-28 23:02:58 -05:00
Matthias Clasen
e821c2fc2f gtk: Avoid using gdk_screen_get_setting
We can get the setting from the display instead.
2017-10-30 16:51:20 -04:00
Timm Bäder
edf0aeb92e gtkapplication: g_dbus_proxy_new_sync can return NULL
Specifically, in the case where @error is set.
2017-07-19 21:27:15 -04:00
Philip Chimento
76e5fd4d0f GtkApplication: Lack of optional components shouldn't warn
When running uninstalled tests with GtkApplication on an autobuilder with
a fake session bus, warnings will cause the tests to abort. The GNOME
session manager, the Xfce session manager, and the Inhibit portal are all
not needed for normal operation of GTK, so we should not log warnings if
they are not found.

As well as not being present on a fake session bus, it's also not
expected that they'll be present on all platforms.

https://bugzilla.gnome.org/show_bug.cgi?id=774784
2016-12-19 15:20:58 -08:00
Matthias Clasen
6163b3b2b5 Allow activating the desktop portal for inhibit
We allow it everywhere else, and there is nothing wrong with it.
2016-08-24 10:55:44 -04:00
Matthias Clasen
f089d7503b GtkApplication: some cleanups
Always return an error if we fail to get a dbus proxy; the callers
are only looking whether error is set, not whether the return value
is NULL.

Use the same function for the inhibit proxy as well, and clean up
the sm_proxy in finalize.
2016-07-25 09:11:21 -04:00
Matthias Clasen
04cec61aa1 Support the Inhibit portal
xdg-desktop-portal now has a portal for inhibiting session status
changes. We don't need to use it if we can talk to the session
manager, but if can't, try org.freedesktop.portal.Inhibit.

https://bugzilla.gnome.org/show_bug.cgi?id=768499
2016-07-08 00:08:37 -04:00
Matthias Clasen
c8a74a1f50 Simplify the xfce session manager support
We don't have to check name owners twice; reuse the information
we already have.
2016-07-03 17:22:14 -04:00
Eric Koegel
3c7cd7ac23 GtkApplication: Add support for the Xfce session manager
Xfce4-session-manager added support for managing dbus based clients.
This patch adds support for checking if Xfce session manager is
around after trying the gnome one.
https://bugzilla.gnome.org/show_bug.cgi?id=693203
2016-07-03 14:56:48 -04:00
Ray Strode
046a4a6e0f gtkapplication-dbus: use application id instead of prgname for SM
gnome-session takes an "app id" for client and inhibitor registration,
This app id is supposed to be a desktop file id (complete with the
.desktop extension), but gtk+ currently uses g_get_prgname ().

This commit changes gtkapplication to use the application id instead,
which is a much more natural fit.  gnome-session is going to be updated
to stop using the .desktop extension, too, so everything is consistent.

https://bugzilla.gnome.org/show_bug.cgi?id=763106
2016-03-04 20:17:26 -05:00
Matthias Clasen
ac5ffd847b GtkApplication: Try to cope with ssh situations better
Override the gtk-shell-shows-app-menu and gtk-shell-shows-menubar
settings to FALSE, if we can detect that we are not on the same
session bus as the xsettings provider that we got these settings
from.

We determine this by comparing the bus ID of 'our' session
bus with the one reported in the Gtk/SessionBusId xsetting.
If they are different, then it very likely that we are in an ssh
situation where we see the forwarded X display, but not the
session bus. The D-Bus based menu exporting will not work
in this situation.

https://bugzilla.gnome.org/show_bug.cgi?id=671802
2014-12-18 23:26:23 -05:00
Matthias Clasen
4aa0d16865 Only warn once if inhibit-related dbus calls fail
No need to spam about it.

https://bugzilla.gnome.org/show_bug.cgi?id=734140
2014-11-03 00:48:42 -05:00
Matthias Clasen
d55e3b25a7 Fix various compiler warnings
Mostly missing declarations and missing statics.
2014-09-05 21:21:49 -04:00
Ryan Lortie
d3b34d3cf2 Add gtk_application_prefers_app_menu()
Applications can call this to determine if they should an app menu.
This will be %FALSE on desktop environments that do not have an
application menu like the one in gnome-shell.  It is %FALSE on Windows
and Mac OS.

Applications are completely free to totally ignore this API -- it is
only provided as a hint to help applications that may be interested in
supporting non-GNOME platforms with a more native 'look and feel'.

https://bugzilla.gnome.org/show_bug.cgi?id=722092
2014-07-02 20:17:34 -04:00
Bastien Nocera
80993ea47a gtkapplication: Fix incorrect value passed to g_variant_new()
The code expected to format @u, not u.

https://bugzilla.gnome.org/show_bug.cgi?id=728140
2014-04-14 20:27:45 +02:00
Bastien Nocera
1409d7c4bd gtkapplication: Fix passing NULL as the window to inhibit
gtk_application_inhibit() supports passing NULL, so don't
blindly pass the NULL window to
gtk_application_impl_dbus_get_window_system_id().

https://bugzilla.gnome.org/show_bug.cgi?id=728023
2014-04-11 18:51:53 -07:00
Paolo Borelli
90b78f89d3 application-dbus: free strings during finalization 2014-03-30 11:57:23 +02:00
Ryan Lortie
ced939fc11 gtkapplication: fix inhibit
The big refactor contained a small mistake that broke inhibiting.  Fix it.
2013-12-16 14:39:48 -05:00
Ryan Lortie
7fd81cf111 Refactor GtkApplication
gtkapplication.c has turned into a bit of an #ifdef mess over time, and
many of the current checks are incorrect.  As an example, if you build
Gtk for wayland, and exclude the X11 backend, much of the functionality
required by wayland (such as exporting menu models) will be disabled.

Solve that by introducing a backend mechanism to GtkApplication (named
GtkApplicationImpl) similar to the one in GApplication.  Add backends
for Wayland, X11 and Quartz, with X11 and Wayland sharing a common
'DBus' superclass.

                             GtkApplicationImpl
                                      |
                       /--------------+-------------------\
                       |                                  |
            GtkApplicationImplDBus              GtkApplicationImplQuartz
                       |
           /-----------+-----------------\
           |                             |
  GtkApplicationImplX11      GtkApplicationImplWayland

GtkApplicationImpl itself is essentially a bunch of vfuncs that serve as
hooks for various things that the platform-specific backends may be
interested in doing (startup, shutdown, managing windows, inhibit, etc.)

With this change, all platform specific code has been removed from
gtkapplication.c and gtkapplicationwindow.c (both of which are now free
of #ifdefs, except for a UNIX-specific use of GDesktopAppInfo in
gtkapplicationwindow.c).

Additionally, because of the movement of the property-setting code out
of GtkApplicationWindow, the _GTK_APPLICATION_ID properties (and
friends) will be set on non-GtkApplicationWindows, such as dialogs.

https://bugzilla.gnome.org/show_bug.cgi?id=720550
2013-12-16 13:51:54 -05:00