Opened 14 years ago

Closed 14 years ago

Last modified 13 months ago

#545 closed defect (fixed)

Grab mouse in fullscreen

Reported by: Jay Weisskopf Owned by:
Priority: Nice to Have Milestone: Alpha 2
Component: Core engine Keywords: multimon
Cc: Patch:

Description

When the game is running in fullscreen, the mouse should be grabbed so it cannot move outside the game. I have multiple monitors, so when I try to pan the camera by putting the cursor along the edges, it moves right into the next monitor, which is a major annoyance.

Attached is a patch to fix the issue.

The ideal functionality for mouse grabbing would probably be to have it always grabbed in fullscreen, and optionally grabbed during gameplay in windowed mode (but not on menus, dev console, text entry, etc). I can also implement this if desired (it'd be a good way for me to start getting my feet wet).

Attachments (1)

mouse_grab.patch (396 bytes ) - added by Jay Weisskopf 14 years ago.
Patch for grabbing mouse when game is fullscreen.

Download all attachments as: .zip

Change History (11)

by Jay Weisskopf, 14 years ago

Attachment: mouse_grab.patch added

Patch for grabbing mouse when game is fullscreen.

comment:1 by Jay Weisskopf, 14 years ago

Keywords: review added

comment:2 by Philip Taylor, 14 years ago

See #508 for a similar issue. That was from before r7686 implemented SDL_WM_GrabInput on Windows - seems good to use that function now we have it.

What platforms have you tested this on? On Windows, does it avoid the bugs mentioned in a comment on that ticket? (I'd prefer to fix them or at least be fully aware of them before committing the change.)

comment:3 by Jay Weisskopf, 14 years ago

Yes, using SDL_WM_GrabInput is better than modifying the functionality of SDL_Set_VideoMode. The SDL emulation should adhere as closely to native SDL as possible. (I'm quite puzzled as to why you're even emulating it, but that's a discussion for IRC or the forum.)

I recommend you commit my patch, just so the major annoyance is gone, and close this issue. I will assign myself to #508 and produce another patch that takes care of any edge cases (alt+tab, stuff like that).

comment:4 by Jay Weisskopf, 14 years ago

Oh, I forgot to mention that this has only been tested on Windows, but if you're using native SDL on the other platforms, there shouldn't be any issues. I've done some work on this exact same issue for another project, which is SDL-based, so I'm comfortable with its API.

comment:5 by Philip Taylor, 14 years ago

Okay, I'll commit this one for now. I tried it on OS X and it looks like fullscreen is already pretty broken and this doesn't make it any worse, so I'll leave those problems for some competent Mac developer to come and fix. Multi-monitor fullscreen on Linux doesn't work (it fills the bounding box of all monitors; I think that's SDL's responsibility, not ours) so this doesn't have any effect there so that's okay.

comment:6 by philip, 14 years ago

Resolution: fixed
Status: newclosed

(In [8022]) Fix #545 (Grab mouse in fullscreen), based on patch from Jayschwa

comment:7 by (none), 14 years ago

Milestone: Unclassified

Milestone Unclassified deleted

comment:8 by zoot, 11 years ago

Keywords: multimon added
Milestone: Backlog

comment:9 by historic_bruno, 11 years ago

Keywords: review removed
Milestone: BacklogAlpha 2

comment:10 by Vladislav Belov, 13 months ago

In 27603:

Adds an option to disable mouse grab in fullscreen.

Refs #6649
Refs #545

Differential Revision: https://code.wildfiregames.com/D4974

Note: See TracTickets for help on using tickets.