[RFC] Un-trapping mouse while running fullscreen (SDL limitation/design-flaw)
#31
I actually submitted a patch (discussion here) for win32 supporting a maximized borderless window on the secondary display that just uses the current resolution of the second monitor. The OSX path already had code to do this, so maybe there is a similar solution for X?

I know on my Linux box I run the resolution for "default: 1280x720 @ 60.00Hz" which is in effect a maximized window, but I only have 1 display.
Reply
#32
CapnBry Wrote:I actually submitted a patch (discussion here) for win32 supporting a maximized borderless window on the secondary display that just uses the current resolution of the second monitor. The OSX path already had code to do this, so maybe there is a similar solution for X?
The x_org/y_org fields of the XineramaScreenInfo struct should contain the offset information. Here's how to get the screen info. However I am massively confused by the XBMC code, and I'm not sure where to make the required changes. Once I get my laptop running in MergedFB mode I'll see if I can get it working with a test app - actual Xinerama is crap because it forces software rendering and XBMC is completely unusable. MergedFB gets around this problem but still provides Xinerama info.

CapnBry Wrote:I know on my Linux box I run the resolution for "default: 1280x720 @ 60.00Hz" which is in effect a maximized window, but I only have 1 display.
This uses SDL_FULLSCREEN. Or did your patch change this? I didn't notice anything.

The current XBMC code actually makes use of the Xrandr and Xinerama extensions when getting the available video modes. In particular you can get XBMC to run on the second display, but you must set the SDL_VIDEO_FULLSCREEN_HEAD to make it work properly, which is not very user-friendly. Also it still grabs.

I just noticed that SDL 1.2.13 has an SDL_GetVideoInfo function, which should allow us to get the current resolution in a cross platform manner. This makes it very easy to get non-grabbing fullscreen with one display. Here's an example:

testnoframe.c
Code:
#include <SDL/SDL.h>
#include <stdio.h>

int main (int argc, char *argv[])
{
    SDL_Surface *screen;
    if (SDL_Init (SDL_INIT_VIDEO) != 0) {
        printf ("SDL Init failed: %s", SDL_GetError());
        return 1;
    }

    atexit(SDL_Quit);

    // Get the current video hardware information
    const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo();
    printf ("Current screen size: %dx%d\n", vidInfo->current_w, vidInfo->current_h);

    int width = vidInfo->current_w;
    int height = vidInfo->current_h;
    int bpp = vidInfo->vfmt->BitsPerPixel;

    screen = SDL_SetVideoMode (width, height, bpp, SDL_NOFRAME);
    if (screen == NULL) {
        printf ("Setting video mode failed: %s", SDL_GetError());
        return 1;
    }

    SDL_Event event;
    int quitFlag = 0;

    while (quitFlag == 0) {
        while (SDL_PollEvent(&event)) {
            if (event.type == SDL_KEYDOWN) {
                if (event.key.keysym.sym == SDLK_q || event.key.keysym.sym == SDLK_ESCAPE) {
                    quitFlag = 1;
                } else if (event.key.keysym.sym == SDLK_g) {
                    SDL_WM_GrabInput (SDL_GRAB_ON);
                } else if (event.key.keysym.sym == SDLK_u) {
                    SDL_WM_GrabInput (SDL_GRAB_OFF);
                }
            }
        }
    }

    return EXIT_SUCCESS;
}
Reply
#33
bdallen Wrote:There is also the option of just adding the "maximized non-grab" fullscreen mode, which is confusing to users but much easier to implement. Perhaps this is a good temporary fix until a more complete solution is developed?

Hear hear!

I've now managed to fool xbmc into 'maximized non-grab' mode with sawfish and devilspie but a check box would be much nicer...
Reply
#34
I REALLY want this... if nothing else, it could go in advancedsettings.xml no?
Reply
#35
funkknob Wrote:Hear hear!

I've now managed to fool xbmc into 'maximized non-grab' mode with sawfish and devilspie but a check box would be much nicer...

How did you do that - could you please post the devilspie config file? I tried the same thing today, but I can't get XBMC to un-maximize (starts always in fullscreen mode, even without -fs on the commandline).

Floe

EDIT: Nevermind, I just noticed that Gentoo installs a script for xbmc which always adds "-fs" to the command line. I removed that, now it works. My devilspie script looks like this:

Code:
(if
    (contains
        (window_name)
        "XBMC Media Center"
    )
    (begin
        (undecorate)
        (spawn_sync "sleep 1")
        (set_workspace 2)
        (spawn_sync "sleep 1")
        (geometry "1360x768+0+0")
    )
)

HTH, Floe
Reply
#36
Has any of this been implemented in HEAD? I have some free time to work on this, so I'd like to resurrect the discussion.

As a short-term solution, I would like to introduce a "Fit to Screen X" video option, which will run XBMC maximized with no frame on the given screen, without changing the screen resolution. As discussed above, this can be easily implemented without using SDL_FULLSCREEN, and therefore without mouse grabbing. I think this mode should be available even if/when the screen grabbing limitation of resolution-change fullscreen modes is removed.

Re the discussion in Ticket 5110, does F11 perform the same operation as "\"? I don't see it in the keymap, and it does nothing under Linux.

Long-term the following features are desirable:

- Mouse grabbing should be optional and independent of screen mode.
- If using resolution-change-fullscreen, an Alt+Tab should cause a resolution change and minimization, like the SDL 1.3 fullscreen behavior. However in a dual screen configuration, if focus leaves XBMC and goes to another screen, XBMC should stay active and the resolution should not change. This may be hard to implement even with SDL 1.3.
- Display mode state (windowed vs fullscreen vs maximized) and window position (if windowed) should be remembered across invocations, even if the changes were made via hotkeys (F11, "\", Alt+Enter).
- Choosing the output display should be easy, and fullscreen/maximization should behave properly when multiple displays are present.
- Resizing and screen mode changes should preserve the GLcontext whenever possible.
Reply
#37
bdallen Wrote:Has any of this been implemented in HEAD? I have some free time to work on this, so I'd like to resurrect the discussion.

As a short-term solution, I would like to introduce a "Fit to Screen X" video option, which will run XBMC maximized with no frame on the given screen, without changing the screen resolution. As discussed above, this can be easily implemented without using SDL_FULLSCREEN, and therefore without mouse grabbing. I think this mode should be available even if/when the screen grabbing limitation of resolution-change fullscreen modes is removed.

Re the discussion in Ticket 5110, does F11 perform the same operation as "\"? I don't see it in the keymap, and it does nothing under Linux.

Long-term the following features are desirable:

- Mouse grabbing should be optional and independent of screen mode.
- If using resolution-change-fullscreen, an Alt+Tab should cause a resolution change and minimization, like the SDL 1.3 fullscreen behavior. However in a dual screen configuration, if focus leaves XBMC and goes to another screen, XBMC should stay active and the resolution should not change. This may be hard to implement even with SDL 1.3.
- Display mode state (windowed vs fullscreen vs maximized) and window position (if windowed) should be remembered across invocations, even if the changes were made via hotkeys (F11, "\", Alt+Enter).
- Choosing the output display should be easy, and fullscreen/maximization should behave properly when multiple displays are present.
- Resizing and screen mode changes should preserve the GLcontext whenever possible.

Any short-term fix would be great. My devilspie/sawfish solution is not 100% stable; occasionally on boot the 'window' appears at lower resolution occupying the upper-left corner of the screen. Rebooting fixes the problem.

I wish I could contribute to your coding efforts but unfortunately I'm more a tinkerer than a programmer. If I can help in any way please let me know.

BR/Tom
Reply
#38
I created an ugly hack to add a "Fit to Desktop" advanced setting. The patch is against 8.10, not HEAD - I will updated for HEAD soon and submit to the tracker.

You can get the patch here: fit_to_screen_adv_setting.diff

Here is how to checkout 8.10 and apply the patch:
Code:
svn co https://xbmc.svn.sourceforge.net/svnroot/xbmc/tags/8.10_Atlantis-linux-osx-win32/XBMC
cd XBMC
patch -p0 < /path/to/fit_to_screen_adv_setting.diff

To use the new mode, create an 'advancedsettings.xml' file in your userdata directory (~/.xbmc/userdata in Linux) which looks like this:
Code:
<advancedsettings>
    <fittoscreen>true</fittoscreen>
</advancedsettings>
If you already have an advancedsettings.xml, just add the fittoscreen element.

Note: I have only tested this in Linux with nVidia drivers running two monitors with separate screens (no TwinView and no Xinerama). It may or may not work with other platforms using the HAS_SDL code path.
Reply
#39
Hoping to resurrect this thread, since I am grappling the the same issue (multiple monitors, need to be able to have full-screen without mouse grab). Have any of the changes proposed to create a fullscreen_non_mouse_grab advanced option been implemented in the current version? I do not see it anywhere in the settings. I am running 9.11-beta1 on intrepid, not sure if I can use the above patch on the current version, hoping to not have to recompile.

Joe.
Reply
#40
I'm not sure if this has been addressed in 9.11-beta. I'll take a look and update my patch if necessary.
Reply
#41
The video code is much easier to work with now Big Grin

I have a first-pass, works-for-me, alpha quality, use at your own risk patch for the latest SVN:

fit_to_screen_adv_setting_20091124.diff

The new patch uses the same advanced setting as before:
Code:
<advancedsettings>
    <fittoscreen>true</fittoscreen>
</advancedsettings>

I plan to make something a bit cleaner over the long weekend and submit it for inclusion. Thanks to everyone who showed interest in this.
Reply
#42
I created a new patch which I think is worthy of merging. It's available here:

http://trac.xbmc.org/ticket/5836

Now that xrandr is used to set resolution, resolution changing actually works without mouse grab. To reflect this change, the option is now "nograbfullscreen" instead of "fittoscreen".

Code:
<advancedsettings>
    <nograbfullscreen>true</nograbfullscreen>
</advancedsettings>

Once this is tested under lots of different dual-head setups I'd like to make it a checkbox in the settings gui instead of an advanced setting. Please test if you know how to patch/compile (or are willing to learn).
Reply
#43
Tested on xorg 7.5, nvidia drivers 190 and xbmc yesterday's svn : works as advertised Smile

thanks for this patch. (it should definitly be included, even without gui checkbox)
Reply
#44
Doesn't seem to work for me. The idea is that you set that setting to true, enable full screen the normal way (pressing \, using the parameter -fs or setting it to fs in advancedsettings.xml) and then the mouse won't be grabbed, right?
I'll try again to make sure tomorrow, but when I used it a few days ago it didn't seem to work for me.
Reply
#45
Guess I was wrong. The latest version of the patch (fakefullscreen) works fine for me Smile

EDIT: Just noticed you have an edit button, sorry for the double post.
Reply

Logout Mark Read Team Forum Stats Members Help
[RFC] Un-trapping mouse while running fullscreen (SDL limitation/design-flaw)1