Commit Graph

145 Commits

Author SHA1 Message Date
Niels De Graef
28ab1f4af4 Ensure G_PARAM_STATIC_STRINGS for all properties
In `st`, we can do this by using `ST_PARAM_*`. In the other code files,
just use `G_PARAM_STATIC_STRINGS` directly.

This is just a minor convenience to prevent a few unnecessary string
copies.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/646
2019-07-30 13:58:44 +00:00
Laurent Bigonville
58c4212cfa shell-app: Fix spelling error
https://gitlab.gnome.org/GNOME/gnome-shell/issues/1205
2019-06-15 12:08:40 +02:00
Carlos Garnacho
5a9d094f3e shell: Use MetaDisplay input focus API
Replaces use of (now removed) MetaX11Display focus API (which happened to
work for wayland too).

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/378
2019-05-24 12:24:06 +02:00
Simon McVittie
0f531d8c44 ShellApp: Use g_signal_connect_object for window signals
A window being unmanaged can cause the ShellApp to be removed from
the ShellAppSystem, which if we are unlucky is the app's last
reference, causing it to be disposed and freed. It would be bad if this
happened before we finished handling the signal.

Use g_signal_connect_object to ensure that a reference is held to
the ShellApp for the duration of the signal handler, delaying its
last-unref.

In particular, when a signal handler calls _shell_app_remove_window(),
there is a brief period for which ShellApp breaks the intended
invariant (see !497) that app->running_state is non-NULL if and only if
app->running_state->windows is also non-NULL (non-empty). Freeing the
ShellApp at this point would cause a crash. This seems likely to be the
root cause of <https://gitlab.gnome.org/GNOME/gnome-shell/issues/750>,
<https://gitlab.gnome.org/GNOME/gnome-shell/issues/822> and
<https://bugs.debian.org/926212>.

Signed-off-by: Simon McVittie <smcv@debian.org>
2019-04-23 12:51:56 +00:00
Florian Müllner
1767cd0f6c app: Consider "quit" action for quit
Just like we take a remote "new-window" action into account for
opening new windows, we should call an explicit "quit" action
before falling back to closing all the app's windows on quit.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/624
2019-03-28 00:02:20 +00:00
Florian Müllner
4f65283f31 app: Set styleclass on fallback app icons
For window backed apps, create_icon_texture() doesn't return an StIcon
but a generic widget. Set an appropriate style class to make it easier
to apply a specific style only to fallback icons.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1027
2019-03-08 16:20:21 +01:00
Florian Müllner
6f794738e8 texture-cache: Load bound surfaces into StWidgets
Using widgets instead of plain actors will allow us to set the size
from CSS.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/1027
2019-03-08 16:20:21 +01:00
Marco Trevisan (Treviño)
19c60ff5c5 st-texture-cache: use StImageContent for cairo bound surface
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/5
2019-03-01 17:12:53 +00:00
Florian Müllner
753618a19f app: Remove :menu property
It is now unused.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/624
2019-02-06 18:29:15 +01:00
Florian Müllner
e355756758 app: Don't rely on app menu to check for GtkApplications
As the app menu is being phased out, it is no longer a good indicator
for GtkApplications. Instead, base the check directly on the appropriate
D-Bus properties.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/624
2019-02-06 18:29:15 +01:00
Florian Müllner
446183adee app: Remove unused code
This was overlooked back in the day when application search moved into GIO.
2019-02-05 01:54:17 +01:00
Georges Basile Stavracas Neto
69b1fb699f
app: Replace ClutterTexture by ClutterActor
It apparently uses no ClutterTexture specifics, and instead
only tries to match what StTextureCache used to return.

Since StTextureCache now returns ClutterActor, also use a
ClutterActor on ShellApp.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/373
2019-01-29 17:11:13 -02:00
Carlos Garnacho
10b3671a99 shell: Use MetaStartupNotification
This is "API compatible" with ShellStartupNotification, so only
C changes are necessary.
2018-11-23 13:58:35 +01:00
Florian Müllner
87a645aa2b app: Close all closable windows from quit()
There's no relation between a window being hidden from overview/taskbars
and a window not being closable - currently we effectively disable the
fallback quit action for any application with open transients, which
simply doesn't make sense.

Instead, only exclude windows for which the close action has been
explicitly disabled.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/217
2018-09-13 10:54:39 +00:00
Daniel Drake
4b522a02c3 shell-app: remove child_setup from app launching
When the amount of free memory on the system is somewhat low, gnome-shell
will sometimes fail to launch apps, reporting the error:
  fork(): Cannot allocate memory

fork() is failing here because while cloning the process virtual address
space, Linux worries that the thread being forked may end up COWing the
entire address space of the parent process (gnome-shell, which is
memory-hungry), and there is not enough free memory to permit that to
happen. This check is somewhat irrelevant because we are only forking
to immediately exec(), which will discard the whole virtual address
space anyway.

This issue can be avoided by using a new optimized gspawn codepath in
the latest glib development version, which uses posix_spawn() internally.

For the optimized codepath to be used, we must not pass a child_setup
function, so the the file descriptor management is reimplemented here
using new glib API to pass fds to the child process. The old API will
continue to be used on older glib versions.

We must also change the spawn flags for this code path to be hit.
I checked that gnome-shell's open file descriptors are all CLOEXEC
so using G_SPAWN_LEAVE_DESCRIPTORS_OPEN should be safe.

This will result in more resilient app launching when memory is low,
since the optimized spawn path avoids cloning the virtual address
space of the parent process (gnome-shell) and avoids the irrelevant
memory overcommit check.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/132
2018-07-30 23:11:41 +00:00
Florian Müllner
3efd296fc3 app: Consider "new-window" action for opening new windows
While can_open_new_window() uses some elaborate heuristics to predict
whether an application can open multiple windows, open_new_window()
will always simply relaunch the application. This is often the best
we can do, but when an application provides a "new-window" action in
its .desktop file or on the bus, it is much more likely to work as
expected than blindly activating the app and hoping for a particular
behavior.

https://bugzilla.gnome.org/show_bug.cgi?id=756844
2018-07-30 19:21:40 +00:00
Jonas Ådahl
47ea10b7c9 Remove usage of MetaScreen
Remove any usage of MetaScreen, as it has been removed from libmutter
in the API version 3. The corresponding functionality has been moved
into three different places: MetaDisplay, MetaX11Display (for X11
specific functionality) and MetaWorkspaceManager.

https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:56:19 +02:00
Mario Sanchez Prada
b5f5a594ba shell-app: Don't transition to STOPPED while still in the STARTING state
Similar to what it's done in _shell_app_add_window(), rely on calling
shell_app_sync_running_state() when removing windows too, to avoid
transitioning to STOPPED while it's still in the STARTING state.

This makes the logic compliant with the startup notification spec and
prevents stopping an application too early if it has a splash screen
that has been closed before the application's main window is shown.

https://bugzilla.gnome.org/show_bug.cgi?id=787905
2017-09-29 18:10:23 +01:00
Florian Müllner
053b8da89c app: Work around pkexec restriction when launching
Unless automatic child reaping is disabled in GSpawnFlags, glib's
g_spawn_* functions will reparent the spawned process to init by
double-forking. Unfortunately pkexec bails out in this case[0],
which means that it no longer works in .desktop files since the
PID tracking removal in commit 01c6392c13.
Fix this by going back to manual child reaping.

[0] https://cgit.freedesktop.org/polkit/tree/src/programs/pkexec.c#n728

https://bugzilla.gnome.org/show_bug.cgi?id=763531
2017-09-12 17:32:51 +02:00
Bastien Nocera
39a840e2c3 shell-app: Add "discrete_gpu" option when launching apps
And adapt existing callers to the new API. This will allow us to
implement a way to launch applications on the discrete GPU for systems
where an "Optimus" system exists.

https://bugzilla.gnome.org/show_bug.cgi?id=773117
2016-10-21 19:26:49 +02:00
Florian Müllner
2f0039e7dd app: Add a construct-only app-info property
This will allow us to create a ShellApp from JS code, for instance
for .desktop files that aren't known to the AppSystem.

https://bugzilla.gnome.org/show_bug.cgi?id=762206
2016-07-13 01:28:13 +02:00
Florian Müllner
84da49c715 app: Consider minimized windows for app comparisons
We used to take window visibility into account when comparing apps
until commit 1dfc38d078, following changes in the window switcher
due to auto-minimization. However auto-minimization was abolished
and the window switcher changes reverted, so it makes sense again
to sort apps without non-minimized windows last again.

https://bugzilla.gnome.org/show_bug.cgi?id=766238
2016-05-10 21:36:33 +02:00
Owen W. Taylor
db297e7fdb Don't crash on accesses to stale window-backed apps
The JS code could still be holding on to a reference to a window-backed app
after all windows have vanished. (For example, the dash queues an idle to
refetch apps and display them.) Avoid dying with an error message if we
attempt to activate or otherwise manipulate such a window.

https://bugzilla.gnome.org/show_bug.cgi?id=674799
2015-10-11 15:31:39 -04:00
Florian Müllner
3e10574736 shell: Add default case to switch statements
... to shut up a compiler warning.
2015-09-23 21:32:50 +02:00
Florian Müllner
825146f1e3 shell: Fix signed-unsigned comparisons 2015-09-23 21:32:50 +02:00
Jasper St. Pierre
7424ee755a shell-app: Stay consistent about application states
When the last interesting window of an app-backed window is removed,
we'll transition it back to STOPPED, but we transition the state and
send out the signal before we clear the running state.

This means that any listeners to the state-changed signal might
encounter a window-backed app that has a running state, but no
windows. If they call, e.g. shell_app_get_name, while in this state,
they'll encounter an assertion fail.
2015-07-16 17:09:39 -07:00
Jasper St. Pierre
ff664fd1d8 shell-app: Track the starting state correctly
Apps that are starting might have uninteresting windows like splash
screens pop up and then go away (like LibreOffice), even when
startup-notification hasn't completed yet. In those cases, we don't
want to transition the app back to stopped -- it should remain in
the running state.
2015-07-16 15:21:57 -07:00
Cosimo Cecchi
f812e9be7d ShellApp: use st_icon_set_fallback_icon_name() to specify app fallback
We can now safely pass a NULL GIcon to st_icon_set_gicon(), and specify
a more generic fallback using the new API we just introduced.

https://bugzilla.gnome.org/show_bug.cgi?id=746219
2015-03-14 17:31:07 -07:00
Jasper St. Pierre
71ae7e69c5 shell-app: Remove leftover struct 2015-02-20 17:40:45 -08:00
Carlos Soriano
ef3285d5e7 shell-app: Remove shell_app_get_faded_icon
In previous commit we removed the only use of shell_app_get_faded_icon
so we can remove the function on shell-app as well.

https://bugzilla.gnome.org/show_bug.cgi?id=744680
2015-02-20 15:14:44 +01:00
Florian Müllner
21056a967f Revert "shell-app: Fix typo"
This reverts commit ead4c2b863.
2015-01-30 18:01:57 +01:00
Florian Müllner
ead4c2b863 shell-app: Fix typo
Commit 086fcd4a32 broke the build, use the correct variable to fix.

https://bugzilla.gnome.org/show_bug.cgi?id=743729
2015-01-30 17:59:30 +01:00
Jasper St. Pierre
086fcd4a32 shell-app: Only raise windows on the same workspace when activating them
For some reason, we never did this, even though this is what the comment
says we should be doing.
2015-01-30 11:36:45 -05:00
Rui Matos
af889168f0 StTextureCache: adapt to MetaWindow changing icon prop type
Mutter change is
https://git.gnome.org/browse/mutter/commit/?id=af7f51b992b20da543312fa9fdf1dcef39704b37

https://bugzilla.gnome.org/show_bug.cgi?id=742824
2015-01-13 15:58:45 +01:00
Sebastian Keller
01c6392c13 window-tracker: remove now unused launched_pid_to_app
https://bugzilla.gnome.org/show_bug.cgi?id=736527
2014-12-28 16:40:20 -08:00
Florian Müllner
cad56c871a app: Respect icon-style for faded icon texture
Just like regular application icons, the faded icon texture used
in the app menu should follow the theme's icon style setting.

https://bugzilla.gnome.org/show_bug.cgi?id=740447
2014-11-29 18:13:03 +01:00
Florian Müllner
0acc7ed4c2 app: Use StIcon as icon_texture when loading from a GIcon
Themes - namely the HighContrast one - may now request symbolic
icons rather than fullcolor ones. In order to have recoloring
work as expected in that case, we will need a theme node to pick
up colors from - using an StIcon instead of manually loading a
texture from the cache gives us that for free, so do that.

https://bugzilla.gnome.org/show_bug.cgi?id=740447
2014-11-29 18:13:03 +01:00
Phillip Wood
546ae00854 Add busy property to ShellApp
Using a separate property to show when the application is busy rather
than cramming it into the state property makes the code clearer. In most
places we only care if an app is running or not, not whether it is
actually busy.

https://bugzilla.gnome.org/show_bug.cgi?id=736492
2014-11-27 10:59:55 +00:00
Phillip Wood
e00bfcc2cf Use org.gtk.Application proxy to monitor app's busy state
This simplifies the code and fixes a race where an application could
call g_application_mark_busy() before the shell subscribed to change
notifications on the application's busy state.

https://bugzilla.gnome.org/show_bug.cgi?id=736492
2014-11-27 10:59:55 +00:00
Jasper St. Pierre
0810ab62db Port to cogl_texture_2d_new_from_data 2014-08-07 14:49:55 -04:00
Giovanni Campagna
3182aba744 AppDisplay: don't show a "New Window" menu item if not possible
If the application reports itself as single window (through
an explicit indication in the desktop file or some heuristics),
not show a "New window" item that doesn't actually open a new window.

https://bugzilla.gnome.org/show_bug.cgi?id=722554
2014-08-01 11:45:18 +02:00
Florian Müllner
93c9e031e3 Update (allow-none) annotations
The annotation has been deprecated in favor of (nullable) and/or
(optional).
2014-05-28 22:01:55 +02:00
Giovanni Campagna
d555fd7883 ShellApp: remove impossible check
The action muxer is created and destroyed with the running state,
it can never be NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=722554
2014-02-17 20:44:58 +01:00
Cosimo Cecchi
407dc74502 shell-app: finish support for loading with scale
https://bugzilla.gnome.org/show_bug.cgi?id=705410
2014-02-16 07:49:24 -08:00
Cosimo Cecchi
e5e764b402 texture-cache: require icon scale to load gicon
To support HiDpi.

https://bugzilla.gnome.org/show_bug.cgi?id=705410
2014-02-16 07:49:24 -08:00
Florian Müllner
2fba8e29e0 shell-app: Rename internal function as suggested in review
Ooops, this was meant to be squashed with commit d44f40d105.
2014-01-31 13:59:30 +01:00
Florian Müllner
b4680a5c25 Use meta_window_is_skip_taskbar() directly
Rather than going through ShellWindowTracker, we can just clean up
the code to use the underlying MetaWindow property directly.

https://bugzilla.gnome.org/show_bug.cgi?id=723308
2014-01-31 13:49:07 +01:00
Florian Müllner
d44f40d105 shell-app: Track changes to MetaWindow:skip-taskbar
So far we have assumed that whether or not a window is interesting
is static. In general this is the case, but as it is legal for the
underlying properties to change at any time, there are of course
offenders that actually do this (flash I'm looking at ya).
While we used the property to determine whether a window should be
tracked or not, the worst case was showing windows that should be
hidden or missing windows that should be shown.
However as we nowadays base an app's running state on the number of
interesting windows, we need to be more careful in order to avoid
ending up with running apps with no windows.

https://bugzilla.gnome.org/show_bug.cgi?id=723308
2014-01-31 13:49:07 +01:00
Jasper St. Pierre
36c69124f7 shell-app: Don't crash when trying to dispose
If we dispose a ShellApp that has windows left, then we'll crash
when we remove the last window, as that frees and NULLs out
app->running_state.

https://bugzilla.gnome.org/show_bug.cgi?id=723197
2014-01-29 14:02:26 -05:00
Florian Müllner
73f6e75d8d shell-app: Unref running state when window count drops to zero
With the lastest ShellApp changes, an app is considered stopped
when the last "interesting" window is closed. However the app
may still track non-interesting windows, so if we unref the
running state on the state transition, we hit an assertion later-on
when trying to remove the non-interesting window.
Fix this by keeping the running state around until the last window
is closed.

https://bugzilla.gnome.org/show_bug.cgi?id=722840
2014-01-23 12:45:23 -05:00