Skip to content

Commit 1efae09

Browse files
authored
Updating code to follow current coding style
1 parent b00ecf0 commit 1efae09

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

src/webui.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
Canada.
99
*/
1010

11-
#define webui_log_debug printf
12-
1311
// 64Mb max dynamic memory allocation
1412
#define WEBUI_MAX_BUF (64000000)
1513

@@ -375,7 +373,7 @@ typedef struct _webui_window_t {
375373
int x;
376374
int y;
377375
bool position_set;
378-
bool (*close_handler)(size_t window);
376+
bool (*close_handler_wv)(size_t window);
379377
const void*(*files_handler)(const char* filename, int* length);
380378
const void*(*files_handler_window)(size_t window, const char* filename, int* length);
381379
const void* file_handler_async_response;
@@ -779,7 +777,7 @@ void webui_run(size_t window, const char* script) {
779777
_webui_send_all(win, 0, WEBUI_CMD_JS_QUICK, script, js_len);
780778
}
781779

782-
void webui_set_close_handler(size_t window, bool(*close_handler)(size_t window)) {
780+
void webui_set_close_handler_wv(size_t window, bool(*close_handler)(size_t window)) {
783781

784782
// Initialization
785783
_webui_init();
@@ -790,12 +788,12 @@ void webui_set_close_handler(size_t window, bool(*close_handler)(size_t window))
790788

791789
_webui_window_t* win = _webui.wins[window];
792790

793-
#ifdef WEBUI_LOG
794-
webui_log_debug("[User]webui_set_close_handler(%zu, %p)", window, close_handler);
795-
#endif
791+
#ifdef WEBUI_LOG
792+
printf("[User]webui_set_close_handler(%zu, %p)", window, close_handler);
793+
#endif
796794

797795
// Set the close handler
798-
win->close_handler = close_handler;
796+
win->close_handler_wv = close_handler;
799797
}
800798

801799
void webui_set_file_handler(size_t window, const void*(*handler)(const char* filename, int* length)) {
@@ -11555,13 +11553,12 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1155511553
case WM_CLOSE: {
1155611554
if (win) {
1155711555
bool can_close = true;
11558-
if (win->close_handler != NULL) {
11559-
can_close = win->close_handler(win->num);
11556+
if (win->close_handler_wv != NULL) {
11557+
can_close = win->close_handler_wv(win->num);
1156011558
#ifdef WEBUI_LOG
11561-
webui_log_debug("[Core]\t\tClose Handler installed for %zu, result = %d\n", win->num, can_close);
11559+
webui_log_debug("[Core]\t\tClose handler installed for %zu, result = %d\n", win->num, can_close);
1156211560
#endif
1156311561
}
11564-
1156511562
if (can_close) {
1156611563
// Stop the WebView thread, close the window
1156711564
// and free resources.
@@ -12011,13 +12008,15 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved) {
1201112008
// Delete Event (implement on close handling)
1201212009
static bool _webui_wv_event_on_close(void *widget, void *evt, void *arg) {
1201312010
#ifdef WEBUI_LOG
12014-
webui_log_debug("[Core]\t\t_webui_wv_event_on_close()\n");
12011+
printf("[Core]\t\t_webui_wv_event_on_close()\n");
1201512012
#endif
1201612013
_webui_window_t* win = _webui_dereference_win_ptr(arg);
1201712014
if (win) {
12018-
if (win->close_handler) {
12019-
bool can_close = win->close_handler(win->num);
12020-
webui_log_debug("can_close = %d", can_close);
12015+
if (win->close_handler_wv) {
12016+
bool can_close = win->close_handler_wv(win->num);
12017+
#ifdef WEBUI_LOG
12018+
printf("[Core]\t\t_webui_wv_event_on_close() -> can_close = %d\n", can_close);
12019+
#endif
1202112020
return !can_close;
1202212021
}
1202312022
}

0 commit comments

Comments
 (0)