Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix return from fullscreen for linux/gnome not returning to previous size. #3004

Merged
merged 1 commit into from

5 participants

@nikolai-r

Seems I am not the only one with this issue. Not sure the exact test cases that cause this issue but under linux/gnome when returning from fullscreen mode to window mode. There is a window resize event sent to XBMC after exiting fullscreen that sets it to the size of current desktop resolution after setting it to the previous window size, resulting in an unwanted maximized window. This simple fix just checks if the resize event is the same dimensions as the desktop resolution while NOT in fullscreen to avoid a resize. Has only been tested on linux mint 15 (cinnamon). Since this case should never happen anyways seems like a reasonable quick fix. Possible to cause resize issues with hidden task bars when maximizing the widow though, this is untested.

@FernetMenta
Collaborator

This should not be handled in application. Windowing has to cope with this.

@nikolai-r

Code moved.

xbmc/Application.cpp
@@ -486,11 +486,12 @@ bool CApplication::OnEvent(XBMC_Event& newEvent)
if (!g_application.m_bInitializing &&
!g_advancedSettings.m_fullScreen)
{
- g_Windowing.SetWindowResolution(newEvent.resize.w, newEvent.resize.h);
- g_graphicsContext.SetVideoResolution(RES_WINDOW, true);
- CSettings::Get().SetInt("window.width", newEvent.resize.w);
- CSettings::Get().SetInt("window.height", newEvent.resize.h);
- CSettings::Get().Save();
+ if(g_Windowing.SetWindowResolution(newEvent.resize.w, newEvent.resize.h)) {
+ g_graphicsContext.SetVideoResolution(RES_WINDOW, true);
+ CSettings::Get().SetInt("window.width", newEvent.resize.w);
+ CSettings::Get().SetInt("window.height", newEvent.resize.h);
+ CSettings::Get().Save();
+ }
@elupus Collaborator
elupus added a note

Wrong indentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@FernetMenta
Collaborator

what I meant is that application should not bothered with special cases going just wrong on a single platform. I think the reason for this issue is SDL. It operates with three windows and WinEventsSDL may catch a ConfigureNotify event from an invisible one.

This issue might already be fixed by the drop SDL branch which you can try in a slightly modified form here:
https://github.com/FernetMenta/xbmc

In case you want to fix this for the current version, I would suggest that you filter the event in here:
https://github.com/xbmc/xbmc/blob/master/xbmc/windowing/WinEventsSDL.cpp#L364

Note that it may desired to have the windowed size the same as full screen.

@nikolai-r

I do agree it was just a quick fix and that a case where it would be desired to have the resolution the same as the fullscreen while not in fullscreen is possible. It was less likely then the resize problem that currently existed. It would always be better to solve the root of the problem then filtering it out anyways.

This branch does indeed solve the problem.

@nikolai-r

Reverted and moved to CWinEventsSDL::MessagePump as Fernet mentioned the problem was likely SDL and after a quick test this proved correct.

xbmc/windowing/WinEventsSDL.cpp
@@ -363,13 +365,18 @@ bool CWinEventsSDL::MessagePump()
}
case SDL_VIDEORESIZE:
{
- XBMC_Event newEvent;
- newEvent.type = XBMC_VIDEORESIZE;
- newEvent.resize.w = event.resize.w;
- newEvent.resize.h = event.resize.h;
- ret |= g_application.OnEvent(newEvent);
- g_windowManager.MarkDirty();
- break;
+ if (!g_advancedSettings.m_fullScreen) {
@FernetMenta Collaborator

we use gnu style: curly brackets next line, then two white space indentation.

I think CGraphicContext::IsFullScreenRoot() is better than using advanced settings helper flag.
EDIT: or even better g_windowing.IsFullScreen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@MartijnKaijser

could you please squash all commits to keep a clean merge history

xbmc/windowing/WinEventsSDL.cpp
@@ -363,6 +365,12 @@ bool CWinEventsSDL::MessagePump()
}
case SDL_VIDEORESIZE:
{
+ if(!g_graphicsContext.IsFullScreenRoot())
+ {
+ if((event.resize.w == CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP).iWidth) &&
@FernetMenta Collaborator

did you try the maximize button on the window? does it still work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@FernetMenta
Collaborator

if you add a comment to the code why this is needed and squash your commits, I am fine with it.

@elupus @davilla what do you think?

@nikolai-r nikolai-r referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@nikolai-r
xbmc/windowing/WinEventsSDL.cpp
@@ -363,6 +364,15 @@ bool CWinEventsSDL::MessagePump()
}
case SDL_VIDEORESIZE:
{
+ // Under linux returning from fullscreen, SDL sends an extra event to resize to the desktop
+ // resolution causing the previous window dimensions to be lost. This is needed to rectify
+ // that problem.
+ if(!g_Windowing.IsFullScreen())
+ {
+ if((event.resize.w == CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP).iWidth) &&
+ (event.resize.h == CDisplaySettings::Get().GetResolutionInfo(RES_DESKTOP).iHeight))
+ break;
@elupus Collaborator
elupus added a note

Resolution can be different for different screens. You need to get the resolution for the active screen.

@elupus Collaborator
elupus added a note

g_Windowing.DesktopResolution(g_Windowing.GetCurrentScreen()) returns the resolution index.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@nikolai-r

@FernetMenta @elupus @davilla everyone ok with this then? if so i will squash again

@nikolai-r

squashed, ready for merge if accepted

@davilla
Collaborator

I'm fine, we can always fix any issues that pop up regarding osx.

@FernetMenta
Collaborator

I'm fine too

@davilla
Collaborator

/me summons @MartijnKaijser

@MartijnKaijser

Can't push the button yourself? It's a fix right :)

@davilla davilla merged commit c4622ca into xbmc:master
@Fneufneu Fneufneu referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@elupus elupus commented on the diff
xbmc/windowing/WinEventsSDL.cpp
@@ -363,6 +364,16 @@ bool CWinEventsSDL::MessagePump()
}
case SDL_VIDEORESIZE:
{
+ // Under linux returning from fullscreen, SDL sends an extra event to resize to the desktop
+ // resolution causing the previous window dimensions to be lost. This is needed to rectify
+ // that problem.
+ if(!g_Windowing.IsFullScreen())
+ {
+ int RES_SCREEN = g_Windowing.DesktopResolution(g_Windowing.GetCurrentScreen());
@elupus Collaborator
elupus added a note

Hmm.. RES_SCREEN. I really thought that was a macro first due to the uppercase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@janbar janbar referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 27, 2013
  1. @nikolai-r

    resolve issue #3004

    nikolai-r authored
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 0 deletions.
  1. +11 −0 xbmc/windowing/WinEventsSDL.cpp
View
11 xbmc/windowing/WinEventsSDL.cpp
@@ -26,6 +26,7 @@
#include "Application.h"
#include "ApplicationMessenger.h"
#include "GUIUserMessages.h"
+#include "settings/DisplaySettings.h"
#include "guilib/GUIWindowManager.h"
#include "guilib/Key.h"
#ifdef HAS_SDL_JOYSTICK
@@ -363,6 +364,16 @@ bool CWinEventsSDL::MessagePump()
}
case SDL_VIDEORESIZE:
{
+ // Under linux returning from fullscreen, SDL sends an extra event to resize to the desktop
+ // resolution causing the previous window dimensions to be lost. This is needed to rectify
+ // that problem.
+ if(!g_Windowing.IsFullScreen())
+ {
+ int RES_SCREEN = g_Windowing.DesktopResolution(g_Windowing.GetCurrentScreen());
@elupus Collaborator
elupus added a note

Hmm.. RES_SCREEN. I really thought that was a macro first due to the uppercase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if((event.resize.w == CDisplaySettings::Get().GetResolutionInfo(RES_SCREEN).iWidth) &&
+ (event.resize.h == CDisplaySettings::Get().GetResolutionInfo(RES_SCREEN).iHeight))
+ break;
+ }
XBMC_Event newEvent;
newEvent.type = XBMC_VIDEORESIZE;
newEvent.resize.w = event.resize.w;
Something went wrong with that request. Please try again.