PatchworkOS  966e257
A non-POSIX operating system.
Loading...
Searching...
No Matches

Window. More...

Collaboration diagram for Window:

Detailed Description

Window.

A window represents a rectangular area on the screen that can display content and receive user input, this includes panels, cursors, wallpapers and normal application windows. It can be considered to be the client side implementation of the Desktop Window Managers surfaces.

If WINDOW_DECO flag is set, the window will have decorations (titlebar, close/minimize buttons, etc) which will serve as the root element with the client element as a child. This client element is then what the application will draw to and receive events from.

The window system is NOT thread safe, it is the responsibility of the application to ensure that windows are only accessed from a single thread at a time.

Data Structures

struct  window_t
 Opaque window structure. More...
 

Typedefs

typedef struct window window_t
 

Enumerations

enum  window_flags_t { WINDOW_NONE = 0 , WINDOW_DECO = 1 << 0 , WINDOW_RESIZABLE = 1 << 1 , WINDOW_NO_CONTROLS = 1 << 2 }
 Window flags. More...
 

Functions

window_twindow_new (display_t *disp, const char *name, const rect_t *rect, surface_type_t type, window_flags_t flags, procedure_t procedure, void *private)
 Allocate and initialize a new window.
 
void window_free (window_t *win)
 Free a window.
 
rect_t window_get_rect (window_t *win)
 Get the window's rectangle in screen coordinates.
 
rect_t window_content_rect (window_t *win)
 Get the window's rectangle in local coordinates.
 
display_twindow_get_display (window_t *win)
 Get the display associated with the window.
 
surface_id_t window_get_id (window_t *win)
 Get the surface ID of the window.
 
surface_type_t window_get_type (window_t *win)
 Get the surface type of the window.
 
element_twindow_get_client_element (window_t *win)
 Get the client element of the window.
 
uint64_t window_move (window_t *win, const rect_t *rect)
 Move and/or resize the window.
 
uint64_t window_set_timer (window_t *win, timer_flags_t flags, clock_t timeout)
 Set the window timer.
 
void window_invalidate (window_t *win, const rect_t *rect)
 Invalidate a rectangle of the window.
 
uint64_t window_invalidate_flush (window_t *win)
 Flush invalidated rectangles to the DWM.
 
uint64_t window_dispatch (window_t *win, const event_t *event)
 Dispatch an event to the window's elements.
 
uint64_t window_set_focus (window_t *win)
 Set the focus to the window.
 
uint64_t window_set_visible (window_t *win, bool isVisible)
 Set the visibility of the window.
 

Typedef Documentation

◆ window_t

typedef struct window window_t

Definition at line 37 of file window.h.

Enumeration Type Documentation

◆ window_flags_t

Window flags.

Enumerator
WINDOW_NONE 
WINDOW_DECO 

Enable decorations (titlebar, close/minimize buttons, etc).

WINDOW_RESIZABLE 

Allows window_move() to resize the window.

Todo:
Implement resize handles.
WINDOW_NO_CONTROLS 

Disable controls (close/minimize buttons), only applies if WINDOW_DECO is set.

Definition at line 43 of file window.h.

Function Documentation

◆ window_new()

window_t * window_new ( display_t disp,
const char *  name,
const rect_t rect,
surface_type_t  type,
window_flags_t  flags,
procedure_t  procedure,
void *  private 
)

Allocate and initialize a new window.

Parameters
dispThe connection to the DWM.
nameThe name of the window.
rectThe rectangle defining the position and size of the window.
typeThe type of surface to create, (e.g., panels, cursors, wallpapers, normal windows, etc).
flagsThe window flags.
procedureThe procedure for the window's client element.
privatePrivate data to associate with the window's client element.
Returns
On success, the new window. On failure, returns NULL and errno is set.

Definition at line 301 of file window.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ window_free()

void window_free ( window_t win)

Free a window.

Parameters
winThe window to free.

Definition at line 415 of file window.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ window_get_rect()

rect_t window_get_rect ( window_t win)

Get the window's rectangle in screen coordinates.

Equivalent to RECT_INIT_DIM(x, y, width, height).

Parameters
winThe window.
Returns
The window's rectangle.

Definition at line 447 of file window.c.

Here is the caller graph for this function:

◆ window_content_rect()

rect_t window_content_rect ( window_t win)

Get the window's rectangle in local coordinates.

Equivalent to RECT_INIT_DIM(0, 0, width, height).

Parameters
winThe window.
Returns
The window's local rectangle.

◆ window_get_display()

display_t * window_get_display ( window_t win)

Get the display associated with the window.

Parameters
winThe window.
Returns
The display.

Definition at line 467 of file window.c.

Here is the caller graph for this function:

◆ window_get_id()

surface_id_t window_get_id ( window_t win)

Get the surface ID of the window.

Parameters
winThe window.
Returns
The surface ID or SURFACE_ID_NONE if win is NULL.

Definition at line 477 of file window.c.

Here is the caller graph for this function:

◆ window_get_type()

surface_type_t window_get_type ( window_t win)

Get the surface type of the window.

Parameters
winThe window.
Returns
The surface type or SURFACE_NONE if win is NULL.

Definition at line 487 of file window.c.

◆ window_get_client_element()

element_t * window_get_client_element ( window_t win)

Get the client element of the window.

The client element is the window element that applications should draw to and receive events from, if the window has decorations this will be the child of the deco element, otherwise it will be the root element.

Parameters
winThe window.
Returns
The client element.

Definition at line 497 of file window.c.

Here is the caller graph for this function:

◆ window_move()

uint64_t window_move ( window_t win,
const rect_t rect 
)

Move and/or resize the window.

Parameters
winThe window.
rectThe new screen rectangle for the window.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 507 of file window.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ window_set_timer()

uint64_t window_set_timer ( window_t win,
timer_flags_t  flags,
clock_t  timeout 
)

Set the window timer.

When the timer fires an event of type EVENT_TIMER will be sent to the window's procedure.

Parameters
winThe window.
flagsThe timer flags.
timeoutThe timer timeout in clock ticks, or CLOCKS_NEVER to disable the timer. Setting a new timer will overide the previous timer if one is set.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 533 of file window.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ window_invalidate()

void window_invalidate ( window_t win,
const rect_t rect 
)

Invalidate a rectangle of the window.

This is used to notify the DWM of the change not to redraw the specified rectangle.

The changes will be flushed to the DWM when window_invalidate_flush() is called.

Parameters
winThe window.
rectThe rectangle to invalidate, in local coordinates.

Definition at line 553 of file window.c.

Here is the caller graph for this function:

◆ window_invalidate_flush()

uint64_t window_invalidate_flush ( window_t win)

Flush invalidated rectangles to the DWM.

This will push a command to the display to notify the DWM of all previously invalidated rectangles.

In order for the DWM to actually redraw the invalidated region, the commands must be flushed to the DWM using display_cmds_flush().

Parameters
winThe window.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 570 of file window.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ window_dispatch()

uint64_t window_dispatch ( window_t win,
const event_t event 
)

Dispatch an event to the window's elements.

Most events will be sent to the root element, which will then propagate the event to its children.

Some events will be handled specially, for example EVENT_LIB_FORCE_ACTION will be sent directly to the specified element.

Parameters
winThe window.
eventThe event to dispatch.
Returns
The result of the window procedure.

Definition at line 598 of file window.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ window_set_focus()

uint64_t window_set_focus ( window_t win)

Set the focus to the window.

Causes the window to be moved to the front and to, for example, receive keyboard input.

Parameters
winThe window.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 673 of file window.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ window_set_visible()

uint64_t window_set_visible ( window_t win,
bool  isVisible 
)

Set the visibility of the window.

Windows are invisible by default, so they must be made visible after creation to be seen.

Will also dispatch all currently pending EVENT_LIB_REDRAW events for the window.

Parameters
winThe window.
isVisibleWhether the window should be visible.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 692 of file window.c.

Here is the call graph for this function:
Here is the caller graph for this function: