fill out more linux os layer coverage

This commit is contained in:
Ryan Fleury
2025-05-10 11:38:43 -07:00
parent b9350c867c
commit b52e3be5ae
3 changed files with 68 additions and 11 deletions
+65 -9
View File
@@ -134,13 +134,19 @@ internal void
os_window_close(OS_Handle handle)
{
if(os_handle_match(handle, os_handle_zero())) {return;}
OS_LNX_Window *w = (OS_LNX_Window *)handle.u64[0];
XDestroyWindow(os_lnx_gfx_state->display, w->window);
}
internal void
os_window_set_title(OS_Handle handle, String8 title)
{
if(os_handle_match(handle, os_handle_zero())) {return;}
// TODO(rjf)
Temp scratch = scratch_begin(0, 0);
OS_LNX_Window *w = (OS_LNX_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
@@ -155,12 +161,15 @@ internal void
os_window_focus(OS_Handle handle)
{
if(os_handle_match(handle, os_handle_zero())) {return;}
OS_LNX_Window *w = (OS_LNX_Window *)handle.u64[0];
XSetInputFocus(os_lnx_gfx_state->display, w->window, RevertToNone, CurrentTime);
}
internal B32
os_window_is_focused(OS_Handle handle)
{
if(os_handle_match(handle, os_handle_zero())) {return 0;}
// TODO(rjf)
return 0;
}
@@ -168,6 +177,7 @@ internal B32
os_window_is_fullscreen(OS_Handle handle)
{
if(os_handle_match(handle, os_handle_zero())) {return 0;}
// TODO(rjf)
return 0;
}
@@ -175,12 +185,14 @@ internal void
os_window_set_fullscreen(OS_Handle handle, B32 fullscreen)
{
if(os_handle_match(handle, os_handle_zero())) {return;}
// TODO(rjf)
}
internal B32
os_window_is_maximized(OS_Handle handle)
{
if(os_handle_match(handle, os_handle_zero())) {return 0;}
// TODO(rjf)
return 0;
}
@@ -188,12 +200,14 @@ internal void
os_window_set_maximized(OS_Handle handle, B32 maximized)
{
if(os_handle_match(handle, os_handle_zero())) {return;}
// TODO(rjf)
}
internal B32
os_window_is_minimized(OS_Handle handle)
{
if(os_handle_match(handle, os_handle_zero())) {return 0;}
// TODO(rjf)
return 0;
}
@@ -201,60 +215,77 @@ internal void
os_window_set_minimized(OS_Handle handle, B32 minimized)
{
if(os_handle_match(handle, os_handle_zero())) {return;}
// TODO(rjf)
}
internal void
os_window_bring_to_front(OS_Handle handle)
{
if(os_handle_match(handle, os_handle_zero())) {return;}
// TODO(rjf)
}
internal void
os_window_set_monitor(OS_Handle handle, OS_Handle monitor)
{
if(os_handle_match(handle, os_handle_zero())) {return;}
// TODO(rjf)
}
internal void
os_window_clear_custom_border_data(OS_Handle handle)
{
if(os_handle_match(handle, os_handle_zero())) {return;}
// TODO(rjf)
}
internal void
os_window_push_custom_title_bar(OS_Handle handle, F32 thickness)
{
if(os_handle_match(handle, os_handle_zero())) {return;}
// TODO(rjf)
}
internal void
os_window_push_custom_edges(OS_Handle handle, F32 thickness)
{
if(os_handle_match(handle, os_handle_zero())) {return;}
// TODO(rjf)
}
internal void
os_window_push_custom_title_bar_client_area(OS_Handle handle, Rng2F32 rect)
{
if(os_handle_match(handle, os_handle_zero())) {return;}
// TODO(rjf)
}
internal Rng2F32
os_rect_from_window(OS_Handle handle)
{
return r2f32p(0, 0, 0, 0);
if(os_handle_match(handle, os_handle_zero())) {return r2f32p(0, 0, 0, 0);}
OS_LNX_Window *w = (OS_LNX_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);
return result;
}
internal Rng2F32
os_client_rect_from_window(OS_Handle handle)
{
return r2f32p(0, 0, 0, 0);
OS_LNX_Window *w = (OS_LNX_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);
return result;
}
internal F32
os_dpi_from_window(OS_Handle handle)
{
return 0;
// TODO(rjf)
return 96.f;
}
////////////////////////////////
@@ -264,6 +295,7 @@ internal OS_HandleArray
os_push_monitors_array(Arena *arena)
{
OS_HandleArray result = {0};
// TODO(rjf)
return result;
}
@@ -271,6 +303,7 @@ internal OS_Handle
os_primary_monitor(void)
{
OS_Handle result = {0};
// TODO(rjf)
return result;
}
@@ -278,24 +311,28 @@ internal OS_Handle
os_monitor_from_window(OS_Handle window)
{
OS_Handle result = {0};
// TODO(rjf)
return result;
}
internal String8
os_name_from_monitor(Arena *arena, OS_Handle monitor)
{
// TODO(rjf)
return str8_zero();
}
internal Vec2F32
os_dim_from_monitor(OS_Handle monitor)
{
// TODO(rjf)
return v2f32(0, 0);
}
internal F32
os_dpi_from_monitor(OS_Handle monitor)
{
// TODO(rjf)
return 96.f;
}
@@ -305,7 +342,7 @@ os_dpi_from_monitor(OS_Handle monitor)
internal void
os_send_wakeup_event(void)
{
// TODO(rjf)
}
internal OS_EventList
@@ -467,19 +504,38 @@ os_get_events(Arena *arena, B32 wait)
internal OS_Modifiers
os_get_modifiers(void)
{
// TODO(rjf)
return 0;
}
internal B32
os_key_is_down(OS_Key key)
{
// TODO(rjf)
return 0;
}
internal Vec2F32
os_mouse_from_window(OS_Handle handle)
{
return v2f32(0, 0);
if(os_handle_match(handle, os_handle_zero())) {return v2f32(0, 0);}
OS_LNX_Window *w = (OS_LNX_Window *)handle.u64[0];
Vec2F32 result = {0};
{
Window root_window = 0;
Window child_window = 0;
int root_rel_x = 0;
int root_rel_y = 0;
int child_rel_x = 0;
int child_rel_y = 0;
unsigned int mask = 0;
if(XQueryPointer(os_lnx_gfx_state->display, w->window, &root_window, &child_window, &root_rel_x, &root_rel_y, &child_rel_x, &child_rel_y, &mask))
{
result.x = child_rel_x;
result.y = child_rel_y;
}
}
return result;
}
////////////////////////////////
@@ -488,7 +544,7 @@ os_mouse_from_window(OS_Handle handle)
internal void
os_set_cursor(OS_Cursor cursor)
{
// TODO(rjf)
}
////////////////////////////////
@@ -511,11 +567,11 @@ os_graphical_message(B32 error, String8 title, String8 message)
internal void
os_show_in_filesystem_ui(String8 path)
{
// TODO(rjf)
}
internal void
os_open_in_browser(String8 url)
{
// TODO(rjf)
}
@@ -14,7 +14,7 @@
//~ rjf: Decide On Backend
#if !defined(R_OPENGL_LINUX_BACKEND)
# define R_OPENGL_LINUX_BACKEND R_OPENGL_LINUX_BACKEND_GLX
# define R_OPENGL_LINUX_BACKEND R_OPENGL_LINUX_BACKEND_EGL
#endif
////////////////////////////////
+2 -1
View File
@@ -73,9 +73,10 @@ frame(void)
group.batches = r_batch_list_make(sizeof(R_Rect2DInst));
group.params.xform = mat_3x3f32(1.f);
group.params.clip = os_client_rect_from_window(window_os);
Vec2F32 mouse = os_mouse_from_window(window_os);
R_Rect2DInst *inst = r_batch_list_push_inst(scratch.arena, &group.batches, 256);
MemoryZeroStruct(inst);
inst->dst = r2f32p(30, 30, 100 ,100);
inst->dst = r2f32p(mouse.x+30, mouse.y+30, mouse.x+100, mouse.y+100);
inst->src = r2f32p(0, 0, 1, 1);
inst->colors[Corner_00] = inst->colors[Corner_01] = inst->colors[Corner_10] = inst->colors[Corner_11] = v4f32(1, 0, 0, 1);
inst->corner_radii[Corner_00] = inst->corner_radii[Corner_01] = inst->corner_radii[Corner_10] = inst->corner_radii[Corner_11] = 8.f;