X-Git-Url: https://git.stderr.nl/gitweb?p=projects%2Fchimara%2Fchimara.git;a=blobdiff_plain;f=libchimara%2Fwindow.c;h=a4366b4b8ca4c6f11c15da94c38c504f42b53386;hp=c9132939237d5548f9632ff85a903f0e70148088;hb=1e0dc5378f314f555e3b923c6d95f5017abd528b;hpb=3c59ba5eef5cb4d39c06eb7f523b9c3b026bdc9b diff --git a/libchimara/window.c b/libchimara/window.c index c913293..a4366b4 100644 --- a/libchimara/window.c +++ b/libchimara/window.c @@ -5,12 +5,12 @@ #include "gi_dispa.h" #include "pager.h" -extern GPrivate *glk_data_key; +extern GPrivate glk_data_key; static winid_t window_new_common(glui32 rock) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); winid_t win = g_new0(struct glk_window_struct, 1); win->magic = MAGIC_WINDOW; @@ -52,7 +52,7 @@ window_new_common(glui32 rock) static void window_close_common(winid_t win, gboolean destroy_node) { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); if(glk_data->unregister_obj) { @@ -100,8 +100,8 @@ winid_t glk_window_iterate(winid_t win, glui32 *rockptr) { VALID_WINDOW_OR_NULL(win, return NULL); - - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); GNode *retnode; if(win == NULL) @@ -216,7 +216,7 @@ glk_window_get_sibling(winid_t win) winid_t glk_window_get_root() { - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); if(glk_data->root_window == NULL) return NULL; return (winid_t)glk_data->root_window->data; @@ -466,8 +466,8 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype, if(method != (method & (winmethod_DirMask | winmethod_DivisionMask | winmethod_BorderMask))) WARNING("Unrecognized bits in method constant"); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + if(split == NULL && glk_data->root_window != NULL) { ILLEGAL("Tried to open a new root window, but there is already a root window"); @@ -691,10 +691,10 @@ glk_window_open(winid_t split, glui32 method, glui32 size, glui32 wintype, } /* Set the window as a child of the Glk widget, don't trigger an arrange event */ - g_mutex_lock(glk_data->arrange_lock); + g_mutex_lock(&glk_data->arrange_lock); glk_data->needs_rearrange = TRUE; glk_data->ignore_next_arrange_event = TRUE; - g_mutex_unlock(glk_data->arrange_lock); + g_mutex_unlock(&glk_data->arrange_lock); gtk_widget_set_parent(win->frame, GTK_WIDGET(glk_data->self)); gtk_widget_queue_resize(GTK_WIDGET(glk_data->self)); @@ -828,8 +828,8 @@ glk_window_close(winid_t win, stream_result_t *result) { VALID_WINDOW(win, return); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + gdk_threads_enter(); /* Prevent redraw while we're trashing the window */ /* If any pair windows have this window or its children as a key window, @@ -888,10 +888,10 @@ glk_window_close(winid_t win, stream_result_t *result) window_close_common(win, FALSE); /* Schedule a redraw */ - g_mutex_lock(glk_data->arrange_lock); + g_mutex_lock(&glk_data->arrange_lock); glk_data->needs_rearrange = TRUE; glk_data->ignore_next_arrange_event = TRUE; - g_mutex_unlock(glk_data->arrange_lock); + g_mutex_unlock(&glk_data->arrange_lock); gtk_widget_queue_resize( GTK_WIDGET(glk_data->self) ); gdk_threads_leave(); } @@ -941,8 +941,8 @@ glk_window_clear(winid_t win) VALID_WINDOW(win, return); g_return_if_fail(win->input_request_type != INPUT_REQUEST_LINE && win->input_request_type != INPUT_REQUEST_LINE_UNICODE); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + switch(win->type) { case wintype_Blank: @@ -954,11 +954,11 @@ glk_window_clear(winid_t win) /* fill the buffer with blanks */ { /* Wait for the window's size to be updated */ - g_mutex_lock(glk_data->arrange_lock); + 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); - + g_cond_wait(&glk_data->rearranged, &glk_data->arrange_lock); + g_mutex_unlock(&glk_data->arrange_lock); + gdk_threads_enter(); /* Manually put newlines at the end of each row of characters in the buffer; manual newlines make resizing the window's grid easier. */ @@ -1006,10 +1006,10 @@ glk_window_clear(winid_t win) GtkAllocation allocation; /* Wait for the window's size to be updated */ - g_mutex_lock(glk_data->arrange_lock); + 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); + g_cond_wait(&glk_data->rearranged, &glk_data->arrange_lock); + g_mutex_unlock(&glk_data->arrange_lock); gdk_threads_enter(); gtk_widget_get_allocation(win->widget, &allocation); @@ -1136,8 +1136,8 @@ 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); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + switch(win->type) { case wintype_Blank: @@ -1150,11 +1150,11 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr) case wintype_TextGrid: /* Wait until the window's size is current */ - g_mutex_lock(glk_data->arrange_lock); + 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); - + g_cond_wait(&glk_data->rearranged, &glk_data->arrange_lock); + g_mutex_unlock(&glk_data->arrange_lock); + gdk_threads_enter(); gtk_widget_get_allocation(win->widget, &allocation); /* Cache the width and height */ @@ -1169,12 +1169,12 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr) break; case wintype_TextBuffer: - /* Wait until the window's size is current */ - g_mutex_lock(glk_data->arrange_lock); + /* Wait until the window's size is current */ + 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); - + g_cond_wait(&glk_data->rearranged, &glk_data->arrange_lock); + g_mutex_unlock(&glk_data->arrange_lock); + gdk_threads_enter(); gtk_widget_get_allocation(win->widget, &allocation); if(widthptr != NULL) @@ -1186,11 +1186,11 @@ glk_window_get_size(winid_t win, glui32 *widthptr, glui32 *heightptr) break; case wintype_Graphics: - g_mutex_lock(glk_data->arrange_lock); + 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); - + g_cond_wait(&glk_data->rearranged, &glk_data->arrange_lock); + g_mutex_unlock(&glk_data->arrange_lock); + gdk_threads_enter(); gtk_widget_get_allocation(win->widget, &allocation); if(widthptr != NULL) @@ -1284,8 +1284,8 @@ glk_window_set_arrangement(winid_t win, glui32 method, glui32 size, winid_t keyw g_return_if_fail(method == (method & (winmethod_DirMask | winmethod_DivisionMask))); g_return_if_fail(!(((method & winmethod_DivisionMask) == winmethod_Proportional) && size > 100)); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + win->split_method = method; win->constraint_size = size; if(keywin) @@ -1293,10 +1293,10 @@ glk_window_set_arrangement(winid_t win, glui32 method, glui32 size, winid_t keyw /* Tell GTK to rearrange the windows */ gdk_threads_enter(); - g_mutex_lock(glk_data->arrange_lock); + g_mutex_lock(&glk_data->arrange_lock); glk_data->needs_rearrange = TRUE; glk_data->ignore_next_arrange_event = TRUE; - g_mutex_unlock(glk_data->arrange_lock); + g_mutex_unlock(&glk_data->arrange_lock); gtk_widget_queue_resize(GTK_WIDGET(glk_data->self)); gdk_threads_leave(); } @@ -1362,13 +1362,13 @@ glk_window_move_cursor(winid_t win, glui32 xpos, glui32 ypos) flush_window_buffer(win); - ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key); - + ChimaraGlkPrivate *glk_data = g_private_get(&glk_data_key); + /* Wait until the window's size is current */ - g_mutex_lock(glk_data->arrange_lock); + 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); + g_cond_wait(&glk_data->rearranged, &glk_data->arrange_lock); + g_mutex_unlock(&glk_data->arrange_lock); /* Don't do anything if the window is shrunk down to nothing */ if(win->width == 0 || win->height == 0)