summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Waddell <jwaddell@nvidia.com>2017-09-15 14:50:32 -0700
committerAaron Plattner <aplattner@nvidia.com>2017-10-03 10:28:25 -0700
commit3722e02dfa8c0db9ee3f4042a4da42a427540d73 (patch)
treee9bd08fa19eaa84e1eb4bd645f3ff4b471c3e91b
parent34bd15d6822f8789f4ea3a14de7b6578e6c8c44a (diff)
Set Rotation and Reflection to only the current modes when using Basic Configuration
Currently when the Display Configuration page of nvidia-settings is in Basic mode, any changes to the Rotation and Reflection values are applied to all modes for that display. This causes our entire list of metamodes to be updated and when we cancel a modeset, those updated metamodes are not reverted. Even if we do revert them on the server, our internal data structures do not represent these metamodes and resetting the UI to force a sync would cause the loss of all user config options currently chosen but not applied. This change modifies the behavior of Basic Mode configurations that involve rotation and reflection. These changes will make these metamode changes to behave similarly to advanced mode changes in that they will only affect the current metamode. On the UI side, in basic mode, we will make sure that if rotation/reflection is selected and the resolution is changed (effectively changing to a different selected mode) we will make sure the adjustments are carried over to the new mode. A user using the UI exclusively should not see any changes in behavior aside from the actual issue fixed. A user checking the available metamodes on the server would see a difference but it would be identical to the metamodes given by the unchanged Configuration method in Advanced Mode.
-rw-r--r--src/gtk+-2.x/ctkdisplayconfig-utils.c25
-rw-r--r--src/gtk+-2.x/ctkdisplayconfig-utils.h1
-rw-r--r--src/gtk+-2.x/ctkdisplayconfig.c46
-rw-r--r--src/gtk+-2.x/ctkdisplaylayout.c42
4 files changed, 51 insertions, 63 deletions
diff --git a/src/gtk+-2.x/ctkdisplayconfig-utils.c b/src/gtk+-2.x/ctkdisplayconfig-utils.c
index d0aa1ad..40c9c7c 100644
--- a/src/gtk+-2.x/ctkdisplayconfig-utils.c
+++ b/src/gtk+-2.x/ctkdisplayconfig-utils.c
@@ -1651,31 +1651,6 @@ void display_remove_modes(nvDisplayPtr display)
-/*!
- * Sets all the modes on the display to the specified rotation
- *
- * \param[in] mode The display who's modes are to be modified
- * \param[in] rotation The rotation to set
- *
- * \return TRUE if a new rotation was set for at least one mode, FALSE if all
- * of the modes on the display were already set to the rotation given.
- */
-Bool display_set_modes_rotation(nvDisplayPtr display, Rotation rotation)
-{
- nvModePtr mode;
- Bool modified = FALSE;
-
- for (mode = display->modes; mode; mode = mode->next) {
- if (mode_set_rotation(mode, rotation)) {
- modified = TRUE;
- }
- }
-
- return modified;
-}
-
-
-
/** display_free() ***************************************************
*
* Frees memory used by a display
diff --git a/src/gtk+-2.x/ctkdisplayconfig-utils.h b/src/gtk+-2.x/ctkdisplayconfig-utils.h
index f59696a..1bc4f31 100644
--- a/src/gtk+-2.x/ctkdisplayconfig-utils.h
+++ b/src/gtk+-2.x/ctkdisplayconfig-utils.h
@@ -82,7 +82,6 @@ Bool display_has_modeline(nvDisplayPtr display, nvModeLinePtr modeline);
Bool display_add_modelines_from_server(nvDisplayPtr display, nvGpuPtr gpu,
gchar **err_str);
void display_remove_modes(nvDisplayPtr display);
-Bool display_set_modes_rotation(nvDisplayPtr display, Rotation rotation);
/* Metamode functions */
diff --git a/src/gtk+-2.x/ctkdisplayconfig.c b/src/gtk+-2.x/ctkdisplayconfig.c
index d5022a7..b5a8646 100644
--- a/src/gtk+-2.x/ctkdisplayconfig.c
+++ b/src/gtk+-2.x/ctkdisplayconfig.c
@@ -6193,6 +6193,8 @@ static void display_refresh_changed(GtkWidget *widget, gpointer user_data)
gint idx;
nvModeLinePtr modeline;
nvDisplayPtr display;
+ Rotation old_rotation;
+ Reflection old_reflection;
/* Get the modeline and display to set */
@@ -6201,6 +6203,9 @@ static void display_refresh_changed(GtkWidget *widget, gpointer user_data)
display = ctk_display_layout_get_selected_display
(CTK_DISPLAY_LAYOUT(ctk_object->obj_layout));
+ /* Save the current rotation and reflection settings */
+ old_rotation = display->cur_mode->rotation;
+ old_reflection = display->cur_mode->reflection;
/* In Basic view, we assume the user most likely wants
* to change which metamode is being used.
@@ -6225,6 +6230,24 @@ static void display_refresh_changed(GtkWidget *widget, gpointer user_data)
&display->cur_mode->viewPortIn,
&display->cur_mode->viewPortOut);
+ /* If we are in Basic mode, apply the rotation and reflection settings from
+ * the previous mode to the new mode.
+ */
+ if (!ctk_object->advanced_mode) {
+
+ if (display->cur_mode->rotation != old_rotation) {
+ ctk_display_layout_set_display_rotation(
+ CTK_DISPLAY_LAYOUT(ctk_object->obj_layout),
+ display, old_rotation);
+ }
+
+ if (display->cur_mode->reflection != old_reflection) {
+ ctk_display_layout_set_display_reflection(
+ CTK_DISPLAY_LAYOUT(ctk_object->obj_layout),
+ display, old_reflection);
+ }
+ }
+
/* Update the modename */
setup_display_modename(ctk_object);
@@ -6247,6 +6270,8 @@ static void display_resolution_changed(GtkWidget *widget, gpointer user_data)
gint last_idx;
nvSelectedModePtr selected_mode;
nvDisplayPtr display;
+ Rotation old_rotation;
+ Reflection old_reflection;
/* Get the modeline and display to set */
@@ -6265,6 +6290,9 @@ static void display_resolution_changed(GtkWidget *widget, gpointer user_data)
return;
}
+ /* Save the current rotation and reflection settings */
+ old_rotation = display->cur_mode->rotation;
+ old_reflection = display->cur_mode->reflection;
/* In Basic view, we assume the user most likely wants
* to change which metamode is being used.
@@ -6300,6 +6328,24 @@ static void display_resolution_changed(GtkWidget *widget, gpointer user_data)
NULL /* viewPortOut */);
}
+ /* If we are in Basic mode, apply the rotation and reflection settings from
+ * the previous mode to the new mode.
+ */
+ if (!ctk_object->advanced_mode) {
+
+ if (display->cur_mode->rotation != old_rotation) {
+ ctk_display_layout_set_display_rotation(
+ CTK_DISPLAY_LAYOUT(ctk_object->obj_layout),
+ display, old_rotation);
+ }
+
+ if (display->cur_mode->reflection != old_reflection) {
+ ctk_display_layout_set_display_reflection(
+ CTK_DISPLAY_LAYOUT(ctk_object->obj_layout),
+ display, old_reflection);
+ }
+ }
+
/* Update the UI */
setup_display_page(ctk_object);
diff --git a/src/gtk+-2.x/ctkdisplaylayout.c b/src/gtk+-2.x/ctkdisplaylayout.c
index 24f479d..93a4ddd 100644
--- a/src/gtk+-2.x/ctkdisplaylayout.c
+++ b/src/gtk+-2.x/ctkdisplaylayout.c
@@ -4460,9 +4460,7 @@ void ctk_display_layout_set_display_panning(CtkDisplayLayout *ctk_object,
/*!
* Sets the rotation orientation for the display.
*
- * In basic mode, this function will make all modes on the display have the
- * same rotation. In advanced mode, only the current mode will have its
- * rotation orientation modified.
+ * Only the current mode will have its rotation orientation modified.
*
* If a modification occurs, this function will call the modified_callback
* handler registered, if any.
@@ -4475,23 +4473,13 @@ void ctk_display_layout_set_display_rotation(CtkDisplayLayout *ctk_object,
nvDisplayPtr display,
Rotation rotation)
{
- Bool modified;
-
-
if (!display->cur_mode ||
!display->cur_mode->modeline) {
return;
}
- if (ctk_object->advanced_mode) {
- /* In advanced mode, only set the rotation of the current mode */
- modified = mode_set_rotation(display->cur_mode, rotation);
- } else {
- /* In basic mode, make all the modes have the same rotation */
- modified = display_set_modes_rotation(display, rotation);
- }
+ if (mode_set_rotation(display->cur_mode, rotation)) {
- if (modified) {
/* Update the layout */
ctk_display_layout_update(ctk_object);
@@ -4508,9 +4496,7 @@ void ctk_display_layout_set_display_rotation(CtkDisplayLayout *ctk_object,
/*!
* Sets the reflection orientation for the display.
*
- * In basic mode, this function will make all modes on the display have the
- * same reflection. In advanced mode, only the current mode will have its
- * reflection orientation modified.
+ * Only the current mode will have its reflection orientation modified.
*
* If a modification occurs, this function will call the modified_callback
* handler registered, if any.
@@ -4523,33 +4509,15 @@ void ctk_display_layout_set_display_reflection(CtkDisplayLayout *ctk_object,
nvDisplayPtr display,
Reflection reflection)
{
- Bool modified = FALSE;
-
-
if (!display->cur_mode ||
!display->cur_mode->modeline) {
return;
}
- if (ctk_object->advanced_mode) {
- /* In advanced mode, only set the reflection of the current mode */
- if (display->cur_mode->reflection != reflection) {
- modified = TRUE;
- }
- display->cur_mode->reflection = reflection;
- } else {
- nvModePtr mode;
+ if (display->cur_mode->reflection != reflection) {
- /* In basic mode, make all the modes have the same reflection */
- for (mode = display->modes; mode; mode = mode->next) {
- if (mode->reflection != reflection) {
- mode->reflection = reflection;
- modified = TRUE;
- }
- }
- }
+ display->cur_mode->reflection = reflection;
- if (modified) {
/* Update the layout */
ctk_display_layout_update(ctk_object);