libxputty 0.1
Loading...
Searching...
No Matches
xwidget-platform.h
Go to the documentation of this file.
1/* vim:ts=4:sw=4:et:
2 * 0BSD
3 *
4 * BSD Zero Clause License
5 *
6 * Copyright (c) 2019 Hermann Meyer
7 *
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted.
10
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 *
19 */
20
31#pragma once
32
33#ifndef XWIDGET_PLATFORM_H
34#define XWIDGET_PLATFORM_H
35
36#include "xputty.h"
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/*---------------------------------------------------------------------
43-----------------------------------------------------------------------
44 common structs and definitions
45-----------------------------------------------------------------------
46----------------------------------------------------------------------*/
47
59typedef struct {
61 int width;
63 int height;
65 int x;
67 int y;
69 bool visible;
70} Metrics_t;
71
72/*---------------------------------------------------------------------
73-----------------------------------------------------------------------
74 wrapper functions
75-----------------------------------------------------------------------
76----------------------------------------------------------------------*/
77
84Display *os_open_display(char *display_name);
85
91void os_close_display(Display *dpy);
92
101Window os_get_root_window(Xputty *main, int flag);
102
109
119void os_translate_coords(Widget_t *w, Window from_window, Window to_window,
120 int from_x, int from_y, int *to_x, int *to_y);
121
128void os_get_window_metrics(Widget_t *w, Metrics_t *metrics);
129
137void os_set_window_min_size(Widget_t *w, int min_width, int min_height,
138 int base_width, int base_height);
139
147void os_move_window(Display *dpy, Widget_t *w, int x, int y);
148
156void os_resize_window(Display *dpy, Widget_t *w, int x, int y);
157
164void os_get_surface_size(cairo_surface_t *surface, int *width, int *height);
165
172void os_set_widget_surface_size(Widget_t *w, int width, int height);
173
185 int x, int y, int width, int height);
186
198 int x, int y, int width, int height);
199
206void os_set_title(Widget_t *w, const char *title);
207
213void os_widget_show(Widget_t *w);
214
220void os_widget_hide(Widget_t *w);
221
228void os_show_tooltip(Widget_t *wid, Widget_t *w);
229
236void os_transparent_draw(void *w_, void *user_data);
237
244
252void os_send_configure_event(Widget_t *w,int x, int y, int width, int height);
253
261
269
277
285void os_adjustment_callback(void *w_, void *user_data);
286
296bool os_get_keyboard_input(Widget_t *w, XKeyEvent *key, char *buf, size_t bufsize);
297
305
313
321
330
338
346
353bool os_is_directory(const char *filename);
354
361char *os_get_home_dir();
362
370void os_free_pixmap(Widget_t *w, Pixmap pixmap);
371
372
380char *utf8_from_locale(char *localestr);
381
389char *locale_from_utf8(char *utf8str);
390
396void os_quit(Widget_t *w);
397
403void os_quit_widget(Widget_t *w);
404
412
420
421
431void os_widget_event_loop(void *w_, void* event, Xputty *main, void* user_data);
432
439void os_run_embedded(Xputty *main);
440
446void os_main_run(Xputty *main);
447
454void os_init_dnd(Xputty *main);
455
456
457
458#ifdef __cplusplus
459}
460#endif
461
462#endif //XWIDGET_PLATFORM_H
Metrics_t - struct to receive window size, position & visibility Pass this struct to os_get_window_...
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
Xputty - the main struct. It should be declared before any other call to a Xputty function....
Definition xputty.h:228
XID Pixmap
XID Display
unsigned long int Atom
HWND Window
This file contains definitions and structs used on all platforms. Platform specific definitions are l...
void os_get_window_metrics(Widget_t *w, Metrics_t *metrics)
os_get_window_metrics - Get the Merics_t struct related to a Widget_t
void os_widget_show(Widget_t *w)
os_widget_show - Show a Widget_t
void os_main_run(Xputty *main)
os_main_run - start the event loop
void os_widget_hide(Widget_t *w)
os_widget_hide - Hide a Widget_t
void os_destroy_window(Widget_t *w)
os_destroy_window - destroy a widget (close and remove from processing)
void os_init_dnd(Xputty *main)
os_init_dnd - register a Widget_t for handling drag and drop events only implemented on linux
void os_set_widget_surface_size(Widget_t *w, int width, int height)
os_set_widget_surface_size - set the size of a Widget_t cairo surface
void os_send_button_press_event(Widget_t *w)
os_send_button_press_event - Send a button press event to a Widget_t see XButtonEvent
int os_grab_pointer(Widget_t *w)
os_grab_pointer - grab the mouse pointer. Works only on linux
char * utf8_from_locale(char *localestr)
utf8_from_locale - convert active codepage to utf8 must be freed by the caller
int os_get_screen_width(Widget_t *w)
os_get_screen_width - Get the width of the used Display
void os_resize_window(Display *dpy, Widget_t *w, int x, int y)
os_resize_window - Resize a Widget_t
char * os_get_home_dir()
os_get_home_dir - get the users home directory
void os_send_button_release_event(Widget_t *w)
os_send_button_release_event - Send a button release event to a Widget_t see XButtonEvent
Window os_get_root_window(Xputty *main, int flag)
os_get_root_window - get a pointer to the root window (desktop)
void os_run_embedded(Xputty *main)
os_run_embedded - the event handling when run embedded on windows all messges goes into WndProc,...
void os_translate_coords(Widget_t *w, Window from_window, Window to_window, int from_x, int from_y, int *to_x, int *to_y)
os_translate_coords - get x,y related to destination Window
void os_send_systray_message(Widget_t *w)
os_send_send_systray_message - Send a systray event to a Widget_t only working on Linux for now
void os_send_configure_event(Widget_t *w, int x, int y, int width, int height)
os_send_configure_event - Send a configure event to a Widget_t
void os_set_title(Widget_t *w, const char *title)
os_set_title - Set the title of a Widget_t
Atom os_register_widget_destroy(Widget_t *wid)
os_register_widget_destroy - Get the needed Atom to send a widget destroy message
void os_quit(Widget_t *w)
os_quit - quit the main loop and free all used memory
void os_set_input_mask(Widget_t *w)
os_set_input_mask - set the Event mask to a Widget_t only work on linux, stub on Windows
void os_show_tooltip(Widget_t *wid, Widget_t *w)
os_show_tooltip - Show a tooltip of a Widget_t
Atom os_register_wm_delete_window(Widget_t *wid)
os_register_wm_delete_window - Get the needed Atom to send a widget delete message
void os_free_pixmap(Widget_t *w, Pixmap pixmap)
os_free_pixmap - Free the memory used by a Pixmap only Linux, stub otherwise
void os_move_window(Display *dpy, Widget_t *w, int x, int y)
os_move_window - Move a Widget_t
void os_widget_event_loop(void *w_, void *event, Xputty *main, void *user_data)
os_widget_event_loop - the Widget_t event loop on windows all messges goes into WndProc,...
bool os_is_directory(const char *filename)
os_is directory - check if a given path is a directory or a file
void os_quit_widget(Widget_t *w)
os_quit_widget - remove a Widget_t from the main loop and free it's used memory
void os_set_transient_for_hint(Widget_t *parent, Widget_t *w)
os_set_ transient_for_hint - set a Widget_t transient to a other Widget_t only work on linux,...
void os_transparent_draw(void *w_, void *user_data)
os_transparent_draw - Draw the Widget_t to the back buffer
bool os_get_keyboard_input(Widget_t *w, XKeyEvent *key, char *buf, size_t bufsize)
os_ get_keyboard_input - Get the Keyboard input and convert it to utf8
void os_set_window_min_size(Widget_t *w, int min_width, int min_height, int base_width, int base_height)
os_set_window_min_size - Set the min and base size of a Widget_t
void os_create_widget_window_and_surface(Widget_t *w, Xputty *app, Widget_t *parent, int x, int y, int width, int height)
os_create_main_widget_and_surface - create a Widget_t with a acairo surface this function is used mai...
int os_get_screen_height(Widget_t *w)
os_get_screen_height - Get the height of the used Display
void os_create_main_window_and_surface(Widget_t *w, Xputty *app, Window win, int x, int y, int width, int height)
os_create_main_window_and_surface - create a Widget_t with a acairo surface this function is used mai...
void os_close_display(Display *dpy)
os_close_display - Close connection to the used display
void os_adjustment_callback(void *w_, void *user_data)
os_adjustment_callback - called when a adjustment value have changed used internal for redraw the Wid...
void os_expose_widget(Widget_t *w)
os_expose_widget - Draw the the back buffer to the Widget_t surface
char * locale_from_utf8(char *utf8str)
locale_from_utf8 - convert utf8 to active codepage must be freed by the caller
Display * os_open_display(char *display_name)
os_open_display - Connect to the display to use
void os_set_window_attrb(Widget_t *w)
os_set_window_attrb - set the attribute mask to a Widget_t only work on linux, stub on Windows
void os_get_surface_size(cairo_surface_t *surface, int *width, int *height)
os_get_surface_size - get the size of the cairo surface