ltk

GUI toolkit for X11 (WIP)
git clone git://lumidify.org/ltk.git (fast, but not encrypted)
git clone https://lumidify.org/ltk.git (encrypted, but very slow)
git clone git://4kcetb7mo7hj6grozzybxtotsub5bempzo4lirzc3437amof2c2impyd.onion/ltk.git (over tor)
Log | Files | Refs | README | LICENSE

event.h (2634B)


      1 /*
      2  * Copyright (c) 2022-2024 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 LTK_EVENT_H
     18 #define LTK_EVENT_H
     19 
     20 #include <stddef.h>
     21 
     22 #include "eventdefs.h"
     23 
     24 typedef struct {
     25 	ltk_event_type type;
     26 	size_t window_id;
     27 	ltk_button_type button;
     28 	int x, y;
     29 } ltk_button_event;
     30 
     31 typedef struct {
     32 	ltk_event_type type;
     33 	size_t window_id;
     34 	int x, y;
     35 	int dx, dy;
     36 } ltk_scroll_event;
     37 
     38 typedef struct {
     39 	ltk_event_type type;
     40 	size_t window_id;
     41 	int x, y;
     42 } ltk_motion_event;
     43 
     44 typedef struct {
     45 	ltk_event_type type;
     46 	size_t window_id;
     47 	ltk_mod_type modmask;
     48 	ltk_keysym sym;
     49 	char *text;
     50 	char *mapped;
     51 } ltk_key_event;
     52 
     53 typedef struct {
     54 	ltk_event_type type;
     55 	size_t window_id;
     56 	char *new_kbd;
     57 } ltk_keyboard_event;
     58 
     59 typedef struct {
     60 	ltk_event_type type;
     61 	size_t window_id;
     62 	int x, y;
     63 	int w, h;
     64 } ltk_configure_event;
     65 
     66 /* FIXME: should maybe be handled in backend with double buffering */
     67 typedef struct {
     68 	ltk_event_type type;
     69 	size_t window_id;
     70 	int x, y;
     71 	int w, h;
     72 } ltk_expose_event;
     73 
     74 typedef struct {
     75 	ltk_event_type type;
     76 	size_t window_id;
     77 	unsigned int dpi;
     78 } ltk_dpichange_event;
     79 
     80 typedef union {
     81 	ltk_event_type type;
     82 	struct {
     83 		ltk_event_type type;
     84 		size_t window_id;
     85 	} any;
     86 	ltk_button_event button;
     87 	ltk_scroll_event scroll;
     88 	ltk_motion_event motion;
     89 	ltk_key_event key;
     90 	ltk_configure_event configure;
     91 	ltk_expose_event expose;
     92 	ltk_keyboard_event keyboard;
     93 	ltk_dpichange_event dpichange;
     94 } ltk_event;
     95 
     96 #include "graphics.h"
     97 #include "clipboard.h"
     98 
     99 void ltk_events_cleanup(void);
    100 void ltk_events_init(ltk_renderdata *renderdata);
    101 /* WARNING: Text returned in key and keyboard events must be copied before calling this function again! */
    102 int ltk_next_event(ltk_renderdata *renderdata, ltk_renderwindow **windows, size_t num_windows, ltk_clipboard *clip, size_t lang_index, ltk_event *event);
    103 void ltk_generate_keyboard_event(ltk_renderdata *renderdata, ltk_event *event);
    104 
    105 #endif /* LTK_EVENT_H */