# Fullscreen code rocks!

**URL:** <https://discourse.libsdl.org/t/fullscreen-code-rocks/1528>\
**Category:** SDL Development\
**Created:** [January 14, 2000, 6:40am UTC](https://discourse.libsdl.org/t/fullscreen-code-rocks/1528 "2000-01-14T06:40:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [January 14, 2000, 6:40am UTC](https://discourse.libsdl.org/t/fullscreen-code-rocks/1528/1 "2000-01-14T06:40:18Z")

</div>

The fullscreen code is awesome! 🙂  
[http://www.devolution.com/~slouken/SDL/cvs.html](http://www.devolution.com/~slouken/SDL/cvs.html)

I added two new functions: SDL\_WM\_GrabInput() and SDL\_WM\_IconifyWindow(),

testwm now has three new keybindings:  
Ctrl-G : Grab the mouse and keyboard to the SDL window  
Ctrl-Z : Iconify the window  
Escape : Post a quit message

SDL has a new internal keybinding, ALT-Enter, which toggles fullscreen mode.

Stephane and Ryan helped me bang on it and make it phule proof! 🙂

This is currently implemented only on Linux, with other platforms easily  
done:

/\*

- This function iconifies the window, and returns 1 if it succeeded.
- If the function succeeds, it generates an SDL\_APPACTIVE loss event.
- This function is a noop and returns 0 in non-windowed environments.  
\*/  
extern DECLSPEC int SDL\_WM\_IconifyWindow(void);

/\*

- This function allows you to set and query the input grab state of
- the application. It returns the new input grab state.  
_/  
typedef enum {  
SDL\_GRAB\_QUERY = -1,  
SDL\_GRAB\_OFF = 0,  
SDL\_GRAB\_ON = 1  
} SDL\_GrabMode;  
/_
- Grabbing means that the mouse is confined to the application window,
- and nearly all keyboard input is passed directly to the application,
- and not interpreted by a window manager, if any.  
\*/  
SDL\_GrabMode SDL\_WM\_GrabInput(SDL\_GrabMode mode);

Enjoy!  
-Sam Lantinga (slouken at [devolution.com](http://devolution.com))

Lead Programmer, Loki Entertainment Software–  
“Any sufficiently advanced bug is indistinguishable from a feature”  
– Rich Kulawiec

---

<div class="post-metadata">

**Author:** ![Nicholas\_Vining](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/n/f04885/32.png) [@Nicholas\_Vining](https://discourse.libsdl.org/u/Nicholas_Vining)\
**Post date:** [January 14, 2000, 8:02am UTC](https://discourse.libsdl.org/t/fullscreen-code-rocks/1528/2 "2000-01-14T08:02:43Z")

</div>

> > The fullscreen code is awesome! 🙂  
> > [http://www.devolution.com/~slouken/SDL/cvs.html](http://www.devolution.com/~slouken/SDL/cvs.html)
> 
> Do you ever sleep? OK, you’re feeling inspired, let me run past you the  
> errors I found on my machine (P/200, running GNU WindowMaker, Slackware 7):
> 
> - the new testgl doesn’t seem to be handling perspective quite right.
> - testalpha has wierd problems under fullscreen mode. The mouse doesn’t drag  
> properly, and you see wierd rectangular holes in the blitting areas.
> 
> Are these dealt with in this new CVS tree, or did I just install the wrong  
> one?
> 
> > -Sam Lantinga (slouken at [devolution.com](http://devolution.com))
> 
> Nicholas
> 
> > ----- Original Message -----  
> > From: [slouken@devolution.com](mailto:slouken@devolution.com) (Sam Lantinga)  
> > To: sdl at [lokigames.com](http://lokigames.com)   
> > Date: Thursday, January 13, 2000 11:02 PM  
> > Subject: [SDL] Fullscreen code rocks!

---

<div class="post-metadata">

**Author:** ![Ryan\_Wahle](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/r/6f9a4e/32.png) [@Ryan\_Wahle](https://discourse.libsdl.org/u/Ryan_Wahle)\
**Post date:** [January 14, 2000, 9:21am UTC](https://discourse.libsdl.org/t/fullscreen-code-rocks/1528/3 "2000-01-14T09:21:10Z")

</div>

I know! IT ROCKS!! Before with DGA mode it never looked right for me, but  
now it is perfect!!!On Thu, 13 Jan 2000, Sam Lantinga wrote:

> The fullscreen code is awesome! 🙂  
> [http://www.devolution.com/~slouken/SDL/cvs.html](http://www.devolution.com/~slouken/SDL/cvs.html)
> 
> I added two new functions: SDL\_WM\_GrabInput() and SDL\_WM\_IconifyWindow(),
> 
> testwm now has three new keybindings:  
> Ctrl-G : Grab the mouse and keyboard to the SDL window  
> Ctrl-Z : Iconify the window  
> Escape : Post a quit message
> 
> SDL has a new internal keybinding, ALT-Enter, which toggles fullscreen mode.
> 
> Stephane and Ryan helped me bang on it and make it phule proof! 🙂
> 
> This is currently implemented only on Linux, with other platforms easily  
> done:
> 
> /\*
> 
> - This function iconifies the window, and returns 1 if it succeeded.
> - If the function succeeds, it generates an SDL\_APPACTIVE loss event.
> - This function is a noop and returns 0 in non-windowed environments.  
> \*/  
> extern DECLSPEC int SDL\_WM\_IconifyWindow(void);
> 
> /\*
> 
> - This function allows you to set and query the input grab state of
> - the application. It returns the new input grab state.  
> _/  
> typedef enum {  
> SDL\_GRAB\_QUERY = -1,  
> SDL\_GRAB\_OFF = 0,  
> SDL\_GRAB\_ON = 1  
> } SDL\_GrabMode;  
> /_
> - Grabbing means that the mouse is confined to the application window,
> - and nearly all keyboard input is passed directly to the application,
> - and not interpreted by a window manager, if any.  
> \*/  
> SDL\_GrabMode SDL\_WM\_GrabInput(SDL\_GrabMode mode);
> 
> Enjoy!  
> -Sam Lantinga (slouken at [devolution.com](http://devolution.com))
> 
> ## Lead Programmer, Loki Entertainment Software
> 
> “Any sufficiently advanced bug is indistinguishable from a feature”  
> – Rich Kulawiec

---

<div class="post-metadata">

**Author:** ![slouken](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/s/ec9cab/32.png) [@slouken](https://discourse.libsdl.org/u/slouken)\
**Post date:** [January 14, 2000, 6:57pm UTC](https://discourse.libsdl.org/t/fullscreen-code-rocks/1528/4 "2000-01-14T18:57:16Z")

</div>

> Do you ever sleep? OK, you’re feeling inspired, let me run past you the  
> errors I found on my machine (P/200, running GNU WindowMaker, Slackware 7):

> - the new testgl doesn’t seem to be handling perspective quite right.
> - testalpha has wierd problems under fullscreen mode. The mouse doesn’t drag  
> properly, and you see wierd rectangular holes in the blitting areas.

> Are these dealt with in this new CVS tree, or did I just install the wrong  
> one?

Did you grab the version I posted last night?  
The code on the CVS web page should be completely current, and it sounds  
like you are using code from several days ago.

```
-Sam Lantinga (slouken at devolution.com)

```

Lead Programmer, Loki Entertainment Software–  
“Any sufficiently advanced bug is indistinguishable from a feature”  
– Rich Kulawiec
