widget.h - ltk - GUI toolkit for X11 (WIP)
HTML git clone git://lumidify.org/ltk.git (fast, but not encrypted)
HTML git clone https://lumidify.org/git/ltk.git (encrypted, but very slow)
HTML git clone git://4kcetb7mo7hj6grozzybxtotsub5bempzo4lirzc3437amof2c2impyd.onion/ltk.git (over tor)
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
widget.h (3538B)
---
1 /*
2 * Copyright (c) 2021-2026 lumidify <nobody@lumidify.org>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17 #ifndef LTKD_WIDGET_H
18 #define LTKD_WIDGET_H
19
20 #include <stddef.h>
21 #include <stdint.h>
22
23 #include "ltkd.h"
24 #include "err.h"
25
26 #include <ltk/ltk.h>
27
28 typedef struct {
29 int client; /* index of client */
30 uint32_t mask; /* generic event mask */
31 uint32_t lmask; /* generic lock mask */
32 uint32_t wmask; /* event mask for specific widget type */
33 uint32_t lwmask; /* lock event mask for specific widget type */
34 } client_event_mask;
35
36 typedef struct {
37 ltk_signal_callback callback;
38 int type;
39 } ltkd_event_handler;
40
41 typedef struct {
42 ltk_widget_id ltkid;
43 char *id;
44 client_event_mask *event_masks;
45 /* FIXME: kind of a waste of space to use size_t here */
46 size_t masks_num;
47 size_t masks_alloc;
48 ltkd_event_handler *event_handlers;
49 size_t num_event_handlers;
50 } ltkd_widget;
51
52 /* FIXME: document that multiple clients locking on event is undefined
53 (or at least order is undefined) */
54
55 void ltkd_widgets_init(void);
56 ltkd_widget *ltkd_widget_create(
57 ltk_widget_id widgetid, const char *id,
58 ltkd_event_handler *event_handlers, size_t num_event_handlers, ltkd_error *err
59 );
60 ltkd_widget *ltkd_get_widget(const char *id, ltk_widget_type type, ltkd_error *err);
61
62 int ltkd_widget_queue_specific_event(ltkd_widget *widget, const char *type, uint32_t mask, const char *data);
63
64 /*int ltkd_widget_id_free(const char *id);
65 void ltkd_set_widget(ltkd_widget *widget, const char *id);
66 void ltkd_remove_widget(const char *id);*/
67
68 void ltkd_widget_destroy(ltkd_widget *widget, int shallow);
69 int ltkd_widget_destroy_cmd(ltk_widget_id windowid, ltkd_cmd_token *tokens, size_t num_tokens, ltkd_error *err);
70 void ltkd_widget_remove_client(int client);
71
72 void ltkd_widgets_cleanup(void);
73
74 void ltkd_widget_set_event_mask(ltkd_widget *widget, int client, uint32_t mask);
75 void ltkd_widget_set_event_lmask(ltkd_widget *widget, int client, uint32_t mask);
76 void ltkd_widget_set_event_wmask(ltkd_widget *widget, int client, uint32_t mask);
77 void ltkd_widget_set_event_lwmask(ltkd_widget *widget, int client, uint32_t mask);
78 void ltkd_widget_add_to_event_mask(ltkd_widget *widget, int client, uint32_t mask);
79 void ltkd_widget_add_to_event_lmask(ltkd_widget *widget, int client, uint32_t mask);
80 void ltkd_widget_add_to_event_wmask(ltkd_widget *widget, int client, uint32_t mask);
81 void ltkd_widget_add_to_event_lwmask(ltkd_widget *widget, int client, uint32_t mask);
82 void ltkd_widget_remove_from_event_mask(ltkd_widget *widget, int client, uint32_t mask);
83 void ltkd_widget_remove_from_event_lmask(ltkd_widget *widget, int client, uint32_t mask);
84 void ltkd_widget_remove_from_event_wmask(ltkd_widget *widget, int client, uint32_t mask);
85 void ltkd_widget_remove_from_event_lwmask(ltkd_widget *widget, int client, uint32_t mask);
86
87 #endif /* LTKD_WIDGET_H */