{
VALID_WINDOW_OR_NULL(split, return NULL);
g_return_val_if_fail(method == (method & (winmethod_DirMask | winmethod_DivisionMask)), NULL);
- g_return_val_if_fail(!(((method & winmethod_DivisionMask) == winmethod_Proportional) && size >= 100), NULL);
+ g_return_val_if_fail(!(((method & winmethod_DivisionMask) == winmethod_Proportional) && size > 100), NULL);
if(split == NULL && glk_data->root_window != NULL)
{
glk_data->root_window = win->window_node;
}
- /* Set the window as a child of the Glk widget */
+ /* Set the window as a child of the Glk widget, don't trigger an arrange event */
+ g_mutex_lock(glk_data->arrange_lock);
+ glk_data->ignore_next_arrange_event = TRUE;
+ 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));
}
/* Internal function: destroy this window's GTK widgets, window streams,
- and those of all its children */
+ and those of all its children. GDK threads must be locked. */
static void
destroy_windows_below(winid_t win, stream_result_t *result)
{
switch(win->type)
{
case wintype_Blank:
- gdk_threads_enter();
gtk_widget_unparent(win->widget);
- gdk_threads_leave();
break;
case wintype_TextGrid:
case wintype_TextBuffer:
- gdk_threads_enter();
gtk_widget_unparent(win->frame);
- gdk_threads_leave();
/* TODO: Cancel all input requests */
break;
{
VALID_WINDOW(win, return);
+ 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,
set their key window to NULL */
g_node_traverse(glk_data->root_window, G_IN_ORDER, G_TRAVERSE_NON_LEAVES, -1, (GNodeTraverseFunc)remove_key_windows, win);
g_free(win);
/* Schedule a redraw */
- gdk_threads_enter();
+ g_mutex_lock(glk_data->arrange_lock);
+ glk_data->ignore_next_arrange_event = TRUE;
+ g_mutex_unlock(glk_data->arrange_lock);
gtk_widget_queue_resize( GTK_WIDGET(glk_data->self) );
- gdk_window_process_all_updates();
gdk_threads_leave();
}
g_return_if_fail(g_node_is_ancestor(win->window_node, keywin->window_node));
}
g_return_if_fail(method == (method & (winmethod_DirMask | winmethod_DivisionMask)));
- g_return_if_fail(!(((method & winmethod_DivisionMask) == winmethod_Proportional) && size >= 100));
+ g_return_if_fail(!(((method & winmethod_DivisionMask) == winmethod_Proportional) && size > 100));
win->split_method = method;
win->constraint_size = size;
/* Tell GTK to rearrange the windows */
gdk_threads_enter();
+ g_mutex_lock(glk_data->arrange_lock);
+ glk_data->ignore_next_arrange_event = TRUE;
+ g_mutex_unlock(glk_data->arrange_lock);
gtk_widget_queue_resize(GTK_WIDGET(glk_data->self));
- gdk_window_process_all_updates();
gdk_threads_leave();
}
VALID_WINDOW(win, return);
g_return_if_fail(win->type == wintype_TextGrid);
+ /* Don't do anything if the window is shrunk down to nothing */
+ if(win->width == 0 || win->height == 0)
+ return;
+
/* Calculate actual position if cursor is moved past the right edge */
if(xpos >= win->width)
{