XenevaOS
Loading...
Searching...
No Matches
window.h
Go to the documentation of this file.
1
30#ifndef __CH_WINDOW_H__
31#define __CH_WINDOW_H__
32
33#include <stdint.h>
34#include "../chitralekha.h"
35#include "../color.h"
36#include "../draw.h"
37#include "base.h"
38#include "list.h"
39#include <setjmp.h>
40
41#define CHITRALEKHA_DEFAULT_WIN_WIDTH 400
42#define CHITRALEKHA_DEFAULT_WIN_HEIGHT 300
43#define CHITRALEKHA_WINDOW_DEFAULT_PAD_Y 26
44#define CHITRALEKHA_WINDOW_DEFAULT_PAD_X 1
45
46#define WINDOW_GLOBAL_CONTROL_CLOSE 1
47#define WINDOW_GLOBAL_CONTROL_MAXIMIZE 2
48#define WINDOW_GLOBAL_CONTROL_MINIMIZE 3
49#define WINDOW_GLOBAL_CONTROL_CUSTOM 4
50
51#define WINDOW_FLAG_MOVABLE (1 << 0)
52#define WINDOW_FLAG_STATIC (1 << 1)
53#define WINDOW_FLAG_ALWAYS_ON_TOP (1 << 2)
54#define WINDOW_FLAG_NON_RESIZABLE (1 << 3)
55#define WINDOW_FLAG_BROADCAST_LISTENER (1 << 4)
56#define WINDOW_FLAG_ANIMATED (1 << 5)
57#define WINDOW_FLAG_BLOCKED (1 << 6)
58#define WINDOW_FLAG_MESSAGEBOX (1 << 7)
59#define WINDOW_FLAG_DIALOGBOX (1 << 8)
60#define WINDOW_FLAG_ANIMATION_FADE_IN (1 << 9)
61#define WINDOW_FLAG_ANIMATION_FADE_OUT (1 << 10)
62#define WINDOW_FLAG_POPUP (1 << 11)
63/* Opt in to the compositor's glassmorphic pipeline. The blur buffers are
64 * allocated by the compositor when the window is created, so this flag MUST
65 * be passed to ChCreateWindow. The compositor then blends every translucent
66 * pixel against the blurred desktop backdrop (DeodhaiXR WINDOW_FLAG_GLASS).
67 * Pair it with ChWindowSetGlassMorphism() (chrome) and translucent fills in
68 * the client paint code (content). */
69#define WINDOW_FLAG_GLASS (1 << 12)
70
71#define CHITRALEKHA_WIDGET_TYPE_CONTROL (1 << 1)
72#define CHITRALEKHA_WIDGET_TYPE_POPUP (1 << 2)
73
74#define CHITRALEKHA_WIDGET_SCROLL_HORIZONTAL 0
75#define CHITRALEKHA_WIDGET_SCROLL_VERTICAL 1
76
77#define WINDOW_HANDLE_TYPE_NORMAL 1
78#define WINDOW_HANDLE_TYPE_POPUP 2
79
80//#pragma pack(push,1)
96
97static inline bool ChSharedFlagLoad(const bool* flag) {
98 return __atomic_load_n(flag, __ATOMIC_ACQUIRE);
99}
100
101static inline void ChSharedFlagStore(bool* flag, bool value) {
102 __atomic_store_n(flag, value, __ATOMIC_RELEASE);
103}
104//#pragma pack(pop)
105
129
130typedef struct _ChWidget_ {
131 int x;
132 int y;
133 int w;
134 int h;
138 bool hover;
145 void (*ChMouseEvent)(struct _ChWidget_* widget, ChWindow* win, int x, int y, int button);
146 void (*ChTouchEvent)(struct _ChWidget_* widget, ChWindow* win, int x, int y);
147 void (*ChScrollEvent)(struct _ChWidget_* widget,
148 ChWindow* win,
149 int scrollval,
152 void (*ChDestroy)(struct _ChWidget_* widget, ChWindow* win);
154
173
174#pragma pack(push, 1)
188#pragma pack(pop)
189
202
203#ifdef __cplusplus
204XE_EXTERN {
205#endif
206
207 /*
208 * ChCreateWindow -- create a new chitralekha window
209 * @param app -- pointer to Chitralekha app
210 * @param attrib -- window attributes
211 * @param title -- title of the window
212 * @param x -- x position of the window
213 * @param y -- y position of the window
214 * @param w -- width of the window
215 * @param h -- height of the window
216 */
218 ChitralekhaApp * app, uint16_t attrib, char* title, int x, int y, int w, int h);
219
220 /*
221 * ChWindowAddSubWindow -- add sub window to parent window list
222 * @param parent -- Pointer to main window
223 * @param win -- Pointer to sub window
224 */
226
227 /*
228 * ChWindowBroadcastIcon -- broadcast icon information to
229 * broadcast listener
230 * @param app -- pointer to chitralekha application
231 * @param iconfile -- path of the icon file, supported formats
232 * are : 32bit- bmp file
233 */
234 XE_LIB void ChWindowBroadcastIcon(ChitralekhaApp * app, char* iconfile);
235
236 /*
237 * ChWindowPaint -- paint the entire window
238 * @param win -- Pointer to window
239 */
241
242 /*
243 * ChWindowUpdate -- update a portion or whole window
244 * @param win -- Pointer to window
245 * @param x -- x position of the dirty area
246 * @param y -- y position of the dirty area
247 * @param w - width of the dirty area
248 * @param h -- height of the dirty area
249 * @param updateEntireWin -- update entire window
250 * @param dirty -- dirty specifies small areas of the window
251 */
253 ChWindow * win, int x, int y, int w, int h, bool updateEntireWin, bool dirty);
254
255 /*
256 * ChWindowHide -- hide the window
257 * basically it sends command to deodhai
258 * @param win -- Pointer to window structure
259 */
261
262 /*
263 * ChGetWindowHandle -- get a specific window handle from
264 * the system looking by its name
265 * @param app -- Pointer to application instance
266 * @param title -- desired window title
267 */
269 /*
270 * ChWindowHandleMouse -- handle mouse event
271 * @param win -- Pointer to window
272 * @param x -- X coord of the mouse
273 * @param y -- Y coord of the mouse
274 * @param button -- button state of the mouse
275 */
276 XE_LIB void ChWindowHandleMouse(ChWindow * win, int x, int y, int button);
277
278 /*
279 * ChWindowHandleTouch -- handle touch event
280 * @param win -- Pointer to window
281 * @param x -- X coord of the mouse
282 * @param y -- Y coord of the mouse
283 * @param button -- button state of the mouse
284 */
285 XE_LIB void ChWindowHandleTouch(ChWindow * win, int x, int y, int button);
286
287 /*
288 * ChWindowSetFocused -- bring a window to focused state
289 * @param win -- Pointer to window
290 */
292 /*
293 * ChWindowHandleFocus -- handle focus changed events
294 * @param win -- Pointer to window
295 * @param focus_val -- focus bit, 1 -- focused, 0 -- not focused
296 * @param handle -- handle number of the window
297 */
298 XE_LIB void ChWindowHandleFocus(ChWindow * win, bool focus_val, uint32_t handle);
299
300 /*
301 * ChWindowGetBackgroundColor -- returns the current
302 * background color
303 * @param win -- Pointer to Chitralekha Window
304 */
306
307 /*
308 * ChWindowAddWidget -- adds a widget to window
309 * @param win -- Pointer to root window
310 * @param wid -- Pointer to widget needs to be added
311 */
313
314 /*
315 * ChWindowAddSubWindow -- add sub window to parent window list
316 * @param parent -- Pointer to main window
317 * @param win -- Pointer to sub window
318 */
320
321 /*
322 * ChGetWindowByHandle -- returns window by looking sub windows list
323 * @param mainWin -- pointer to main window
324 * @param handle -- Handle of the window
325 */
327
328 /*
329 * ChGetPopupWindowByHandle -- looks for popup window by its handle
330 * @param mainWin -- Pointer to main window
331 * @param handle -- Handle of the popup window
332 */
334
335 /*
336 * ChPopupWindowHandleMouse -- Handle popup window's mouse event externally
337 * @param win -- Pointer to popup window
338 * @param mainWin -- Pointer to main Window
339 * @param x -- Mouse x coordinate
340 * @param y -- Mouse y coordinate
341 * @param button -- Mouse button state
342 */
343 XE_LIB void ChPopupWindowHandleMouse(ChWindow * win, int x, int y, int button);
344
345 /*
346 * ChWindowSetFlags -- set window flags
347 * @param win -- Pointer to window
348 * @param flags -- flags to set
349 */
351
352 /*
353 * ChWindowSetGlassMorphism -- apply the glassmorphic look to a window
354 * @param win -- Pointer to the window
355 * @param alpha -- opacity of the glass pane, 0 (invisible) .. 255 (opaque)
356 *
357 * Toolkit-level opt-in for the deodhai glass pipeline. The window must be
358 * created with WINDOW_FLAG_GLASS (the compositor allocates its backdrop
359 * blur buffers at creation time); this call then paints a translucent pane
360 * over the whole surface so the blurred desktop shows through, and turns the
361 * uniform window fade off so glass pixels are not blended twice.
362 */
364
365 /*
366 * ChWindowMove -- moves target window to a new location
367 * @param win -- Pointer to the window
368 * @param newX -- new x location relative to screen coord
369 * @param newY -- new y location relative to screen coord
370 */
371 XE_LIB void ChWindowMove(ChWindow * win, int newX, int newY);
372
373 /*
374 * ChWindowRegisterJump -- register long jump address
375 * @param win -- Pointer to main window
376 */
378
379 /*
380 * ChWindowCloseWindow -- clears window related data and
381 * sends close message to deodhai
382 * @param win -- Pointer to window data
383 */
385
386 /*
387 * ChCreatePopupWindow -- *Create a popup window
388 * @param app -- Pointer to application
389 * @param win -- Pointer to Window
390 * @param x -- X coordinate
391 * @param y -- Y coordinate
392 * @param w -- Width of the window
393 * @param h -- Height of the window
394 * @param type -- type of the window
395 */
397 ChWindow * win, int x, int y, int w, int h, uint16_t flags, char* title);
398
399 /*
400 * ChPopupWindowUpdate -- update the popup window
401 * @param pw -- Pointer to Chitralekha Popup Window
402 * @param x -- X location
403 * @param y -- Y location
404 * @param w -- Width of the popup window
405 * @param h -- Height of the popup window
406 */
407 XE_LIB void ChPopupWindowUpdate(ChPopupWindow * pw, int x, int y, int w, int h);
408
409 /*
410 * ChPopupWindowShow -- show the popup window
411 * @param pw -- Pointer to Popup Window
412 * @param win -- Pointer to Chitralekha Main Window
413 */
415
416 /*
417 * ChPopupWindowUpdateLocation -- update the location of popup window relative to
418 * main window
419 * @param pwin -- Pointer to Popup Window
420 * @param win -- Pointer to Main Window
421 * @param x -- X location
422 * @param y -- Y location
423 */
424 XE_LIB void ChPopupWindowUpdateLocation(ChWindow * pwin, ChWindow * win, int x, int y);
425
426 /*
427 * ChPopupWindowHide -- hide the popup window
428 * @param pw -- Pointer to Popup Window
429 * @param perent -- Parent Window
430 */
432
433 /*
434 * @brief ChWindowHandleDestroyBuffer -- handle destroy buffer
435 * message from server
436 * @param win -- Pointer to main window
437 */
439
446 XE_LIB void ChWindowHandleReinitBuffer(ChWindow * win, int bufferkey);
447
448#ifdef __cplusplus
449}
450#endif
451
452#endif
uint8_t flags
Definition virtio.h:0
XE_LIB void ChWindowHide(ChWindow *win)
Definition window.cpp:451
struct _popup_win_ ChPopupWindow
XE_LIB void ChWindowHandleTouch(ChWindow *win, int x, int y, int button)
Definition window.cpp:610
XE_LIB void ChPopupWindowHandleMouse(ChWindow *win, int x, int y, int button)
Definition window.cpp:707
XE_LIB void ChPopupWindowUpdate(ChPopupWindow *pw, int x, int y, int w, int h)
Definition window.cpp:1033
XE_LIB void ChWindowCloseWindow(ChWindow *win)
Definition window.cpp:880
struct _ChSharedWin_ ChSharedWinInfo
XE_LIB void ChWindowSetFlags(ChWindow *win, uint16_t flags)
Definition window.cpp:776
struct _chwin_ ChWindow
XE_LIB void ChWindowRegisterJump(ChWindow *win)
Definition window.cpp:767
XE_LIB void ChWindowHandleMouse(ChWindow *win, int x, int y, int button)
Definition window.cpp:510
XE_LIB void ChWindowHandleFocus(ChWindow *win, bool focus_val, uint32_t handle)
Definition window.cpp:745
XE_LIB void ChPopupWindowHide(ChWindow *pw, ChWindow *parent)
Definition window.cpp:1089
XE_LIB void ChWindowMove(ChWindow *win, int newX, int newY)
Definition window.cpp:793
XE_LIB void ChWindowBroadcastIcon(ChitralekhaApp *app, char *iconfile)
Definition window.cpp:258
XE_LIB ChWindow * ChGetWindowByHandle(ChWindow *mainWin, int handle)
Definition window.cpp:415
XE_LIB ChWindow * ChGetPopupWindowByHandle(ChWindow *mainWin, int handle)
Definition window.cpp:436
XE_LIB ChWindow * ChCreateWindow(ChitralekhaApp *app, uint16_t attrib, char *title, int x, int y, int w, int h)
Definition window.cpp:171
XE_LIB void ChPopupWindowUpdateLocation(ChWindow *pwin, ChWindow *win, int x, int y)
Definition window.cpp:1079
XE_LIB void ChWindowSetGlassMorphism(ChWindow *win, uint8_t alpha)
Definition window.cpp:388
XE_LIB void ChWindowSetFocused(ChWindow *win)
Definition window.cpp:493
XE_LIB uint32_t ChWindowGetBackgroundColor(ChWindow *win)
Definition window.cpp:969
XE_LIB void ChWindowHandleReinitBuffer(ChWindow *win, int bufferkey)
ChWindowHandleReinitBuffer – reinitialize back buffer with requested size.
Definition window.cpp:1120
XE_LIB uint32_t ChGetWindowHandle(ChitralekhaApp *app, char *title)
Definition window.cpp:466
XE_LIB void ChWindowHandleDestroyBuffer(ChWindow *win)
Definition window.cpp:1098
XE_LIB void ChWindowAddWidget(ChWindow *win, ChWidget *wid)
Definition window.cpp:759
struct _global_ctrl_ ChWinGlobalControl
XE_LIB ChWindow * ChCreatePopupWindow(ChWindow *win, int x, int y, int w, int h, uint16_t flags, char *title)
Definition window.cpp:984
XE_LIB void ChWindowAddSubWindow(ChWindow *parent, ChWindow *win)
Definition window.cpp:403
XE_LIB void ChPopupWindowShow(ChWindow *pw, ChWindow *win)
Definition window.cpp:1062
struct _popup_sh_win_ ChPopupSharedWin
XE_LIB void ChWindowUpdate(ChWindow *win, int x, int y, int w, int h, bool updateEntireWin, bool dirty)
Definition window.cpp:278
XE_LIB void ChWindowPaint(ChWindow *win)
Definition window.cpp:357
struct _ChWidget_ ChWidget
ChWindow * mainWin
Definition main.cpp:58
ChitralekhaApp * app
Definition main.cpp:57
#define XE_LIB
Definition _xeneva.h:55
#define XE_EXTERN
Definition _xeneva.h:50
unsigned int uint32_t
Definition acefiex.h:163
unsigned char uint8_t
Definition acefiex.h:161
unsigned short int uint16_t
Definition acefiex.h:162
flag
Definition bytecode.h:29
char title[128]
Definition d_main.c:877
struct kobject * parent
Definition kobject.h:91
int y
Definition layout.c:118
int h
Definition layout.c:118
int x
Definition layout.c:118
int w
Definition layout.c:118
ChWindow * win
Definition namdapha.cpp:60
long long jmp_buf[_JBLEN]
Definition setjmp.h:35
Definition base.h:85
Definition chitralekha.h:40
Definition window.h:81
bool windowReady
Definition window.h:93
bool alpha
Definition window.h:90
int width
Definition window.h:88
int y
Definition window.h:87
bool dirty
Definition window.h:84
int x
Definition window.h:86
double alphaValue
Definition window.h:92
int height
Definition window.h:89
ChRect rect[256]
Definition window.h:82
uint32_t rect_count
Definition window.h:83
bool hide
Definition window.h:91
bool updateEntireWindow
Definition window.h:85
bool zoomed
Definition window.h:94
Definition window.h:130
void(* ChTouchEvent)(struct _ChWidget_ *widget, ChWindow *win, int x, int y)
Definition window.h:146
void(* ChPaintHandler)(struct _ChWidget_ *widget, ChWindow *win)
Definition window.h:151
void(* ChMouseEvent)(struct _ChWidget_ *widget, ChWindow *win, int x, int y, int button)
Definition window.h:145
int x
Definition window.h:131
int w
Definition window.h:133
bool visible
Definition window.h:141
bool hoverPainted
Definition window.h:139
int lastMouseX
Definition window.h:135
uint8_t type
Definition window.h:143
void(* ChDestroy)(struct _ChWidget_ *widget, ChWindow *win)
Definition window.h:152
bool hover
Definition window.h:138
bool touched
Definition window.h:142
void(* ChScrollEvent)(struct _ChWidget_ *widget, ChWindow *win, int scrollval, uint8_t scrolltype)
Definition window.h:147
int y
Definition window.h:132
int h
Definition window.h:134
int lastMouseY
Definition window.h:136
void(* ChActionHandler)(struct _ChWidget_ *widget, ChWindow *win)
Definition window.h:144
bool KillFocus
Definition window.h:140
bool clicked
Definition window.h:137
Definition draw.h:42
Definition window.h:106
void * selectedMenuItem
Definition window.h:123
void * sharedwin
Definition window.h:109
uint32_t color
Definition window.h:115
ChSharedWinInfo * info
Definition window.h:112
list_t * popup
Definition window.h:120
list_t * widgets
Definition window.h:118
list_t * GlobalControls
Definition window.h:117
void(* ChWinPaint)(struct _chwin_ *win)
Definition window.h:126
list_t * subwindow
Definition window.h:119
ChitralekhaApp * app
Definition window.h:113
struct _chwin_ * parent
Definition window.h:121
jmp_buf jump
Definition window.h:125
bool focused
Definition window.h:116
void * focusedWidget
Definition window.h:124
char * title
Definition window.h:111
ChCanvas * canv
Definition window.h:110
void(* ChCloseWin)(struct _chwin_ *win)
Definition window.h:127
void * currentPopupMenu
Definition window.h:122
uint16_t flags
Definition window.h:107
uint32_t * buffer
Definition window.h:108
uint32_t handle
Definition window.h:114
Definition window.h:155
uint32_t hoverOutlineColor
Definition window.h:165
void(* ChGlobalMouseEvent)(ChWindow *win, struct _global_ctrl_ *glbl, int x, int y, int button)
Definition window.h:169
uint32_t clickedFillColor
Definition window.h:166
int x
Definition window.h:156
uint32_t fillColor
Definition window.h:163
bool hover
Definition window.h:161
uint32_t clickedOutlineColor
Definition window.h:167
int w
Definition window.h:158
bool clicked
Definition window.h:162
int y
Definition window.h:157
void(* ChGlobalTouchEvent)(ChWindow *win, struct _global_ctrl_ *glbl, int x, int y)
Definition window.h:170
void(* ChGlobalActionEvent)(ChWindow *win, struct _global_ctrl_ *glbl)
Definition window.h:171
int h
Definition window.h:159
uint8_t type
Definition window.h:160
void(* ChGlobalButtonPaint)(ChWindow *win, struct _global_ctrl_ *glbl)
Definition window.h:168
uint32_t outlineColor
Definition window.h:164
Definition list.h:46
Definition window.h:175
ChRect rect[100]
Definition window.h:176
int w
Definition window.h:180
uint32_t rect_count
Definition window.h:177
bool hide
Definition window.h:184
bool dirty
Definition window.h:182
int x
Definition window.h:178
int h
Definition window.h:181
bool alpha
Definition window.h:186
bool popuped
Definition window.h:185
int y
Definition window.h:179
bool close
Definition window.h:183
Definition window.h:190
uint32_t * buffer
Definition window.h:193
list_t * widgets
Definition window.h:196
ChWidget wid
Definition window.h:191
uint16_t buffWinKey
Definition window.h:195
uint16_t shwinKey
Definition window.h:194
ChPopupSharedWin * shwin
Definition window.h:192
void(* ChPopupWindowPaint)(struct _popup_win_ *pwin, ChWindow *win)
Definition window.h:200
int handle
Definition window.h:197
ChCanvas * canv
Definition window.h:198
bool hidden
Definition window.h:199
bool dirty
Definition term.cpp:55