add text from xlib inputs
This commit is contained in:
parent
7f4c109106
commit
809814577d
@ -17,7 +17,7 @@
|
||||
# include FT_GLYPH_H
|
||||
#endif
|
||||
|
||||
#ifdef NO_STBI
|
||||
#ifndef NO_STBI
|
||||
# include "external/stb/stb_image.h"
|
||||
# include "external/stb/stb_image_write.h"
|
||||
#endif
|
||||
|
||||
30
platform.d
30
platform.d
@ -155,12 +155,13 @@ struct InputEvent
|
||||
{
|
||||
Input key;
|
||||
Modifier md;
|
||||
InputEvent* next, prev;
|
||||
string text;
|
||||
bool pressed;
|
||||
i32 x;
|
||||
i32 y;
|
||||
i32 rel_x;
|
||||
i32 rel_y;
|
||||
InputEvent* next, prev;
|
||||
}
|
||||
|
||||
enum ClipboardMode
|
||||
@ -553,14 +554,16 @@ ResetInputs(Inputs* inputs)
|
||||
}
|
||||
|
||||
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);
|
||||
node.key = input;
|
||||
|
||||
node.key = input;
|
||||
node.pressed = pressed;
|
||||
node.x = x;
|
||||
node.y = y;
|
||||
node.md = md;
|
||||
node.x = x;
|
||||
node.y = y;
|
||||
node.md = md;
|
||||
node.text = text.length ? ConvToStr(Alloc!(char)(&inputs.arena, text)) : [];
|
||||
|
||||
DLLPushFront(inputs, node, null);
|
||||
}
|
||||
@ -1241,11 +1244,14 @@ HandleEvents(void* window_ptr)
|
||||
case KeyPress:
|
||||
{
|
||||
XKeyEvent* kb_ev = &e.xkey;
|
||||
|
||||
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);
|
||||
|
||||
char[32] chars;
|
||||
i32 text_length = XLookupString(kb_ev, chars.ptr, chars.length, null, null);
|
||||
char[] text = text_length ? chars[0 .. text_length] : [];
|
||||
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 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)
|
||||
{
|
||||
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;
|
||||
case ButtonPress:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user