can close windows independently
This commit is contained in:
1 parent
d2d9981efe
commit
f580776964
2 files changed
+46
-5
No files matched your search
@@ -38,11 +38,26 @@ internal void ja_frame()
|
|||||||
{
|
{
|
||||||
for (WM_Event *event = events.first, *next = 0; event != 0; event = next)
|
for (WM_Event *event = events.first, *next = 0; event != 0; event = next)
|
||||||
{
|
{
|
||||||
bool32 take = 0;
|
JA_WindowState* ws = ja_window_state_from_platform_handle(event->window);
|
||||||
|
bool32 take = 0;
|
||||||
if (event->kind == WM_EventKind_WindowClose)
|
if (event->kind == WM_EventKind_WindowClose)
|
||||||
{
|
{
|
||||||
ja_state->quit = 1;
|
if (ws != 0)
|
||||||
take = 1;
|
{
|
||||||
|
JA_WindowRequest* request = ja_window_request_from_id(ws->id);
|
||||||
|
AssertAlways(request != 0);
|
||||||
|
ja_window_close_request(request);
|
||||||
|
|
||||||
|
if (ja_state->window_request_count == 0)
|
||||||
|
{
|
||||||
|
ja_state->quit = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ja_state->quit = 1;
|
||||||
|
}
|
||||||
|
take = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (take)
|
if (take)
|
||||||
@@ -220,6 +235,23 @@ internal JA_WindowState* ja_window_state_from_id(JA_ID id)
|
|||||||
return ws;
|
return ws;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal JA_WindowState* ja_window_state_from_platform_handle(WM_Window platform_handle)
|
||||||
|
{
|
||||||
|
JA_WindowState* ws = &ja_nil_window_state;
|
||||||
|
{
|
||||||
|
for (JA_WindowState* w_candidate = ja_state->first_window_state; w_candidate != &ja_nil_window_state;
|
||||||
|
w_candidate = w_candidate->order_next)
|
||||||
|
{
|
||||||
|
if (wm_window_match(w_candidate->plat_handle, platform_handle))
|
||||||
|
{
|
||||||
|
ws = w_candidate;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ws;
|
||||||
|
}
|
||||||
|
|
||||||
internal void ja_window_request()
|
internal void ja_window_request()
|
||||||
{
|
{
|
||||||
JA_ID id = ja_state->window_request_gen_id++;
|
JA_ID id = ja_state->window_request_gen_id++;
|
||||||
@@ -234,12 +266,16 @@ internal void ja_window_request()
|
|||||||
}
|
}
|
||||||
result->id = id;
|
result->id = id;
|
||||||
DLL_push_back(ja_state->window_request_first, ja_state->window_request_last, result);
|
DLL_push_back(ja_state->window_request_first, ja_state->window_request_last, result);
|
||||||
|
ja_state->window_request_count += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void ja_window_close_request(JA_WindowRequest* request)
|
internal void ja_window_close_request(JA_WindowRequest* request)
|
||||||
{
|
{
|
||||||
DLL_remove(ja_state->window_request_first, ja_state->window_request_last, request);
|
DLL_remove(ja_state->window_request_first, ja_state->window_request_last, request);
|
||||||
SLL_stack_push(ja_state->free_window_request, request);
|
SLL_stack_push(ja_state->free_window_request, request);
|
||||||
|
|
||||||
|
ja_state->window_request_count -= 1;
|
||||||
|
AssertAlways(ja_state->window_request_count >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal JA_WindowRequest* ja_window_request_from_id(JA_ID id)
|
internal JA_WindowRequest* ja_window_request_from_id(JA_ID id)
|
||||||
@@ -248,8 +284,11 @@ internal JA_WindowRequest* ja_window_request_from_id(JA_ID id)
|
|||||||
for
|
for
|
||||||
EachNode(wr, JA_WindowRequest, ja_state->window_request_first)
|
EachNode(wr, JA_WindowRequest, ja_state->window_request_first)
|
||||||
{
|
{
|
||||||
result = wr;
|
if (wr->id == id)
|
||||||
break;
|
{
|
||||||
|
result = wr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -66,6 +66,7 @@ struct JA_State
|
|||||||
JA_WindowRequest* window_request_first;
|
JA_WindowRequest* window_request_first;
|
||||||
JA_WindowRequest* window_request_last;
|
JA_WindowRequest* window_request_last;
|
||||||
JA_WindowRequest* free_window_request;
|
JA_WindowRequest* free_window_request;
|
||||||
|
uint64 window_request_count;
|
||||||
|
|
||||||
// Windows
|
// Windows
|
||||||
JA_WindowState* free_window_state;
|
JA_WindowState* free_window_state;
|
||||||
@@ -100,6 +101,7 @@ internal void ja_id_list_push(Arena* arena, JA_IDList* list, JA_ID id);
|
|||||||
// Window Functions
|
// Window Functions
|
||||||
|
|
||||||
internal JA_WindowState* ja_window_state_from_id(JA_ID id);
|
internal JA_WindowState* ja_window_state_from_id(JA_ID id);
|
||||||
|
internal JA_WindowState* ja_window_state_from_platform_handle(WM_Window platform_handle);
|
||||||
internal void ja_window_request();
|
internal void ja_window_request();
|
||||||
internal void ja_window_close_request(JA_WindowRequest* request);
|
internal void ja_window_close_request(JA_WindowRequest* request);
|
||||||
internal JA_WindowRequest* ja_window_request_from_id(JA_ID id);
|
internal JA_WindowRequest* ja_window_request_from_id(JA_ID id);
|
||||||
Reference in new issue
Block a user