The Window module is about opening and managing windows and system-related
things that goes throught window. It also handles some screen related features.
The allocator module header is lapin/window.h
typedef enum e_bunny_window_style
{
 
NO_BORDER ,
 
TITLEBAR = 1,
 
RESIZE_BUTTON = 2,
 
CLOSE_BUTTON = 4,
 
FULLSCREEN = 9,
 
DEFAULT_WIN_STYLE = TITLEBAR | RESIZE_BUTTON | CLOSE_BUTTON,
 
ANTIALIASING
}
t_bunny_window_style;
Symbols
-
NO_BORDER :
  A simple rectangle of the requested size will be opened. There will not
be any outline or button. It will not be possible to grab the window to move
it on screen thanks to the titlebar without this.
-
TITLEBAR :
  Display in the border the title of the window in a bar that can also
be used to grab the window and move it.
-
RESIZE_BUTTON :
  Display in the border a resize button to maximize the window.
-
CLOSE_BUTTON :
  Display in the border a close button to shut the window. Note that
not having this button may not prevent the close event to happen: the system
may offer other ways to close the window.
-
FULLSCREEN :
  Start the window in fullscreen mode.
-
DEFAULT_WIN_STYLE :
The style used by the bunny_start function.
-
ANTIALIASING :
A bitmask that can be added to any other mode to ask for an anti aliasing
filter.
INDEX
Description
  Open a window and return a structure to handle it.
If the window is started in fullscreen, then all size are not
available. A call to
bunny_get_fullscreen_modes will returns
you an array of working fullscreen modes for the underlying system.
The returned structure must be free with
bunny_stop.
It is important to call it
before exiting, especially
if you are fullscreen, because it will restores the original
screen resolution if the window opening have changed it.
A good idea, if you managed to create a program that can
easily adapt to any screen resolution and that you want
to start in fullscreen is to use
bunny_get_screen_resolution
to get the current screen resolution and create a window
of the same size. It will not change the system resolution
and use at the maximum the system capabilities.
Note that you can open several window in windowed mode.
This function perform a joystick scan. So when opening
a window, all joysticks will be recognized. After opening
the window, you will have to handle the connection and
disconnection by yourself with events.
By default, the window is filled with
PINK2.
Parameters
-
unsigned int width:
  The width in pixel of the bunny to open.
-
unsigned int height:
  The height in pixel of the bunny to open.
-
bool fullscreen:
  Send true to open the window in fullscreen. false to windowed mode.
-
const char *name:
  The window name. It will be used on the window outline itself and
on most system in the status bar of the desktop manager.
Error values and logs
On error, bunny_errno is set to:
Logs written by this function are tagged with the "window" label.
INDEX
Description
  Refresh the window on screen. Call this function
after you terminated all your drawing on screen to make them
appeir.
INDEX
Description
  Return the current screen resolution.
Starting a window into this resolution in fullscreen mode
will not provoke a brutal resolution resizing.
INDEX
Description
  Return an array of all valid fullscreen modes. The array
is terminated by a { .x = 0, .y = 0 } case.
Return value
-
A t_bunny_size structure containing valid resolution
for a fullscreen mode. The last item is filled with zero.
INDEX
Parameters
-
unsigned int width:
  The width in pixel of the bunny to open.
-
unsigned int height:
  The height in pixel of the bunny to open.
-
t_bunny_window_style style:
  The style of the window that will be opened.
-
const char *name:
  The window name. It will be used on the window outline itself and
on most system in the status bar of the desktop manager.
Error values and logs
On error, bunny_errno is set to:
Logs written by this function are tagged with the "window" label.
INDEX
Description
  Enable or disable the key repetition for the sent window.
Note that the key repetition is
not made for be used
in a video game context: it is not a "keydown status" but
a pure tool for text editor. Its speed is system configuration
dependant. If you need a keydown status, use
bunny_get_keyboard.
Parameters
-
t_bunny_window *window:
  The window which will have its key repetition policy modified.
-
bool repeat:
  true to enable key repetition, false to disable it.
INDEX
Description
  Display or hide the system mouse cursor when moving over the window.
INDEX
Description
  Set the mouse cursor at the sent position, relatively to the sent window.
Parameters
-
t_bunny_window *window:
  The window to use as reference
-
int x:
  The horizontal position to warp the mouse on.
-
int y:
  The vertical position to warp the mouse on.
INDEX
Description
  Set the mouse cursor at the sent position.
Parameters
-
int x:
  The horizontal position to warp the mouse on.
-
int y:
  The vertical position to warp the mouse on.
INDEX
Description
  Send a request to the window manager to get the focus
back on the sent window.
INDEX
Description
  Move the sent window at the sent coordinates.
INDEX
Description
  Resize the sent window to match the sent size.
INDEX
Description
  Enable or disable vertical synchronization with screen refresh.
Disabled by default.
INDEX