os -> wm; *_w32_ -> w32_*_, *_lnx_ -> lnx_*_

This commit is contained in:
Ryan Fleury committed 2026-05-08 21:17:21 -07:00
1 parent 9a7782de47
commit 2f6d0f9aaa
52 files changed
+3086 -3115

No files matched your search

+189 -189
View File
@@ -4,11 +4,11 @@
////////////////////////////////
//~ rjf: Helpers
internal OS_LNX_Window *
internal LNX_WM_Window *
os_lnx_window_from_x11window(Window window)
{
OS_LNX_Window *result = 0;
for(OS_LNX_Window *w = os_lnx_gfx_state->first_window; w != 0; w = w->next)
LNX_WM_Window *result = 0;
for(LNX_WM_Window *w = os_lnx_gfx_state->first_window; w != 0; w = w->next)
{
if(w->window == window)
{
@@ -23,11 +23,11 @@ os_lnx_window_from_x11window(Window window)
//~ rjf: @os_hooks Main Initialization API (Implemented Per-OS)
internal void
os_gfx_init(void)
wm_init(void)
{
//- rjf: initialize basics
Arena *arena = arena_alloc();
os_lnx_gfx_state = push_array(arena, OS_LNX_GfxState, 1);
os_lnx_gfx_state = push_array(arena, LNX_WM_GfxState, 1);
os_lnx_gfx_state->arena = arena;
os_lnx_gfx_state->display = XOpenDisplay(0);
@@ -48,20 +48,20 @@ os_gfx_init(void)
{
struct
{
OS_Cursor cursor;
WM_Cursor cursor;
unsigned int id;
}
map[] =
{
{OS_Cursor_Pointer, XC_left_ptr},
{OS_Cursor_IBar, XC_xterm},
{OS_Cursor_LeftRight, XC_sb_h_double_arrow},
{OS_Cursor_UpDown, XC_sb_v_double_arrow},
{OS_Cursor_DownRight, XC_bottom_right_corner},
{OS_Cursor_UpRight, XC_top_right_corner},
{OS_Cursor_UpDownLeftRight, XC_fleur},
{OS_Cursor_HandPoint, XC_hand1},
{OS_Cursor_Disabled, XC_X_cursor},
{WM_Cursor_Pointer, XC_left_ptr},
{WM_Cursor_IBar, XC_xterm},
{WM_Cursor_LeftRight, XC_sb_h_double_arrow},
{WM_Cursor_UpDown, XC_sb_v_double_arrow},
{WM_Cursor_DownRight, XC_bottom_right_corner},
{WM_Cursor_UpRight, XC_top_right_corner},
{WM_Cursor_UpDownLeftRight, XC_fleur},
{WM_Cursor_HandPoint, XC_hand1},
{WM_Cursor_Disabled, XC_X_cursor},
};
for EachElement(idx, map)
{
@@ -73,8 +73,8 @@ os_gfx_init(void)
////////////////////////////////
//~ rjf: @os_hooks Graphics System Info (Implemented Per-OS)
internal OS_GfxInfo *
os_get_gfx_info(void)
internal WM_SystemInfo *
wm_get_system_info(void)
{
return &os_lnx_gfx_state->gfx_info;
}
@@ -83,13 +83,13 @@ os_get_gfx_info(void)
//~ rjf: @os_hooks Clipboards (Implemented Per-OS)
internal void
os_set_clipboard_text(String8 string)
wm_set_clipboard_text(String8 string)
{
}
internal String8
os_get_clipboard_text(Arena *arena)
wm_get_clipboard_text(Arena *arena)
{
String8 result = {0};
return result;
@@ -98,20 +98,20 @@ os_get_clipboard_text(Arena *arena)
////////////////////////////////
//~ rjf: @os_hooks Windows (Implemented Per-OS)
internal OS_Window
os_window_open(Rng2F32 rect, OS_WindowFlags flags, String8 title)
internal WM_Window
wm_window_open(Rng2F32 rect, WM_WindowFlags flags, String8 title)
{
Vec2F32 resolution = dim_2f32(rect);
//- rjf: allocate window
OS_LNX_Window *w = os_lnx_gfx_state->free_window;
LNX_WM_Window *w = os_lnx_gfx_state->free_window;
if(w)
{
SLLStackPop(os_lnx_gfx_state->free_window);
}
else
{
w = push_array_no_zero(os_lnx_gfx_state->arena, OS_LNX_Window, 1);
w = push_array_no_zero(os_lnx_gfx_state->arena, LNX_WM_Window, 1);
}
MemoryZeroStruct(w);
DLLPushBack(os_lnx_gfx_state->first_window, os_lnx_gfx_state->last_window, w);
@@ -161,50 +161,50 @@ os_window_open(Rng2F32 rect, OS_WindowFlags flags, String8 title)
scratch_end(scratch);
//- rjf: convert to handle & return
OS_Window handle = {(U64)w};
WM_Window handle = {(U64)w};
return handle;
}
internal void
os_window_close(OS_Window handle)
wm_window_close(WM_Window handle)
{
if(os_window_match(handle, os_window_zero())) {return;}
OS_LNX_Window *w = (OS_LNX_Window *)handle.u64[0];
if(wm_window_match(handle, wm_window_zero())) {return;}
LNX_WM_Window *w = (LNX_WM_Window *)handle.u64[0];
XDestroyWindow(os_lnx_gfx_state->display, w->window);
}
internal void
os_window_set_title(OS_Window handle, String8 title)
wm_window_set_title(WM_Window handle, String8 title)
{
if(os_window_match(handle, os_window_zero())) {return;}
if(wm_window_match(handle, wm_window_zero())) {return;}
Temp scratch = scratch_begin(0, 0);
OS_LNX_Window *w = (OS_LNX_Window *)handle.u64[0];
LNX_WM_Window *w = (LNX_WM_Window *)handle.u64[0];
String8 title_copy = push_str8_copy(scratch.arena, title);
XStoreName(os_lnx_gfx_state->display, w->window, (char *)title_copy.str);
scratch_end(scratch);
}
internal void
os_window_first_paint(OS_Window handle)
wm_window_first_paint(WM_Window handle)
{
if(os_window_match(handle, os_window_zero())) {return;}
OS_LNX_Window *w = (OS_LNX_Window *)handle.u64[0];
if(wm_window_match(handle, wm_window_zero())) {return;}
LNX_WM_Window *w = (LNX_WM_Window *)handle.u64[0];
XMapWindow(os_lnx_gfx_state->display, w->window);
}
internal void
os_window_focus(OS_Window handle)
wm_window_focus(WM_Window handle)
{
if(os_window_match(handle, os_window_zero())) {return;}
OS_LNX_Window *w = (OS_LNX_Window *)handle.u64[0];
if(wm_window_match(handle, wm_window_zero())) {return;}
LNX_WM_Window *w = (LNX_WM_Window *)handle.u64[0];
XSetInputFocus(os_lnx_gfx_state->display, w->window, RevertToNone, CurrentTime);
}
internal B32
os_window_is_focused(OS_Window handle)
wm_window_is_focused(WM_Window handle)
{
if(os_window_match(handle, os_window_zero())) {return 0;}
OS_LNX_Window *w = (OS_LNX_Window *)handle.u64[0];
if(wm_window_match(handle, wm_window_zero())) {return 0;}
LNX_WM_Window *w = (LNX_WM_Window *)handle.u64[0];
Window focused_window = 0;
int revert_to = 0;
XGetInputFocus(os_lnx_gfx_state->display, &focused_window, &revert_to);
@@ -213,97 +213,97 @@ os_window_is_focused(OS_Window handle)
}
internal B32
os_window_is_fullscreen(OS_Window handle)
wm_window_is_fullscreen(WM_Window handle)
{
if(os_window_match(handle, os_window_zero())) {return 0;}
if(wm_window_match(handle, wm_window_zero())) {return 0;}
// TODO(rjf)
return 0;
}
internal void
os_window_set_fullscreen(OS_Window handle, B32 fullscreen)
wm_window_set_fullscreen(WM_Window handle, B32 fullscreen)
{
if(os_window_match(handle, os_window_zero())) {return;}
if(wm_window_match(handle, wm_window_zero())) {return;}
// TODO(rjf)
}
internal B32
os_window_is_maximized(OS_Window handle)
wm_window_is_maximized(WM_Window handle)
{
if(os_window_match(handle, os_window_zero())) {return 0;}
if(wm_window_match(handle, wm_window_zero())) {return 0;}
// TODO(rjf)
return 0;
}
internal void
os_window_set_maximized(OS_Window handle, B32 maximized)
wm_window_set_maximized(WM_Window handle, B32 maximized)
{
if(os_window_match(handle, os_window_zero())) {return;}
if(wm_window_match(handle, wm_window_zero())) {return;}
// TODO(rjf)
}
internal B32
os_window_is_minimized(OS_Window handle)
wm_window_is_minimized(WM_Window handle)
{
if(os_window_match(handle, os_window_zero())) {return 0;}
if(wm_window_match(handle, wm_window_zero())) {return 0;}
// TODO(rjf)
return 0;
}
internal void
os_window_set_minimized(OS_Window handle, B32 minimized)
wm_window_set_minimized(WM_Window handle, B32 minimized)
{
if(os_window_match(handle, os_window_zero())) {return;}
if(wm_window_match(handle, wm_window_zero())) {return;}
// TODO(rjf)
}
internal void
os_window_bring_to_front(OS_Window handle)
wm_window_bring_to_front(WM_Window handle)
{
if(os_window_match(handle, os_window_zero())) {return;}
if(wm_window_match(handle, wm_window_zero())) {return;}
// TODO(rjf)
}
internal void
os_window_set_monitor(OS_Window handle, OS_Monitor monitor)
wm_window_set_monitor(WM_Window handle, WM_Monitor monitor)
{
if(os_window_match(handle, os_window_zero())) {return;}
if(wm_window_match(handle, wm_window_zero())) {return;}
// TODO(rjf)
}
internal void
os_window_clear_custom_border_data(OS_Window handle)
wm_window_clear_custom_border_data(WM_Window handle)
{
if(os_window_match(handle, os_window_zero())) {return;}
if(wm_window_match(handle, wm_window_zero())) {return;}
// TODO(rjf)
}
internal void
os_window_push_custom_title_bar(OS_Window handle, F32 thickness)
wm_window_push_custom_title_bar(WM_Window handle, F32 thickness)
{
if(os_window_match(handle, os_window_zero())) {return;}
if(wm_window_match(handle, wm_window_zero())) {return;}
// TODO(rjf)
}
internal void
os_window_push_custom_edges(OS_Window handle, F32 thickness)
wm_window_push_custom_edges(WM_Window handle, F32 thickness)
{
if(os_window_match(handle, os_window_zero())) {return;}
if(wm_window_match(handle, wm_window_zero())) {return;}
// TODO(rjf)
}
internal void
os_window_push_custom_title_bar_client_area(OS_Window handle, Rng2F32 rect)
wm_window_push_custom_title_bar_client_area(WM_Window handle, Rng2F32 rect)
{
if(os_window_match(handle, os_window_zero())) {return;}
if(wm_window_match(handle, wm_window_zero())) {return;}
// TODO(rjf)
}
internal Rng2F32
os_rect_from_window(OS_Window handle)
wm_rect_from_window(WM_Window handle)
{
if(os_window_match(handle, os_window_zero())) {return r2f32p(0, 0, 0, 0);}
OS_LNX_Window *w = (OS_LNX_Window *)handle.u64[0];
if(wm_window_match(handle, wm_window_zero())) {return r2f32p(0, 0, 0, 0);}
LNX_WM_Window *w = (LNX_WM_Window *)handle.u64[0];
XWindowAttributes atts = {0};
Status s = XGetWindowAttributes(os_lnx_gfx_state->display, w->window, &atts);
Rng2F32 result = r2f32p((F32)atts.x, (F32)atts.y, (F32)atts.x + (F32)atts.width, (F32)atts.y + (F32)atts.height);
@@ -311,9 +311,9 @@ os_rect_from_window(OS_Window handle)
}
internal Rng2F32
os_client_rect_from_window(OS_Window handle)
wm_client_rect_from_window(WM_Window handle)
{
OS_LNX_Window *w = (OS_LNX_Window *)handle.u64[0];
LNX_WM_Window *w = (LNX_WM_Window *)handle.u64[0];
XWindowAttributes atts = {0};
Status s = XGetWindowAttributes(os_lnx_gfx_state->display, w->window, &atts);
Rng2F32 result = r2f32p(0, 0, (F32)atts.width, (F32)atts.height);
@@ -321,7 +321,7 @@ os_client_rect_from_window(OS_Window handle)
}
internal F32
os_dpi_from_window(OS_Window handle)
wm_dpi_from_window(WM_Window handle)
{
// TODO(rjf)
return 96.f;
@@ -330,16 +330,16 @@ os_dpi_from_window(OS_Window handle)
////////////////////////////////
//~ rjf: @os_hooks External Windows (Implemented Per-OS)
internal OS_ExternalWindow
os_focused_external_window(void)
internal WM_ExtWindow
wm_focused_external_window(void)
{
OS_ExternalWindow result = {0};
WM_ExtWindow result = {0};
// TODO(rjf)
return result;
}
internal void
os_focus_external_window(OS_ExternalWindow handle)
wm_focus_external_window(WM_ExtWindow handle)
{
// TODO(rjf)
}
@@ -347,46 +347,46 @@ os_focus_external_window(OS_ExternalWindow handle)
////////////////////////////////
//~ rjf: @os_hooks Monitors (Implemented Per-OS)
internal OS_MonitorArray
os_push_monitors_array(Arena *arena)
internal WM_MonitorArray
wm_push_monitors_array(Arena *arena)
{
OS_MonitorArray result = {0};
WM_MonitorArray result = {0};
// TODO(rjf)
return result;
}
internal OS_Monitor
os_primary_monitor(void)
internal WM_Monitor
wm_primary_monitor(void)
{
OS_Monitor result = {0};
WM_Monitor result = {0};
// TODO(rjf)
return result;
}
internal OS_Monitor
os_monitor_from_window(OS_Window window)
internal WM_Monitor
wm_monitor_from_window(WM_Window window)
{
OS_Monitor result = {0};
WM_Monitor result = {0};
// TODO(rjf)
return result;
}
internal String8
os_name_from_monitor(Arena *arena, OS_Monitor monitor)
wm_name_from_monitor(Arena *arena, WM_Monitor monitor)
{
// TODO(rjf)
return str8_zero();
}
internal Vec2F32
os_dim_from_monitor(OS_Monitor monitor)
wm_dim_from_monitor(WM_Monitor monitor)
{
// TODO(rjf)
return v2f32(0, 0);
}
internal F32
os_dpi_from_monitor(OS_Monitor monitor)
wm_dpi_from_monitor(WM_Monitor monitor)
{
// TODO(rjf)
return 96.f;
@@ -396,15 +396,15 @@ os_dpi_from_monitor(OS_Monitor monitor)
//~ rjf: @os_hooks Events (Implemented Per-OS)
internal void
os_send_wakeup_event(void)
wm_send_wakeup_event(void)
{
// TODO(rjf)
}
internal OS_EventList
os_get_events(Arena *arena, B32 wait)
internal WM_EventList
wm_get_events(Arena *arena, B32 wait)
{
OS_EventList evts = {0};
WM_EventList evts = {0};
for(;XPending(os_lnx_gfx_state->display) > 0 || (wait && evts.count == 0);)
{
XEvent evt = {0};
@@ -419,86 +419,86 @@ os_get_events(Arena *arena, B32 wait)
case KeyRelease:
{
// rjf: determine flags
OS_Modifiers modifiers = 0;
if(evt.xkey.state & ShiftMask) { modifiers |= OS_Modifier_Shift; }
if(evt.xkey.state & ControlMask) { modifiers |= OS_Modifier_Ctrl; }
if(evt.xkey.state & Mod1Mask) { modifiers |= OS_Modifier_Alt; }
WM_Modifiers modifiers = 0;
if(evt.xkey.state & ShiftMask) { modifiers |= WM_Modifier_Shift; }
if(evt.xkey.state & ControlMask) { modifiers |= WM_Modifier_Ctrl; }
if(evt.xkey.state & Mod1Mask) { modifiers |= WM_Modifier_Alt; }
// rjf: map keycode -> keysym & codepoint
OS_LNX_Window *window = os_lnx_window_from_x11window(evt.xkey.window);
LNX_WM_Window *window = os_lnx_window_from_x11window(evt.xkey.window);
KeySym keysym = 0;
U8 text[256] = {0};
U64 text_size = Xutf8LookupString(window->xic, &evt.xkey, (char *)text, sizeof(text), &keysym, 0);
// rjf: map keysym -> OS_Key
// rjf: map keysym -> WM_Key
B32 is_right_sided = 0;
OS_Key key = OS_Key_Null;
WM_Key key = WM_Key_Null;
switch(keysym)
{
default:
{
if(0){}
else if(XK_F1 <= keysym && keysym <= XK_F24) { key = (OS_Key)(OS_Key_F1 + (keysym - XK_F1)); }
else if('0' <= keysym && keysym <= '9') { key = OS_Key_0 + (keysym-'0'); }
else if(XK_F1 <= keysym && keysym <= XK_F24) { key = (WM_Key)(WM_Key_F1 + (keysym - XK_F1)); }
else if('0' <= keysym && keysym <= '9') { key = WM_Key_0 + (keysym-'0'); }
}break;
case XK_Escape:{key = OS_Key_Esc;};break;
case XK_BackSpace:{key = OS_Key_Backspace;}break;
case XK_Delete:{key = OS_Key_Delete;}break;
case XK_Return:{key = OS_Key_Return;}break;
case XK_Pause:{key = OS_Key_Pause;}break;
case XK_Tab:{key = OS_Key_Tab;}break;
case XK_Left:{key = OS_Key_Left;}break;
case XK_Right:{key = OS_Key_Right;}break;
case XK_Up:{key = OS_Key_Up;}break;
case XK_Down:{key = OS_Key_Down;}break;
case XK_Home:{key = OS_Key_Home;}break;
case XK_End:{key = OS_Key_End;}break;
case XK_Page_Up:{key = OS_Key_PageUp;}break;
case XK_Page_Down:{key = OS_Key_PageDown;}break;
case XK_Alt_L:{ key = OS_Key_Alt; }break;
case XK_Alt_R:{ key = OS_Key_Alt; is_right_sided = 1;}break;
case XK_Shift_L:{ key = OS_Key_Shift; }break;
case XK_Shift_R:{ key = OS_Key_Shift; is_right_sided = 1;}break;
case XK_Control_L:{ key = OS_Key_Ctrl; }break;
case XK_Control_R:{ key = OS_Key_Ctrl; is_right_sided = 1;}break;
case '-':{key = OS_Key_Minus;}break;
case '=':{key = OS_Key_Equal;}break;
case '[':{key = OS_Key_LeftBracket;}break;
case ']':{key = OS_Key_RightBracket;}break;
case ';':{key = OS_Key_Semicolon;}break;
case '\'':{key = OS_Key_Quote;}break;
case '.':{key = OS_Key_Period;}break;
case ',':{key = OS_Key_Comma;}break;
case '/':{key = OS_Key_Slash;}break;
case '\\':{key = OS_Key_BackSlash;}break;
case '\t':{key = OS_Key_Tab;}break;
case 'a':case 'A':{key = OS_Key_A;}break;
case 'b':case 'B':{key = OS_Key_B;}break;
case 'c':case 'C':{key = OS_Key_C;}break;
case 'd':case 'D':{key = OS_Key_D;}break;
case 'e':case 'E':{key = OS_Key_E;}break;
case 'f':case 'F':{key = OS_Key_F;}break;
case 'g':case 'G':{key = OS_Key_G;}break;
case 'h':case 'H':{key = OS_Key_H;}break;
case 'i':case 'I':{key = OS_Key_I;}break;
case 'j':case 'J':{key = OS_Key_J;}break;
case 'k':case 'K':{key = OS_Key_K;}break;
case 'l':case 'L':{key = OS_Key_L;}break;
case 'm':case 'M':{key = OS_Key_M;}break;
case 'n':case 'N':{key = OS_Key_N;}break;
case 'o':case 'O':{key = OS_Key_O;}break;
case 'p':case 'P':{key = OS_Key_P;}break;
case 'q':case 'Q':{key = OS_Key_Q;}break;
case 'r':case 'R':{key = OS_Key_R;}break;
case 's':case 'S':{key = OS_Key_S;}break;
case 't':case 'T':{key = OS_Key_T;}break;
case 'u':case 'U':{key = OS_Key_U;}break;
case 'v':case 'V':{key = OS_Key_V;}break;
case 'w':case 'W':{key = OS_Key_W;}break;
case 'x':case 'X':{key = OS_Key_X;}break;
case 'y':case 'Y':{key = OS_Key_Y;}break;
case 'z':case 'Z':{key = OS_Key_Z;}break;
case ' ':{key = OS_Key_Space;}break;
case XK_Escape:{key = WM_Key_Esc;};break;
case XK_BackSpace:{key = WM_Key_Backspace;}break;
case XK_Delete:{key = WM_Key_Delete;}break;
case XK_Return:{key = WM_Key_Return;}break;
case XK_Pause:{key = WM_Key_Pause;}break;
case XK_Tab:{key = WM_Key_Tab;}break;
case XK_Left:{key = WM_Key_Left;}break;
case XK_Right:{key = WM_Key_Right;}break;
case XK_Up:{key = WM_Key_Up;}break;
case XK_Down:{key = WM_Key_Down;}break;
case XK_Home:{key = WM_Key_Home;}break;
case XK_End:{key = WM_Key_End;}break;
case XK_Page_Up:{key = WM_Key_PageUp;}break;
case XK_Page_Down:{key = WM_Key_PageDown;}break;
case XK_Alt_L:{ key = WM_Key_Alt; }break;
case XK_Alt_R:{ key = WM_Key_Alt; is_right_sided = 1;}break;
case XK_Shift_L:{ key = WM_Key_Shift; }break;
case XK_Shift_R:{ key = WM_Key_Shift; is_right_sided = 1;}break;
case XK_Control_L:{ key = WM_Key_Ctrl; }break;
case XK_Control_R:{ key = WM_Key_Ctrl; is_right_sided = 1;}break;
case '-':{key = WM_Key_Minus;}break;
case '=':{key = WM_Key_Equal;}break;
case '[':{key = WM_Key_LeftBracket;}break;
case ']':{key = WM_Key_RightBracket;}break;
case ';':{key = WM_Key_Semicolon;}break;
case '\'':{key = WM_Key_Quote;}break;
case '.':{key = WM_Key_Period;}break;
case ',':{key = WM_Key_Comma;}break;
case '/':{key = WM_Key_Slash;}break;
case '\\':{key = WM_Key_BackSlash;}break;
case '\t':{key = WM_Key_Tab;}break;
case 'a':case 'A':{key = WM_Key_A;}break;
case 'b':case 'B':{key = WM_Key_B;}break;
case 'c':case 'C':{key = WM_Key_C;}break;
case 'd':case 'D':{key = WM_Key_D;}break;
case 'e':case 'E':{key = WM_Key_E;}break;
case 'f':case 'F':{key = WM_Key_F;}break;
case 'g':case 'G':{key = WM_Key_G;}break;
case 'h':case 'H':{key = WM_Key_H;}break;
case 'i':case 'I':{key = WM_Key_I;}break;
case 'j':case 'J':{key = WM_Key_J;}break;
case 'k':case 'K':{key = WM_Key_K;}break;
case 'l':case 'L':{key = WM_Key_L;}break;
case 'm':case 'M':{key = WM_Key_M;}break;
case 'n':case 'N':{key = WM_Key_N;}break;
case 'o':case 'O':{key = WM_Key_O;}break;
case 'p':case 'P':{key = WM_Key_P;}break;
case 'q':case 'Q':{key = WM_Key_Q;}break;
case 'r':case 'R':{key = WM_Key_R;}break;
case 's':case 'S':{key = WM_Key_S;}break;
case 't':case 'T':{key = WM_Key_T;}break;
case 'u':case 'U':{key = WM_Key_U;}break;
case 'v':case 'V':{key = WM_Key_V;}break;
case 'w':case 'W':{key = WM_Key_W;}break;
case 'x':case 'X':{key = WM_Key_X;}break;
case 'y':case 'Y':{key = WM_Key_Y;}break;
case 'z':case 'Z':{key = WM_Key_Z;}break;
case ' ':{key = WM_Key_Space;}break;
}
// rjf: push text event
@@ -509,7 +509,7 @@ os_get_events(Arena *arena, B32 wait)
UnicodeDecode decode = utf8_decode(text+off, text_size-off);
if(decode.codepoint != 0 && (decode.codepoint >= 32 || decode.codepoint == '\t'))
{
OS_Event *e = os_event_list_push_new(arena, &evts, OS_EventKind_Text);
WM_Event *e = wm_event_list_push_new(arena, &evts, WM_EventKind_Text);
e->window.u64[0] = (U64)window;
e->character = decode.codepoint;
}
@@ -523,7 +523,7 @@ os_get_events(Arena *arena, B32 wait)
// rjf: push key event
{
OS_Event *e = os_event_list_push_new(arena, &evts, evt.type == KeyPress ? OS_EventKind_Press : OS_EventKind_Release);
WM_Event *e = wm_event_list_push_new(arena, &evts, evt.type == KeyPress ? WM_EventKind_Press : WM_EventKind_Release);
e->window.u64[0] = (U64)window;
e->modifiers = modifiers;
e->key = key;
@@ -536,26 +536,26 @@ os_get_events(Arena *arena, B32 wait)
case ButtonRelease:
{
// rjf: determine flags
OS_Modifiers modifiers = 0;
if(evt.xbutton.state & ShiftMask) { modifiers |= OS_Modifier_Shift; }
if(evt.xbutton.state & ControlMask) { modifiers |= OS_Modifier_Ctrl; }
if(evt.xbutton.state & Mod1Mask) { modifiers |= OS_Modifier_Alt; }
WM_Modifiers modifiers = 0;
if(evt.xbutton.state & ShiftMask) { modifiers |= WM_Modifier_Shift; }
if(evt.xbutton.state & ControlMask) { modifiers |= WM_Modifier_Ctrl; }
if(evt.xbutton.state & Mod1Mask) { modifiers |= WM_Modifier_Alt; }
// rjf: map button -> OS_Key
OS_Key key = OS_Key_Null;
// rjf: map button -> WM_Key
WM_Key key = WM_Key_Null;
switch(evt.xbutton.button)
{
default:{}break;
case Button1:{key = OS_Key_LeftMouseButton;}break;
case Button2:{key = OS_Key_MiddleMouseButton;}break;
case Button3:{key = OS_Key_RightMouseButton;}break;
case Button1:{key = WM_Key_LeftMouseButton;}break;
case Button2:{key = WM_Key_MiddleMouseButton;}break;
case Button3:{key = WM_Key_RightMouseButton;}break;
}
// rjf: push event
OS_LNX_Window *window = os_lnx_window_from_x11window(evt.xbutton.window);
if(key != OS_Key_Null)
LNX_WM_Window *window = os_lnx_window_from_x11window(evt.xbutton.window);
if(key != WM_Key_Null)
{
OS_Event *e = os_event_list_push_new(arena, &evts, evt.type == ButtonPress ? OS_EventKind_Press : OS_EventKind_Release);
WM_Event *e = wm_event_list_push_new(arena, &evts, evt.type == ButtonPress ? WM_EventKind_Press : WM_EventKind_Release);
e->window.u64[0] = (U64)window;
e->modifiers = modifiers;
e->key = key;
@@ -564,7 +564,7 @@ os_get_events(Arena *arena, B32 wait)
else if(evt.xbutton.button == Button4 ||
evt.xbutton.button == Button5)
{
OS_Event *e = os_event_list_push_new(arena, &evts, OS_EventKind_Scroll);
WM_Event *e = wm_event_list_push_new(arena, &evts, WM_EventKind_Scroll);
e->window.u64[0] = (U64)window;
e->modifiers = modifiers;
e->delta = v2f32(0, evt.xbutton.button == Button4 ? -1.f : +1.f);
@@ -575,8 +575,8 @@ os_get_events(Arena *arena, B32 wait)
//- rjf: mouse motion
case MotionNotify:
{
OS_LNX_Window *window = os_lnx_window_from_x11window(evt.xclient.window);
OS_Event *e = os_event_list_push_new(arena, &evts, OS_EventKind_MouseMove);
LNX_WM_Window *window = os_lnx_window_from_x11window(evt.xclient.window);
WM_Event *e = wm_event_list_push_new(arena, &evts, WM_EventKind_MouseMove);
e->window.u64[0] = (U64)window;
e->pos.x = (F32)evt.xmotion.x;
e->pos.y = (F32)evt.xmotion.y;
@@ -589,8 +589,8 @@ os_get_events(Arena *arena, B32 wait)
}break;
case FocusOut:
{
OS_LNX_Window *window = os_lnx_window_from_x11window(evt.xfocus.window);
OS_Event *e = os_event_list_push_new(arena, &evts, OS_EventKind_WindowLoseFocus);
LNX_WM_Window *window = os_lnx_window_from_x11window(evt.xfocus.window);
WM_Event *e = wm_event_list_push_new(arena, &evts, WM_EventKind_WindowLoseFocus);
e->window.u64[0] = (U64)window;
}break;
@@ -599,13 +599,13 @@ os_get_events(Arena *arena, B32 wait)
{
if((Atom)evt.xclient.data.l[0] == os_lnx_gfx_state->wm_delete_window_atom)
{
OS_LNX_Window *window = os_lnx_window_from_x11window(evt.xclient.window);
OS_Event *e = os_event_list_push_new(arena, &evts, OS_EventKind_WindowClose);
LNX_WM_Window *window = os_lnx_window_from_x11window(evt.xclient.window);
WM_Event *e = wm_event_list_push_new(arena, &evts, WM_EventKind_WindowClose);
e->window.u64[0] = (U64)window;
}
else if((Atom)evt.xclient.data.l[0] == os_lnx_gfx_state->wm_sync_request_atom)
{
OS_LNX_Window *window = os_lnx_window_from_x11window(evt.xclient.window);
LNX_WM_Window *window = os_lnx_window_from_x11window(evt.xclient.window);
if(window != 0)
{
window->counter_value = 0;
@@ -637,25 +637,25 @@ os_get_events(Arena *arena, B32 wait)
return evts;
}
internal OS_Modifiers
os_get_modifiers(void)
internal WM_Modifiers
wm_get_modifiers(void)
{
// TODO(rjf)
return 0;
}
internal B32
os_key_is_down(OS_Key key)
wm_key_is_down(WM_Key key)
{
// TODO(rjf)
return 0;
}
internal Vec2F32
os_mouse_from_window(OS_Window handle)
wm_mouse_from_window(WM_Window handle)
{
if(os_window_match(handle, os_window_zero())) {return v2f32(0, 0);}
OS_LNX_Window *w = (OS_LNX_Window *)handle.u64[0];
if(wm_window_match(handle, wm_window_zero())) {return v2f32(0, 0);}
LNX_WM_Window *w = (LNX_WM_Window *)handle.u64[0];
Vec2F32 result = {0};
{
Window root_window = 0;
@@ -678,7 +678,7 @@ os_mouse_from_window(OS_Window handle)
//~ rjf: @os_hooks Cursors (Implemented Per-OS)
internal void
os_set_cursor(OS_Cursor cursor)
wm_set_cursor(WM_Cursor cursor)
{
os_lnx_gfx_state->last_set_cursor = cursor;
}
@@ -687,7 +687,7 @@ os_set_cursor(OS_Cursor cursor)
//~ rjf: @os_hooks Native User-Facing Graphical Messages (Implemented Per-OS)
internal void
os_graphical_message(B32 error, String8 title, String8 message)
wm_graphical_message(B32 error, String8 title, String8 message)
{
if(error)
{
@@ -698,7 +698,7 @@ os_graphical_message(B32 error, String8 title, String8 message)
}
internal String8
os_graphical_pick_file(Arena *arena, String8 initial_path)
wm_graphical_pick_file(Arena *arena, String8 initial_path)
{
return str8_zero();
}
@@ -707,13 +707,13 @@ os_graphical_pick_file(Arena *arena, String8 initial_path)
//~ rjf: @os_hooks Shell Operations
internal void
os_show_in_filesystem_ui(String8 path)
wm_show_in_filesystem_ui(String8 path)
{
// TODO(rjf)
}
internal void
os_open_in_browser(String8 url)
wm_open_in_browser(String8 url)
{
// TODO(rjf)
}