[PATCH 4/6] compositor-drm/shell: Allow restore_output_mode() to work properly.

Mario Kleiner mario.kleiner.de at gmail.com
Tue Apr 21 22:37:41 PDT 2015


On 04/16/2015 06:43 PM, Derek Foreman wrote:
> On 02/04/15 12:10 AM, Mario Kleiner wrote:
>> Initialize output->native_mode with the initially chosen
>> mode for an output, so restore_output_mode() has something
>> to work with and can switch back from temporary selected modes
>> to the outputs native mode. Before, this was a no-op.
>>
>> This allows an output to switch back to its default mode if
>> a former toplevel fullscreen shell surface created via method
>> WL_SHELL_SURFACE_FULLSCREEN_METHOD_DRIVER gets destroyed, or
>> demoted to non-fullscreen, or if modesetting on the output
>> failed.
>>
>> Also fix desktop-shell's activate method to only restore
>> output mode on the output on which a shell surface gets
>> activated. This way fullscreen windows can mode switch their
>> output, but window switching and exposay still works in the
>> expected way.
>>
>> Signed-off-by: Mario Kleiner <mario.kleiner.de at gmail.com>
>> ---
>>   desktop-shell/shell.c | 3 ++-
>>   src/compositor-drm.c  | 4 ++++
>>   2 files changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
>> index 7d0e403..68846ed 100644
>> --- a/desktop-shell/shell.c
>> +++ b/desktop-shell/shell.c
>> @@ -2962,6 +2962,7 @@ shell_configure_fullscreen(struct shell_surface *shsurf)
>>   							 output->y - surf_y);
>>   				break;
>>   			} else {
>> +				weston_log("shell: Can't switch to temporary mode.\n");
>>   				restore_output_mode(output);
>>   				center_on_output(shsurf->view, output);
>>   			}
>> @@ -5089,7 +5090,7 @@ activate(struct desktop_shell *shell, struct weston_surface *es,
>>   	if (shsurf->state.fullscreen && configure)
>>   		shell_configure_fullscreen(shsurf);
>>   	else
>> -		restore_all_output_modes(shell->compositor);
>> +		restore_output_mode(shsurf->output);
>>
>>   	/* Update the surface’s layer. This brings it to the top of the stacking
>>   	 * order as appropriate. */
>
> I think above and below this point should be two separate patches.

Yes, makes sense. I'll split it into separate patches.

>
>> diff --git a/src/compositor-drm.c b/src/compositor-drm.c
>> index 4a7baa1..9ddb6d6 100644
>> --- a/src/compositor-drm.c
>> +++ b/src/compositor-drm.c
>> @@ -2209,6 +2209,10 @@ create_output_for_connector(struct drm_compositor *ec,
>>   				    connector->count_modes == 0 ?
>>   				    ", built-in" : "");
>>
>> +	/* Initialize output->native_mode field, so restore_output_mode() works. */
>> +	weston_output_mode_set_native(&output->base, output->base.current_mode,
>> +								  output->base.current_scale);
>> +
>>   	return 0;
>>
>>   err_output:
>>
>
> I'm not sure this is right - I think just setting
> output->base.native_mode = output->base.current_mode would have the same
> end result without triggering all the mode switch related machinery?
>

Yes, it would do the same thing. weston_output_mode_set_native() is a 
no-op apart from that native_mode assignment if current_mode gets set. I 
can change it into that simple assignment if that appears more clean.

thanks,
-mario


More information about the wayland-devel mailing list