add text from xlib inputs
This commit is contained in:
parent
7f4c109106
commit
809814577d
@ -17,7 +17,7 @@
|
|||||||
# include FT_GLYPH_H
|
# include FT_GLYPH_H
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef NO_STBI
|
#ifndef NO_STBI
|
||||||
# include "external/stb/stb_image.h"
|
# include "external/stb/stb_image.h"
|
||||||
# include "external/stb/stb_image_write.h"
|
# include "external/stb/stb_image_write.h"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
28
platform.d
28
platform.d
@ -155,12 +155,13 @@ struct InputEvent
|
|||||||
{
|
{
|
||||||
Input key;
|
Input key;
|
||||||
Modifier md;
|
Modifier md;
|
||||||
|
InputEvent* next, prev;
|
||||||
|
string text;
|
||||||
bool pressed;
|
bool pressed;
|
||||||
i32 x;
|
i32 x;
|
||||||
i32 y;
|
i32 y;
|
||||||
i32 rel_x;
|
i32 rel_x;
|
||||||
i32 rel_y;
|
i32 rel_y;
|
||||||
InputEvent* next, prev;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum ClipboardMode
|
enum ClipboardMode
|
||||||
@ -553,14 +554,16 @@ ResetInputs(Inputs* inputs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Push(Inputs* inputs, Input input, i32 x, i32 y, bool pressed, Modifier md)
|
Push(Inputs* inputs, Input input, i32 x, i32 y, bool pressed, Modifier md, char[] text = [])
|
||||||
{
|
{
|
||||||
InputEvent* node = Alloc!(InputEvent)(&inputs.arena);
|
InputEvent* node = Alloc!(InputEvent)(&inputs.arena);
|
||||||
node.key = input;
|
|
||||||
|
node.key = input;
|
||||||
node.pressed = pressed;
|
node.pressed = pressed;
|
||||||
node.x = x;
|
node.x = x;
|
||||||
node.y = y;
|
node.y = y;
|
||||||
node.md = md;
|
node.md = md;
|
||||||
|
node.text = text.length ? ConvToStr(Alloc!(char)(&inputs.arena, text)) : [];
|
||||||
|
|
||||||
DLLPushFront(inputs, node, null);
|
DLLPushFront(inputs, node, null);
|
||||||
}
|
}
|
||||||
@ -1242,10 +1245,13 @@ HandleEvents(void* window_ptr)
|
|||||||
{
|
{
|
||||||
XKeyEvent* kb_ev = &e.xkey;
|
XKeyEvent* kb_ev = &e.xkey;
|
||||||
|
|
||||||
bool pressed = e.type == KeyPress;
|
char[32] chars;
|
||||||
u32 code = kb_ev.keycode;
|
i32 text_length = XLookupString(kb_ev, chars.ptr, chars.length, null, null);
|
||||||
KeySym key_sym = XkbKeycodeToKeysym(w.display, cast(KeyCode)code, 0, 0);
|
char[] text = text_length ? chars[0 .. text_length] : [];
|
||||||
Input input = ConvertInput(key_sym);
|
bool pressed = e.type == KeyPress;
|
||||||
|
u32 code = kb_ev.keycode;
|
||||||
|
KeySym key_sym = XkbKeycodeToKeysym(w.display, cast(KeyCode)code, 0, 0);
|
||||||
|
Input input = ConvertInput(key_sym);
|
||||||
|
|
||||||
enum modifier_inputs = [Input.LeftShift, Input.RightShift, Input.LeftCtrl, Input.RightCtrl, Input.LeftAlt, Input.RightAlt];
|
enum modifier_inputs = [Input.LeftShift, Input.RightShift, Input.LeftCtrl, Input.RightCtrl, Input.LeftAlt, Input.RightAlt];
|
||||||
enum modifiers = [MD.LeftShift, MD.RightShift, MD.LeftCtrl, MD.RightCtrl, MD.LeftAlt, MD.RightAlt];
|
enum modifiers = [MD.LeftShift, MD.RightShift, MD.LeftCtrl, MD.RightCtrl, MD.LeftAlt, MD.RightAlt];
|
||||||
@ -1260,7 +1266,7 @@ HandleEvents(void* window_ptr)
|
|||||||
|
|
||||||
if(input != Input.None)
|
if(input != Input.None)
|
||||||
{
|
{
|
||||||
Push(inputs, input, kb_ev.x, kb_ev.y, pressed, w.modifier);
|
Push(inputs, input, kb_ev.x, kb_ev.y, pressed, w.modifier, text);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case ButtonPress:
|
case ButtonPress:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user