Commit 3722e02d authored by Jonathan Waddell's avatar Jonathan Waddell Committed by Aaron Plattner

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.
parent 34bd15d6
......@@ -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
......
......@@ -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 */
......
......@@ -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);
......
......@@ -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;
/* 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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment