X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fwindow.c;h=85348f54502ce02de90a88b2406eb363b547cc5e;hb=6bf471dcb4c7d0c36b67bed84097a88b26629258;hp=ef85e3f2651f4de44bd99798c490b40d36f2926c;hpb=90090906ff9ca843e5dac0d26342f5bf85bab4f2;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/window.c b/libchimara/window.c index ef85e3f..85348f5 100644 --- a/libchimara/window.c +++ b/libchimara/window.c @@ -76,6 +76,8 @@ window_close_common(winid_t win, gboolean destroy_node) if(win->pager_layout) g_object_unref(win->pager_layout); + if(win->backing_store) + cairo_surface_destroy(win->backing_store); g_free(win); } @@ -565,8 +567,8 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype, /* Connect signal handlers */ /* Pager */ - g_signal_connect_after( textview, "size-request", G_CALLBACK(pager_after_size_request), win ); - win->pager_expose_handler = g_signal_connect_after( textview, "expose-event", G_CALLBACK(pager_on_expose), win ); + g_signal_connect_after( textview, "size-allocate", G_CALLBACK(pager_after_size_allocate), win ); + win->pager_expose_handler = g_signal_connect_after( textview, "draw", G_CALLBACK(pager_on_draw), win ); g_signal_handler_block(textview, win->pager_expose_handler); win->pager_keypress_handler = g_signal_connect( textview, "key-press-event", G_CALLBACK(pager_on_key_press_event), win ); g_signal_handler_block(textview, win->pager_keypress_handler); @@ -603,7 +605,7 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype, case wintype_Graphics: { - GtkWidget *image = gtk_image_new_from_pixmap(NULL, NULL); + GtkWidget *image = gtk_drawing_area_new(); gtk_widget_show(image); win->unit_width = 1; @@ -611,13 +613,15 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype, win->widget = image; win->frame = image; win->background_color = 0x00FFFFFF; - + win->backing_store = NULL; + /* Connect signal handlers */ win->button_press_event_handler = g_signal_connect(image, "button-press-event", G_CALLBACK(on_window_button_press), win); g_signal_handler_block(image, win->button_press_event_handler); win->shutdown_keypress_handler = g_signal_connect(image, "key-press-event", G_CALLBACK(on_shutdown_key_press_event), win); g_signal_handler_block(image, win->shutdown_keypress_handler); - win->size_allocate_handler = g_signal_connect(image, "size-allocate", G_CALLBACK(on_graphics_size_allocate), win); + g_signal_connect(image, "configure-event", G_CALLBACK(on_graphics_configure), win); + g_signal_connect(image, "draw", G_CALLBACK(on_graphics_draw), win); } break; @@ -1008,13 +1012,19 @@ glk_window_clear(winid_t win) case wintype_Graphics: { + GtkAllocation allocation; + /* Wait for the window's size to be updated */ g_mutex_lock(glk_data->arrange_lock); if(glk_data->needs_rearrange) g_cond_wait(glk_data->rearranged, glk_data->arrange_lock); g_mutex_unlock(glk_data->arrange_lock); - glk_window_erase_rect(win, 0, 0, win->widget->allocation.width, win->widget->allocation.height); + gdk_threads_enter(); + gtk_widget_get_allocation(win->widget, &allocation); + gdk_threads_leave(); + + glk_window_erase_rect(win, 0, 0, allocation.width, allocation.height); } break; @@ -1134,6 +1144,7 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr) { VALID_WINDOW(win, return); + GtkAllocation allocation; ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); switch(win->type) @@ -1154,9 +1165,10 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr) g_mutex_unlock(glk_data->arrange_lock); gdk_threads_enter(); + gtk_widget_get_allocation(win->widget, &allocation); /* Cache the width and height */ - win->width = (glui32)(win->widget->allocation.width / win->unit_width); - win->height = (glui32)(win->widget->allocation.height / win->unit_height); + win->width = (glui32)(allocation.width / win->unit_width); + win->height = (glui32)(allocation.height / win->unit_height); gdk_threads_leave(); if(widthptr != NULL) @@ -1173,10 +1185,11 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr) g_mutex_unlock(glk_data->arrange_lock); gdk_threads_enter(); + gtk_widget_get_allocation(win->widget, &allocation); if(widthptr != NULL) - *widthptr = (glui32)(win->widget->allocation.width / win->unit_width); + *widthptr = (glui32)(allocation.width / win->unit_width); if(heightptr != NULL) - *heightptr = (glui32)(win->widget->allocation.height / win->unit_height); + *heightptr = (glui32)(allocation.height / win->unit_height); gdk_threads_leave(); break; @@ -1188,10 +1201,11 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr) g_mutex_unlock(glk_data->arrange_lock); gdk_threads_enter(); + gtk_widget_get_allocation(win->widget, &allocation); if(widthptr != NULL) - *widthptr = (glui32)(win->widget->allocation.width); + *widthptr = (glui32)(allocation.width); if(heightptr != NULL) - *heightptr = (glui32)(win->widget->allocation.height); + *heightptr = (glui32)(allocation.height); gdk_threads_leave(); break;