3#define __STDC_WANT_LIB_EXT1__ 1
10#define WINDOW_CLIENT_ELEM_ID (UINT64_MAX)
11#define WINDOW_DECO_ELEM_ID (UINT64_MAX - 1)
12#define WINDOW_DECO_CLOSE_BUTTON_ID (UINT64_MAX - 2)
13#define WINDOW_DECO_MINIMIZE_BUTTON_ID (UINT64_MAX - 3)
15#define WINDOW_DECO_CLOSE_BUTTON_INDEX 0
16#define WINDOW_DECO_MINIMIZE_BUTTON_INDEX 1
17#define WINDOW_DECO_BUTTON_AMOUNT 2
49 rect->
right -= size * index;
63 if (private->isFocused)
83 rect_t titlebarWithoutButtons;
89 titlebarWithoutButtons.
right = lastButton.
left;
92 if (private->isDragging)
102 private->isDragging =
false;
107 private->dragOffset =
109 private->isDragging =
true;
122 if (closeButton ==
NULL)
130 if (minimizeButton ==
NULL)
136 if (private->closeIcon ==
NULL)
142 if (private->minimizeIcon ==
NULL)
153 if (private->minimizeIcon !=
NULL)
157 if (private->closeIcon !=
NULL)
161 if (closeButton !=
NULL)
165 if (minimizeButton !=
NULL)
179 private->isFocused =
false;
180 private->isVisible =
true;
181 private->isDragging =
false;
182 private->minimizeIcon =
NULL;
183 private->closeIcon =
NULL;
203 if (private->closeIcon !=
NULL)
207 if (private->minimizeIcon !=
NULL)
640 rect_t newRect =
event->report.info.rect;
646 event.shouldPropagate =
true;
#define MAX_NAME
Maximum length of names.
@ CMD_SURFACE_VISIBLE_SET
element_t * element_new_root(window_t *win, element_id_t id, const rect_t *rect, const char *text, element_flags_t flags, procedure_t procedure, void *private)
void * display_cmd_alloc(display_t *disp, cmd_type_t type, uint64_t size)
Allocate a section of the displays command buffer.
void display_cmds_flush(display_t *disp)
Flush the display's command buffer.
void display_push(display_t *disp, surface_id_t target, event_type_t type, void *data, uint64_t size)
Push an event to the display's internal event queue.
uint64_t display_wait(display_t *disp, event_t *event, event_type_t expected)
Wait for the display to receive an event of the expected type.
uint64_t display_dispatch_pending(display_t *disp, event_type_t type, surface_id_t target)
Dispatch all events currently in the display's internal event queue of a specific type and target.
uint64_t display_set_is_visible(display_t *disp, surface_id_t id, bool isVisible)
Set the visibility of a surface.
void draw_gradient(drawable_t *draw, const rect_t *rect, pixel_t start, pixel_t end, direction_t direction, bool shouldAddNoise)
Draw a gradient filled rectangle.
void draw_rect(drawable_t *draw, const rect_t *rect, pixel_t pixel)
Draw a filled rectangle.
void draw_text(drawable_t *draw, const rect_t *rect, const font_t *font, align_t xAlign, align_t yAlign, pixel_t pixel, const char *text)
Draw text to a drawable.
void draw_frame(drawable_t *draw, const rect_t *rect, uint64_t width, pixel_t foreground, pixel_t background)
Draw a skeuomorphic frame.
void element_set_image(element_t *elem, image_t *image)
Set the image of an element.
void element_set_private(element_t *elem, void *private)
Set private data for an element.
element_t * element_find(element_t *elem, element_id_t id)
Find a child element by its ID.
theme_t * element_get_theme(element_t *elem)
Get the theme of an element.
#define ELEMENT_NO_OUTLINE
uint64_t element_dispatch(element_t *elem, const event_t *event)
Dispatch an event to an element.
void element_draw_end(element_t *elem, drawable_t *draw)
End drawing to an element.
element_t * element_new(element_t *parent, element_id_t id, const rect_t *rect, const char *text, element_flags_t flags, procedure_t procedure, void *private)
Allocate and initialize a new element.
rect_t element_get_content_rect(element_t *elem)
Get the element's rectangle in local coordinates.
void element_draw_begin(element_t *elem, drawable_t *draw)
Begin drawing to an element.
void element_free(element_t *elem)
Deinitialize and free an element and all its children.
void * element_get_private(element_t *elem)
Get private data for an element.
#define LEVENT_FORCE_ACTION
#define EVENT_SURFACE_NEW
surface_type_t
Surface types.
theme_t * theme_global_get(void)
Get the global theme.
uint64_t window_set_visible(window_t *win, bool isVisible)
Set the visibility of the window.
rect_t window_get_rect(window_t *win)
Get the window's rectangle in screen coordinates.
uint64_t window_move(window_t *win, const rect_t *rect)
Move and/or resize the window.
uint64_t window_set_focus(window_t *win)
Set the focus to the window.
surface_id_t window_get_id(window_t *win)
Get the surface ID of the window.
window_flags_t
Window flags.
uint64_t window_invalidate_flush(window_t *win)
Flush invalidated rectangles to the DWM.
surface_type_t window_get_type(window_t *win)
Get the surface type of the window.
uint64_t window_set_timer(window_t *win, timer_flags_t flags, clock_t timeout)
Set the window timer.
uint64_t window_dispatch(window_t *win, const event_t *event)
Dispatch an event to the window's elements.
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.
element_t * window_get_client_element(window_t *win)
Get the client element of the window.
void window_free(window_t *win)
Free a window.
display_t * window_get_display(window_t *win)
Get the display associated with the window.
void window_invalidate(window_t *win, const rect_t *rect)
Invalidate a rectangle of the window.
@ 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.
@ WINDOW_DECO
Enable decorations (titlebar, close/minimize buttons, etc).
#define EINVAL
Invalid argument.
#define ENOMEM
Out of memory.
#define errno
Error number variable.
#define EPERM
Operation not permitted.
fd_t claim(key_t *key)
System call for claiming a shared file descriptor.
uint64_t close(fd_t fd)
System call for closing files.
static void list_remove(list_t *list, list_entry_t *entry)
Removes a list entry from its current list.
static void list_push(list_t *list, list_entry_t *entry)
Pushes an entry to the end of the list.
static void list_entry_init(list_entry_t *entry)
Initializes a list entry.
@ MOUSE_LEFT
Left mouse button.
void * mmap(fd_t fd, void *address, uint64_t length, prot_t prot)
System call to map memory from a file.
uint64_t munmap(void *address, uint64_t length)
System call to unmap mapped memory.
@ PROT_READ
Memory can be read from.
@ PROT_WRITE
Memory can be written to.
#define NULL
Pointer error value.
#define ERR
Integer error value.
__UINT64_TYPE__ fd_t
A file descriptor.
__UINT64_TYPE__ clock_t
A nanosecond time.
void image_free(image_t *image)
image_t * image_new(display_t *disp, const char *path)
uint64_t(* procedure_t)(window_t *, element_t *, const event_t *)
static uint64_t procedure(window_t *win, element_t *elem, const event_t *event)
#define RECT_SHRINK(rect, margin)
#define RECT_INIT_DIM(x, y, width, height)
#define RECT_INIT(left, top, right, bottom)
#define RECT_HEIGHT(rect)
#define RECT_EXPAND_TO_CONTAIN(rect, other)
#define RECT_CONTAINS_POINT(rect, point)
_PUBLIC void * malloc(size_t size)
_PUBLIC _NORETURN void abort(void)
_PUBLIC void free(void *ptr)
_PUBLIC char * strcpy(char *_RESTRICT s1, const char *_RESTRICT s2)
size_t strnlen_s(const char *s, size_t maxsize)
Opaque display structure.
Opaque element structure.
key_t shmemKey
Key that can be claim()ed to access the surface's shared memory.
levent_force_action_t lForceAction
event_surface_new_t surfaceNew
pixel_t backgroundSelectedEnd
pixel_t backgroundUnselectedEnd
pixel_t backgroundUnselectedStart
pixel_t backgroundSelectedStart
char iconMinimize[MAX_PATH]
element_t * clientElement
_PUBLIC int mtx_lock(mtx_t *mtx)
_PUBLIC int mtx_unlock(mtx_t *mtx)
static uint64_t window_deco_init(window_t *win, element_t *elem)
#define WINDOW_DECO_BUTTON_AMOUNT
#define WINDOW_DECO_CLOSE_BUTTON_ID
static void window_deco_handle_dragging(window_t *win, element_t *elem, const event_mouse_t *event)
rect_t window_get_local_rect(window_t *win)
static void window_deco_titlebar_rect(window_t *win, element_t *elem, rect_t *rect)
#define WINDOW_DECO_MINIMIZE_BUTTON_ID
static void window_deco_draw_titlebar(window_t *win, element_t *elem, drawable_t *draw)
#define WINDOW_CLIENT_ELEM_ID
#define WINDOW_DECO_MINIMIZE_BUTTON_INDEX
static void window_deco_redraw(window_t *win, element_t *elem)
static void window_deco_button_rect(window_t *win, element_t *elem, rect_t *rect, uint64_t index)
static uint64_t window_deco_procedure(window_t *win, element_t *elem, const event_t *event)
#define WINDOW_DECO_CLOSE_BUTTON_INDEX
static void window_deco_report(window_t *win, element_t *elem, const event_report_t *report)
#define WINDOW_DECO_ELEM_ID
static void window_deco_free(element_t *elem)
static uint64_t window_deco_init_controls(window_t *win, element_t *elem, deco_private_t *private)
static void window_deco_action(window_t *win, const levent_action_t *action)