diff --git a/demos/clipboard.c b/demos/clipboard.c index a657d94..7e68805 100644 --- a/demos/clipboard.c +++ b/demos/clipboard.c @@ -110,6 +110,7 @@ static void create_window(void *user_data) { &focus_leave }; window->window = gral_window_create(application->application, 800, 600, "gral clipboard demo", &window_interface, window); + gral_window_show(window->window); } static void start(void *user_data) { diff --git a/demos/cursors.c b/demos/cursors.c index d41407e..f9581fc 100644 --- a/demos/cursors.c +++ b/demos/cursors.c @@ -137,6 +137,7 @@ static void create_window(void *user_data) { }; window->window = gral_window_create(application->application, 400, 400, "gral cursors demo", &window_interface, window); window->cursor = GRAL_CURSOR_DEFAULT; + gral_window_show(window->window); } static void start(void *user_data) { diff --git a/demos/draw.c b/demos/draw.c index a31cb70..bacaa29 100644 --- a/demos/draw.c +++ b/demos/draw.c @@ -179,6 +179,7 @@ static void create_window(void *user_data) { }; window->window = gral_window_create(application->application, 600, 400, "gral draw demo", &window_interface, window); gral_window_set_minimum_size(window->window, 600, 400); + gral_window_show(window->window); } static void start(void *user_data) { diff --git a/demos/events.c b/demos/events.c index 1292550..0cb2d56 100644 --- a/demos/events.c +++ b/demos/events.c @@ -154,6 +154,7 @@ static void create_window(void *user_data) { }; window->window = gral_window_create(application->application, 600, 400, "gral events demo", &window_interface, window); window->application = application; + gral_window_show(window->window); } static void start(void *user_data) { diff --git a/demos/file_dialogs.c b/demos/file_dialogs.c index ff80269..bbd07e3 100644 --- a/demos/file_dialogs.c +++ b/demos/file_dialogs.c @@ -122,6 +122,7 @@ static void create_window(void *user_data) { &focus_leave }; window->window = gral_window_create(application->application, 600, 400, "gral file dialog demo", &window_interface, window); + gral_window_show(window->window); } static void start(void *user_data) { diff --git a/demos/text.c b/demos/text.c index 82124a8..afd6bee 100644 --- a/demos/text.c +++ b/demos/text.c @@ -134,6 +134,7 @@ static void create_window(void *user_data) { window->cursor_x = 0.0f; gral_font_get_metrics(window->window, font, &window->ascent, &window->descent); gral_font_delete(font); + gral_window_show(window->window); } static void start(void *user_data) { diff --git a/gral.h b/gral.h index a33c73c..3648442 100644 --- a/gral.h +++ b/gral.h @@ -155,6 +155,7 @@ void gral_draw_context_draw_transformed(struct gral_draw_context *draw_context, ===========*/ struct gral_window *gral_window_create(struct gral_application *application, int width, int height, char const *title, struct gral_window_interface const *interface, void *user_data); +void gral_window_show(struct gral_window *window); void gral_window_set_title(struct gral_window *window, char const *title); void gral_window_request_redraw(struct gral_window *window, int x, int y, int width, int height); void gral_window_set_minimum_size(struct gral_window *window, int minimum_width, int minimum_height); diff --git a/gral_linux.c b/gral_linux.c index c8f8b1d..e0cc670 100644 --- a/gral_linux.c +++ b/gral_linux.c @@ -512,10 +512,13 @@ struct gral_window *gral_window_create(struct gral_application *application, int gtk_window_set_title(GTK_WINDOW(window), title); GtkWidget *area = g_object_new(GRAL_TYPE_AREA, NULL); gtk_container_add(GTK_CONTAINER(window), area); - gtk_widget_show_all(GTK_WIDGET(window)); return (struct gral_window *)window; } +void gral_window_show(struct gral_window *window) { + gtk_widget_show_all(GTK_WIDGET(window)); +} + void gral_window_set_title(struct gral_window *window, char const *title) { gtk_window_set_title(GTK_WINDOW(window), title); } diff --git a/gral_macos.m b/gral_macos.m index d7b1be4..e074099 100644 --- a/gral_macos.m +++ b/gral_macos.m @@ -569,12 +569,17 @@ - (void)doCommandBySelector:(SEL)selector { window->user_data = user_data; [window setDelegate:window]; [window setTitle:[NSString stringWithUTF8String:title]]; + return (struct gral_window *)window; +} + +void gral_window_show(struct gral_window *window_) { + GralWindow *window = (GralWindow *)window_; GralView *view = [[GralView alloc] init]; - view->interface = interface; - view->user_data = user_data; + view->interface = window->interface; + view->user_data = window->user_data; view->is_pointer_locked = NO; NSTrackingArea *trackingArea = [[NSTrackingArea alloc] - initWithRect:CGRectMake(0, 0, width, height) + initWithRect:NSZeroRect options:NSTrackingMouseEnteredAndExited|NSTrackingMouseMoved|NSTrackingActiveAlways|NSTrackingInVisibleRect owner:view userInfo:nil @@ -584,7 +589,6 @@ - (void)doCommandBySelector:(SEL)selector { [window setContentView:view]; [view release]; [window makeKeyAndOrderFront:nil]; - return (struct gral_window *)window; } void gral_window_set_title(struct gral_window *window, char const *title) { diff --git a/gral_windows.cpp b/gral_windows.cpp index cd24171..1212abc 100644 --- a/gral_windows.cpp +++ b/gral_windows.cpp @@ -926,11 +926,14 @@ gral_window *gral_window_create(gral_application *application, int width, int he window_data->target = NULL; window_data->cursor = LoadCursor(NULL, IDC_ARROW); SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)window_data); - ShowWindow(hwnd, SW_SHOW); window_count++; return (gral_window *)hwnd; } +void gral_window_show(gral_window *window) { + ShowWindow((HWND)window, SW_SHOW); +} + void gral_window_set_title(gral_window *window, char const *title) { SetWindowText((HWND)window, utf8_to_utf16(title)); }