Commit graph

391 commits

Author SHA1 Message Date
vitorramos
e5b68871f8 display:Fix null pointer dereference 2020-12-13 22:51:09 +00:00
Benjamin Berg
43b444fba3 display: Try harder to select a good and working scale
When swicthing configurations, we should ensure that the selected scale
is valid. This is complicated by the fact that it depends on other
factors whether we need a single global scale or not.

Try to retain the scale that monitors have if possible. If that does not
work, try to use the old scale of the primary monitor everywhere. This
should result in a good behaviour in most situations.

Co-authored-by: Stéphane Travostino <steph@combo.cc>

Fixes: #1038
2020-10-29 20:27:29 +00:00
Benjamin Berg
66c81d8128 display: Fix possible recursion when configuration type changes
The UI rebuilding code may change the configuration type, which in turn
can trigger a UI rebuild. This should not be done if we are already
updating the UI (but must be done otherwise, as that means the user has
chosen to change the configuration).

Fixes: #1141
2020-10-12 03:22:15 +00:00
Carlos Garnacho
6782bc07db display: Hook to PanelOrientationManaged for accelerometer checks
This property gives means for Mutter to determine who is in charge of
display rotation for the built-in panel (us or Mutter). The UI must
reflect this change.

Fixes: https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1018
2020-09-05 08:03:44 +00:00
Carlos Garnacho
c89f5ca526 display: Add panel-orientation-managed signal to CcDisplayConfig
So we can track changes on this property.
2020-09-05 08:03:44 +00:00
Carlos Garnacho
b91a83c402 display: Add API to get the PanelOrientationManaged DisplayConfig property
This property indicates whether the builtin panel orientation is managed by
an accelerometer, thus shouldn't be managed by the display panel.
2020-09-05 08:03:44 +00:00
Carlos Garnacho
1ae3ebcfb2 display: Use a proxy for org.gnome.Mutter.DisplayConfig
It will be more convenient than a direct DBus call in future commits.
2020-09-05 08:03:44 +00:00
Adrien Plazas
fd60c313df Stop using HANDY_USE_UNSTABLE_API
It isn't needed anymore since libhandy 0.90.0.
2020-08-18 02:51:04 +00:00
Adrien Plazas
0c71793e7c Stop using the action HdyActionRow child type
It has been dropped and is now the default child type.
2020-07-20 08:04:28 +02:00
Adrien Plazas
f06379e30c Replace HdyColumn by HdyClamp
In libhandy 1, HdyClamp replaces HdyColumn. This stops setting values
when they match HdyClamp's defaults.
2020-07-20 08:04:28 +02:00
Robert Ancell
d82f241a9f display: Add missing parameter checks on CcDisplayConfig methods
Closes #945
2020-04-14 11:25:33 +12:00
Robert Ancell
c0cfbeccff display: Connect signals with g_signal_connect_object in swapped form 2020-03-30 16:18:50 +13:00
Robert Ancell
f00a5e20cb display: Fix wrong widget type used 2020-03-30 01:45:57 +00:00
Robert Ancell
73469d3ba2 display: Replace GtkStack child names with widget references
The child names are easier to break if widgets are changed - this can't be
detected by the compiler.
2020-03-30 01:45:57 +00:00
Jian-Hong Pan
00081c434c display: Fix the resolution going to be tested
Gnome-control-center checks the display modes by
cc_display_config_is_scaled_mode_valid()
  ...
  cc_display_config_dbus_is_scaled_mode_valid()
to exclude unusable low resolutions.

However, it is the current using resolution that going to be tested by
is_scaled_mode_allowed() in is_scale_allowed_by_active_monitors(), if it
is global scaled required or configured as cloning mode originally.
Therefor, it will check current using resolution again and again,
instead of the enumerated one. This leads gnome-control-center building
wrong resolution list on the panel.

This patch replaces the current mode with the enumerated mode to have
the correct resolution to be tested by is_scaled_mode_allowed().

Fixes #903
2020-03-10 17:49:22 +08:00
Robert Ancell
93b14a4339 panel: Move shared GCancellable code into panel class
Make the panel class provide a cancellable that will be cancelled when the panel
is destroyed. Panel implementations can use this and not have to mangage the
cancellable themselves. Consolidate cases where panels had multiple cancellables
that were all being used for this behaviour.
2020-02-03 09:36:24 +13:00
Robert Ancell
19ccad96ae Whitespace fixes for g_autoptr coding style 2019-11-08 09:42:10 +13:00
Mohammed Sadiq
af76f51976 display: Reduce some margins in night light page
So that the display panel can reach smaller widths
2019-11-06 17:12:27 +00:00
Benjamin Berg
0fa4d11477 display: Use correct mode for supported scale checking
Monitors may not always have a mode. This means we cannot look up the
mode on the fly, but instead need to have a heuristic to select a mode
if there is none.

Everything was in place already for this, except that one location was
still doing a fresh lookup, possibly causing a crash.

Fixes: #675
2019-10-21 16:22:25 +13:00
Will Thompson
fd93886f6f display: mark 3 missed translatable strings
"Primary Display" and "Contains top bar and Activities" are visible when
you have >1 display connected and the "Join Displays" option is
selected. I can't work out how to see the "Active Display" string but it
sure looks translatable to me.
2019-10-03 17:18:00 +01:00
Robert Ancell
9a2e821fe5 Initialize autoptr values to NULL.
These cases were safe, but if the code changed this risked freeing uninitialized
memory.
2019-10-03 10:58:38 +13:00
Georges Basile Stavracas Neto
f43238473a display: Replace CC_DISPLAY_*_GET_PRIVATE
Replace the custom and deprecated CC_DISPLAY_*_GET_PRIVATE by
the automatically generated cc_display_*_get_instance_private
functions.
2019-09-10 11:40:39 +00:00
Robert Ancell
97985a664e Remove unused GNOMELOCALEDIR defines 2019-09-09 21:45:53 +00:00
Benjamin Berg
4e800cc558 display: Consider monitors in landscape mode for minimum size
Some devices have panels with a native resolution in portrait mode. In
these cases the monitor will likely be used in landscape mode.

Accept the modes as if they are landscape rather than portrait. A
further improvement would be to restrict the orientation setting.

Fixes #639
2019-08-27 13:43:29 +00:00
Benjamin Berg
6d16bf7337 display: Increase the trough size using a different method
Increasing the trough size by setting the min-height caused issue when
the scale was being fine-tuned. Changing the padding seems to have a
similar effect without triggering any such issue (with Adwaita).

Fixes #335
2019-08-25 09:16:46 +00:00
Benjamin Berg
ca684c2a7c display: Update night light scale to new blackbody calculation
g-s-d was changed to use a better black body temperature calculation.
This strongly affects the effect of the color temperature (the default
is changed from 4000K to 2700K). Update the scale to represent a similar
range to default even if the distribution on the scale is quite
different.
2019-07-30 10:47:36 +02:00
Benjamin Berg
345a819f84 display: Add guards for NULL display configuration
This may happen under some conditions. Possibly due to a race condition
(i.e. we did not receive any configuration from mutter yet) or also if
we are not running on GNOME.

Add guards for NULL configuration. This configuration is never
applicable and mostly clears the UI.

Fixes: #604
2019-07-20 02:23:53 +00:00
Benjamin Berg
561ac849d7 display: Add failure returns into CcDisplayConfig
This guards against accidental use of NULL pointers so that the panel
will hopefully not crash if new bugs like this are introduced.
2019-07-20 02:23:53 +00:00
Benjamin Berg
3721f9ed4a display: Update ShowMonitorLabels DBus call
The function has been changed in gnome-shell to be called ShowMonitorLabels
again (rather than ShowMonitorLabels2). Update g-c-c accordingly.

See https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/491
2019-07-15 09:21:23 +00:00
Benjamin Berg
6ed523959d display: Show scale row unconditionally
The only functional change in this commit is the reval of the if that is
checking for cloning mode.
2019-07-15 03:14:24 +00:00
Benjamin Berg
5aac1e93f2 display: Check scale is valid for all monitors when mirroring 2019-07-15 03:14:24 +00:00
Benjamin Berg
9e4c6e89a0 display: Use the new API to determine whether a scale is valid 2019-07-15 03:14:23 +00:00
Marco Trevisan (Treviño)
9ef001b3b1 display-config: Add size constraints and (global) scaled mode checks
Make possible to set scaled size constraints per configuration, and add a method
to verify if the current mode at scale is allowed for such config.

This allows to perform such check also in case we have global scaling enabled,
as in such case we must verify that all the selected current modes are supported
by the given scale.

Fixes GNOME/mutter#407
2019-07-15 03:14:23 +00:00
Allan Day
3d9649577a display: improve time widget spacing
It's good to have some space between the to and from widgets, so
they aren't squashed, and so they blend better with the colour
temperature slider below.

Ideally we'd just increase the space between the to and from
sections, and not also between the widgets and their labels, but
the approach in this commit isn't too bad.
2019-06-17 11:44:06 +01:00
Allan Day
c8c6d51fd0 display: Improve Night Light settings labels
Make sure that the labels in the night settings are clear.

Fixes #583
2019-06-17 11:41:26 +01:00
Georges Basile Stavracas Neto
28b0acb24e display: Rework Night Light page
The new Night Light page, as described by the latest mockups [1],
uses a listbox to display the options. Also, there is a small
revamp on how the disabled state is handled; it now is a switch
in a row, instead of an extra radio button.

This commit changes the Night Light page to have a listbox, and
uses libhandy's rows to achieve the desired interface.

Fixes https://gitlab.gnome.org/GNOME/gnome-control-center/issues/533
2019-06-16 01:01:36 +00:00
Georges Basile Stavracas Neto
50be7b13c8 display: Make night light a panel page
This introduces a GtkStack to handle the pages; move the
current panel to be the "displays" page; and adds the
Night Light page as "night-light".

A stack switcher was added, as a header widget, to control
the stack.

https://gitlab.gnome.org/GNOME/gnome-control-center/issues/533
2019-06-16 01:01:36 +00:00
Georges Basile Stavracas Neto
b46aef0cb6 display: Make night light dialog a GtkBin
And create the dialog manually instead. The next commit
will move it to a different page in the panel itself,
so not much care was put into makin the dialog perfectly
matching.

https://gitlab.gnome.org/GNOME/gnome-control-center/issues/533
2019-06-16 01:01:36 +00:00
Benjamin Berg
f75c3a8471 display: Fix crash if a monitor has no preferred mode
When a monitor has no current mode set and also no preferred mode we ran
into a crash. Simply select the first mode we can find as a further
fallback.
2019-04-30 14:16:17 +00:00
Sebastien Bacher
8541ef9e46 Include glib/gi18n.h which is needed for gettext 2019-04-10 11:27:14 +02:00
Sebastien Bacher
1268137e63 night-light: set screen temperature strings as translatable
Fixes #437
2019-04-09 21:07:12 +02:00
Veerasamy Sevagen
bf3d97e50d panels/display/cc-display-settings.ui: Adding context to "Scale"
The title property for "Scale" did not have any context.
2019-03-29 18:50:04 +00:00
Benjamin Berg
b26a8bdeed display: Ensure configuration has the expected type
In almost all cases, the configuration will be "valid" in the sense that
g-c-c can represent it in the UI. However, there are cases like
mirroring setups with three monitors that we do not allow.

In case that the user has such a configuration, ensure that the
configuration we represent is actually valid according to our
expectations. This should not affect normal use cases, but allows users
to recover again if the configuration is broken for some reason.

Fixes #383
2019-03-20 18:01:01 +01:00
Benjamin Berg
f45dcff81f display: Ensure at least one display is enabled
When the user has more than two monitors, then they can disable each
monitor separately. If the user creates an invalid configuration because
they disabled the last monitor, then enable a different one immediately.
2019-03-20 18:01:01 +01:00
Benjamin Berg
defbcebfab display: Simplify configuration type and UI selection logic
The new logic selects a single configuration type rather than detecting
which types can be considered valid. This simplifies the UI rebuilding
somewhat, but also changes some internal behaviour. We will now always
be in the correct mode internally, even if the UI may not represent this
change (i.e. with more than two monitors it always looks the same).
2019-03-20 18:01:01 +01:00
Benjamin Berg
b2f1d489ad display: Add unusable monitors to dropdown and disable switch for them
We should show unusable monitors in the monitor selection drop-down
list. So always add them to the combobox and add the code to make the
switch to enable them insensitive.
2019-03-20 18:01:01 +01:00
Benjamin Berg
e387b3bb86 display: Only enforce single mode when desired by UI
We should only enforce single mode, when we have exactly two monitors
and the two button UI is used to switch between them in single mode.
Move the code to ensure the single configuration into the relevant
callback handler, rather than trying to solve this globally.
2019-03-20 18:01:01 +01:00
Benjamin Berg
98d20659b7 display: Make rebuilding variable a counter
We need to also set rebuilding while updating some other UI elements.
Make it into a counter to allow for recursive setting.
Note that additional checks for rebuilding will be added in later
commits.
2019-03-20 17:58:29 +01:00
Benjamin Berg
21bb6416be display: Reset resolution when switching configuration types
It generally makes more sense to reset the resolution of a monitor after
we switch configuration types. The main case where this is relevant is
switching from a mirror configuration (CLONE) to either join or single.
In this case, higher resolutions for monitors may become available.

Note that this might be annoying to some users, because there may be
monitors reporting a lower "preferred" resolution than the highest
supported resolution. There is little we can do though, as always
selecting the highest resolution doesn't seem like a much better
approach.
2019-03-20 17:26:56 +01:00
Benjamin Berg
ae22f72cac display: Prevent error when serializing invalid configuration
If no monitors are enabled, then the variant would end up with an
invalid variant type, causing a crash later on. This case only happened
due to other bugs (i.e. in principle we should never send a
configuration without any monitors to the server).

Prevent the serialization error by specifying the correct type for the
builder, therefore potentially preventing a crash in such a corner case.
2019-03-20 17:26:56 +01:00