Themes and threads testing code.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5307 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
8
misc/theme_test/Makefile
Normal file
8
misc/theme_test/Makefile
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
CC = gcc
|
||||||
|
|
||||||
|
test: test.c
|
||||||
|
$(CC) `gtk-config --cflags` test.c -o test `gtk-config --libs`
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o test
|
207
misc/theme_test/test.c
Normal file
207
misc/theme_test/test.c
Normal file
@@ -0,0 +1,207 @@
|
|||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
/* This function rotates the position of the tabs */
|
||||||
|
void rotate_book (GtkButton *button, GtkNotebook *notebook)
|
||||||
|
{
|
||||||
|
gtk_notebook_set_tab_pos (notebook, (notebook->tab_pos +1) %4);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add/Remove the page tabs and the borders */
|
||||||
|
void tabsborder_book (GtkButton *button, GtkNotebook *notebook)
|
||||||
|
{
|
||||||
|
gint tval = FALSE;
|
||||||
|
gint bval = FALSE;
|
||||||
|
if (notebook->show_tabs == 0)
|
||||||
|
tval = TRUE;
|
||||||
|
if (notebook->show_border == 0)
|
||||||
|
bval = TRUE;
|
||||||
|
|
||||||
|
gtk_notebook_set_show_tabs (notebook, tval);
|
||||||
|
gtk_notebook_set_show_border (notebook, bval);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Remove a page from the notebook */
|
||||||
|
void remove_book (GtkButton *button, GtkNotebook *notebook)
|
||||||
|
{
|
||||||
|
gint page;
|
||||||
|
|
||||||
|
page = gtk_notebook_get_current_page(notebook);
|
||||||
|
gtk_notebook_remove_page (notebook, page);
|
||||||
|
/* Need to refresh the widget --
|
||||||
|
This forces the widget to redraw itself. */
|
||||||
|
gtk_widget_draw(GTK_WIDGET(notebook), NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void delete (GtkWidget *widget, GtkWidget *event, gpointer data)
|
||||||
|
{
|
||||||
|
gtk_main_quit ();
|
||||||
|
}
|
||||||
|
|
||||||
|
void assign_new_style(GtkWidget *widget)
|
||||||
|
{
|
||||||
|
GtkStyle *default_style,*new_style;
|
||||||
|
|
||||||
|
default_style = gtk_rc_get_style( widget );
|
||||||
|
|
||||||
|
if (!default_style)
|
||||||
|
default_style = gtk_widget_get_default_style();
|
||||||
|
|
||||||
|
new_style = gtk_style_copy( default_style );
|
||||||
|
new_style->engine_data = default_style->engine_data;
|
||||||
|
new_style->klass = default_style->klass;
|
||||||
|
|
||||||
|
gtk_widget_set_style( widget, new_style );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
GtkWidget *window;
|
||||||
|
GtkWidget *button;
|
||||||
|
GtkWidget *table;
|
||||||
|
GtkWidget *notebook;
|
||||||
|
GtkWidget *frame;
|
||||||
|
GtkWidget *label;
|
||||||
|
|
||||||
|
gtk_init (&argc, &argv);
|
||||||
|
|
||||||
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||||
|
|
||||||
|
gtk_signal_connect (GTK_OBJECT (window), "delete_event",
|
||||||
|
GTK_SIGNAL_FUNC (delete), NULL);
|
||||||
|
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
|
||||||
|
|
||||||
|
table = gtk_table_new(3,6,FALSE);
|
||||||
|
gtk_container_add (GTK_CONTAINER (window), table);
|
||||||
|
|
||||||
|
/* Create a new notebook, place the position of the tabs */
|
||||||
|
notebook = gtk_notebook_new ();
|
||||||
|
assign_new_style( notebook );
|
||||||
|
|
||||||
|
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_TOP);
|
||||||
|
gtk_table_attach_defaults(GTK_TABLE(table), notebook, 0,6,0,1);
|
||||||
|
gtk_widget_show(notebook);
|
||||||
|
|
||||||
|
/* Now finally lets prepend pages to the notebook */
|
||||||
|
|
||||||
|
frame = gtk_frame_new ("frame");
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
|
||||||
|
gtk_widget_set_usize (frame, 100, 75);
|
||||||
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
|
label = gtk_label_new ("label");
|
||||||
|
assign_new_style( label );
|
||||||
|
gtk_container_add (GTK_CONTAINER (frame), label);
|
||||||
|
gtk_widget_show (label);
|
||||||
|
|
||||||
|
label = gtk_label_new ("page");
|
||||||
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
|
||||||
|
|
||||||
|
|
||||||
|
frame = gtk_frame_new ("frame");
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
|
||||||
|
gtk_widget_set_usize (frame, 100, 75);
|
||||||
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
|
label = gtk_button_new_with_label ("button");
|
||||||
|
assign_new_style( label );
|
||||||
|
gtk_container_add (GTK_CONTAINER (frame), label);
|
||||||
|
gtk_widget_show (label);
|
||||||
|
|
||||||
|
label = gtk_label_new ("page");
|
||||||
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
frame = gtk_frame_new ("frame");
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
|
||||||
|
gtk_widget_set_usize (frame, 100, 75);
|
||||||
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
|
label = gtk_check_button_new_with_label ("check button");
|
||||||
|
assign_new_style( label );
|
||||||
|
gtk_container_add (GTK_CONTAINER (frame), label);
|
||||||
|
gtk_widget_show (label);
|
||||||
|
|
||||||
|
label = gtk_label_new ("page");
|
||||||
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
|
||||||
|
|
||||||
|
|
||||||
|
frame = gtk_frame_new ("frame");
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
|
||||||
|
gtk_widget_set_usize (frame, 100, 75);
|
||||||
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
|
label = gtk_radio_button_new_with_label (NULL, "radio button");
|
||||||
|
assign_new_style( label );
|
||||||
|
gtk_container_add (GTK_CONTAINER (frame), label);
|
||||||
|
gtk_widget_show (label);
|
||||||
|
|
||||||
|
label = gtk_label_new ("page");
|
||||||
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
|
||||||
|
|
||||||
|
|
||||||
|
frame = gtk_frame_new ("frame");
|
||||||
|
gtk_container_set_border_width (GTK_CONTAINER (frame), 10);
|
||||||
|
gtk_widget_set_usize (frame, 100, 75);
|
||||||
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
|
label = gtk_entry_new ();
|
||||||
|
assign_new_style( label );
|
||||||
|
gtk_container_add (GTK_CONTAINER (frame), label);
|
||||||
|
gtk_widget_show (label);
|
||||||
|
|
||||||
|
label = gtk_label_new ("page");
|
||||||
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), frame, label);
|
||||||
|
|
||||||
|
/* Create a bunch of buttons */
|
||||||
|
button = gtk_button_new_with_label ("close");
|
||||||
|
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||||
|
GTK_SIGNAL_FUNC (delete), NULL);
|
||||||
|
gtk_table_attach_defaults(GTK_TABLE(table), button, 0,1,1,2);
|
||||||
|
gtk_widget_show(button);
|
||||||
|
|
||||||
|
button = gtk_button_new_with_label ("next page");
|
||||||
|
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||||
|
(GtkSignalFunc) gtk_notebook_next_page,
|
||||||
|
GTK_OBJECT (notebook));
|
||||||
|
gtk_table_attach_defaults(GTK_TABLE(table), button, 1,2,1,2);
|
||||||
|
gtk_widget_show(button);
|
||||||
|
|
||||||
|
button = gtk_button_new_with_label ("prev page");
|
||||||
|
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||||
|
(GtkSignalFunc) gtk_notebook_prev_page,
|
||||||
|
GTK_OBJECT (notebook));
|
||||||
|
gtk_table_attach_defaults(GTK_TABLE(table), button, 2,3,1,2);
|
||||||
|
gtk_widget_show(button);
|
||||||
|
|
||||||
|
button = gtk_button_new_with_label ("tab position");
|
||||||
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||||
|
(GtkSignalFunc) rotate_book, GTK_OBJECT(notebook));
|
||||||
|
gtk_table_attach_defaults(GTK_TABLE(table), button, 3,4,1,2);
|
||||||
|
gtk_widget_show(button);
|
||||||
|
|
||||||
|
button = gtk_button_new_with_label ("tabs/border on/off");
|
||||||
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||||
|
(GtkSignalFunc) tabsborder_book,
|
||||||
|
GTK_OBJECT (notebook));
|
||||||
|
gtk_table_attach_defaults(GTK_TABLE(table), button, 4,5,1,2);
|
||||||
|
gtk_widget_show(button);
|
||||||
|
|
||||||
|
button = gtk_button_new_with_label ("remove page");
|
||||||
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||||
|
(GtkSignalFunc) remove_book,
|
||||||
|
GTK_OBJECT(notebook));
|
||||||
|
gtk_table_attach_defaults(GTK_TABLE(table), button, 5,6,1,2);
|
||||||
|
gtk_widget_show(button);
|
||||||
|
|
||||||
|
gtk_widget_show(table);
|
||||||
|
gtk_widget_show(window);
|
||||||
|
|
||||||
|
gtk_main ();
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
/* example-end */
|
@@ -49,6 +49,8 @@ wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NUL
|
|||||||
|
|
||||||
extern bool g_isIdle;
|
extern bool g_isIdle;
|
||||||
|
|
||||||
|
bool g_mainThreadLocked = FALSE;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// local functions
|
// local functions
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -201,12 +203,16 @@ gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) )
|
|||||||
// unblock other threads wishing to do some GUI things
|
// unblock other threads wishing to do some GUI things
|
||||||
wxMutexGuiLeave();
|
wxMutexGuiLeave();
|
||||||
|
|
||||||
|
g_mainThreadLocked = TRUE;
|
||||||
|
|
||||||
// wake up other threads
|
// wake up other threads
|
||||||
wxUsleep( 1 );
|
wxUsleep( 1 );
|
||||||
|
|
||||||
// block other thread again
|
// block other thread again
|
||||||
wxMutexGuiEnter();
|
wxMutexGuiEnter();
|
||||||
|
|
||||||
|
g_mainThreadLocked = FALSE;
|
||||||
|
|
||||||
wxapp_install_thread_wakeup();
|
wxapp_install_thread_wakeup();
|
||||||
|
|
||||||
// release lock again
|
// release lock again
|
||||||
|
@@ -36,15 +36,19 @@
|
|||||||
#include "wx/settings.h"
|
#include "wx/settings.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
|
|
||||||
|
#ifdef __WXDEBUG__
|
||||||
|
#include "wx/thread.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "gdk/gdk.h"
|
#include <gdk/gdk.h>
|
||||||
#include "gtk/gtk.h"
|
#include <gtk/gtk.h>
|
||||||
#include "gdk/gdkprivate.h"
|
#include <gdk/gdkprivate.h>
|
||||||
#include "gdk/gdkkeysyms.h"
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include "wx/gtk/win_gtk.h"
|
#include <wx/gtk/win_gtk.h>
|
||||||
|
|
||||||
#include "gdk/gdkx.h"
|
#include <gdk/gdkx.h>
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// documentation on internals
|
// documentation on internals
|
||||||
@@ -198,12 +202,16 @@ static int g_sendActivateEvent = -1;
|
|||||||
the last click here */
|
the last click here */
|
||||||
static guint32 gs_timeLastClick = 0;
|
static guint32 gs_timeLastClick = 0;
|
||||||
|
|
||||||
|
extern bool g_mainThreadLocked;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// debug
|
// debug
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
|
|
||||||
|
#define DEBUG_MAIN_THREAD if (wxThread::IsMain() && g_mainThreadLocked) printf("gui reentrance");
|
||||||
|
|
||||||
static gint gtk_debug_focus_in_callback( GtkWidget *WXUNUSED(widget),
|
static gint gtk_debug_focus_in_callback( GtkWidget *WXUNUSED(widget),
|
||||||
GdkEvent *WXUNUSED(event),
|
GdkEvent *WXUNUSED(event),
|
||||||
const wxChar *WXUNUSED(name) )
|
const wxChar *WXUNUSED(name) )
|
||||||
@@ -590,6 +598,8 @@ static long map_to_wx_keysym( KeySym keysym )
|
|||||||
|
|
||||||
static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win )
|
static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (!win->m_hasVMT)
|
if (!win->m_hasVMT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -629,6 +639,8 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
|
|||||||
static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget),
|
static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget),
|
||||||
GdkRectangle *rect, wxWindow *win )
|
GdkRectangle *rect, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -665,6 +677,8 @@ static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget),
|
|||||||
|
|
||||||
static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
|
static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -817,6 +831,8 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
|
|||||||
|
|
||||||
static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
|
static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -873,6 +889,8 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk
|
|||||||
|
|
||||||
static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
|
static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1037,6 +1055,8 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
|
|||||||
|
|
||||||
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
|
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1155,6 +1175,8 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
|
|||||||
|
|
||||||
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
|
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1275,6 +1297,8 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
|
|||||||
|
|
||||||
static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
|
static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1335,6 +1359,8 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(
|
|||||||
|
|
||||||
static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
|
static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1378,6 +1404,8 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED
|
|||||||
|
|
||||||
static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
|
static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1424,6 +1452,8 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_
|
|||||||
|
|
||||||
static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
|
static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1470,6 +1500,8 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_
|
|||||||
|
|
||||||
static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win )
|
static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1504,6 +1536,8 @@ static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win )
|
|||||||
|
|
||||||
static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win )
|
static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1537,6 +1571,8 @@ static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win )
|
|||||||
|
|
||||||
static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
|
static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1557,6 +1593,8 @@ static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxW
|
|||||||
|
|
||||||
static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
|
static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1579,6 +1617,8 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget),
|
|||||||
GdkEventButton *WXUNUSED(gdk_event),
|
GdkEventButton *WXUNUSED(gdk_event),
|
||||||
wxWindow *win )
|
wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1600,6 +1640,8 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *WXUNUSED(widget),
|
|||||||
GdkEventButton *WXUNUSED(gdk_event),
|
GdkEventButton *WXUNUSED(gdk_event),
|
||||||
wxWindow *win )
|
wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
|
|
||||||
// don't test here as we can release the mouse while being over
|
// don't test here as we can release the mouse while being over
|
||||||
// a different window than the slider
|
// a different window than the slider
|
||||||
@@ -1631,6 +1673,8 @@ wxWindow *wxWindowBase::FindFocus()
|
|||||||
static gint
|
static gint
|
||||||
gtk_window_realized_callback( GtkWidget *WXUNUSED(m_widget), wxWindow *win )
|
gtk_window_realized_callback( GtkWidget *WXUNUSED(m_widget), wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
|
@@ -49,6 +49,8 @@ wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NUL
|
|||||||
|
|
||||||
extern bool g_isIdle;
|
extern bool g_isIdle;
|
||||||
|
|
||||||
|
bool g_mainThreadLocked = FALSE;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// local functions
|
// local functions
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -201,12 +203,16 @@ gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) )
|
|||||||
// unblock other threads wishing to do some GUI things
|
// unblock other threads wishing to do some GUI things
|
||||||
wxMutexGuiLeave();
|
wxMutexGuiLeave();
|
||||||
|
|
||||||
|
g_mainThreadLocked = TRUE;
|
||||||
|
|
||||||
// wake up other threads
|
// wake up other threads
|
||||||
wxUsleep( 1 );
|
wxUsleep( 1 );
|
||||||
|
|
||||||
// block other thread again
|
// block other thread again
|
||||||
wxMutexGuiEnter();
|
wxMutexGuiEnter();
|
||||||
|
|
||||||
|
g_mainThreadLocked = FALSE;
|
||||||
|
|
||||||
wxapp_install_thread_wakeup();
|
wxapp_install_thread_wakeup();
|
||||||
|
|
||||||
// release lock again
|
// release lock again
|
||||||
|
@@ -36,15 +36,19 @@
|
|||||||
#include "wx/settings.h"
|
#include "wx/settings.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
|
|
||||||
|
#ifdef __WXDEBUG__
|
||||||
|
#include "wx/thread.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include "gdk/gdk.h"
|
#include <gdk/gdk.h>
|
||||||
#include "gtk/gtk.h"
|
#include <gtk/gtk.h>
|
||||||
#include "gdk/gdkprivate.h"
|
#include <gdk/gdkprivate.h>
|
||||||
#include "gdk/gdkkeysyms.h"
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include "wx/gtk/win_gtk.h"
|
#include <wx/gtk/win_gtk.h>
|
||||||
|
|
||||||
#include "gdk/gdkx.h"
|
#include <gdk/gdkx.h>
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// documentation on internals
|
// documentation on internals
|
||||||
@@ -198,12 +202,16 @@ static int g_sendActivateEvent = -1;
|
|||||||
the last click here */
|
the last click here */
|
||||||
static guint32 gs_timeLastClick = 0;
|
static guint32 gs_timeLastClick = 0;
|
||||||
|
|
||||||
|
extern bool g_mainThreadLocked;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// debug
|
// debug
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __WXDEBUG__
|
#ifdef __WXDEBUG__
|
||||||
|
|
||||||
|
#define DEBUG_MAIN_THREAD if (wxThread::IsMain() && g_mainThreadLocked) printf("gui reentrance");
|
||||||
|
|
||||||
static gint gtk_debug_focus_in_callback( GtkWidget *WXUNUSED(widget),
|
static gint gtk_debug_focus_in_callback( GtkWidget *WXUNUSED(widget),
|
||||||
GdkEvent *WXUNUSED(event),
|
GdkEvent *WXUNUSED(event),
|
||||||
const wxChar *WXUNUSED(name) )
|
const wxChar *WXUNUSED(name) )
|
||||||
@@ -590,6 +598,8 @@ static long map_to_wx_keysym( KeySym keysym )
|
|||||||
|
|
||||||
static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win )
|
static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (!win->m_hasVMT)
|
if (!win->m_hasVMT)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -629,6 +639,8 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
|
|||||||
static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget),
|
static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget),
|
||||||
GdkRectangle *rect, wxWindow *win )
|
GdkRectangle *rect, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -665,6 +677,8 @@ static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget),
|
|||||||
|
|
||||||
static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
|
static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -817,6 +831,8 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
|
|||||||
|
|
||||||
static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
|
static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -873,6 +889,8 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk
|
|||||||
|
|
||||||
static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
|
static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1037,6 +1055,8 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
|
|||||||
|
|
||||||
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
|
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1155,6 +1175,8 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
|
|||||||
|
|
||||||
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
|
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1275,6 +1297,8 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
|
|||||||
|
|
||||||
static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
|
static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1335,6 +1359,8 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(
|
|||||||
|
|
||||||
static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
|
static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1378,6 +1404,8 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED
|
|||||||
|
|
||||||
static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
|
static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1424,6 +1452,8 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_
|
|||||||
|
|
||||||
static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
|
static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1470,6 +1500,8 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_
|
|||||||
|
|
||||||
static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win )
|
static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1504,6 +1536,8 @@ static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win )
|
|||||||
|
|
||||||
static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win )
|
static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1537,6 +1571,8 @@ static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win )
|
|||||||
|
|
||||||
static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
|
static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1557,6 +1593,8 @@ static void gtk_window_vscroll_change_callback( GtkWidget *WXUNUSED(widget), wxW
|
|||||||
|
|
||||||
static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
|
static void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1579,6 +1617,8 @@ static gint gtk_scrollbar_button_press_callback( GtkRange *WXUNUSED(widget),
|
|||||||
GdkEventButton *WXUNUSED(gdk_event),
|
GdkEventButton *WXUNUSED(gdk_event),
|
||||||
wxWindow *win )
|
wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
@@ -1600,6 +1640,8 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *WXUNUSED(widget),
|
|||||||
GdkEventButton *WXUNUSED(gdk_event),
|
GdkEventButton *WXUNUSED(gdk_event),
|
||||||
wxWindow *win )
|
wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
|
|
||||||
// don't test here as we can release the mouse while being over
|
// don't test here as we can release the mouse while being over
|
||||||
// a different window than the slider
|
// a different window than the slider
|
||||||
@@ -1631,6 +1673,8 @@ wxWindow *wxWindowBase::FindFocus()
|
|||||||
static gint
|
static gint
|
||||||
gtk_window_realized_callback( GtkWidget *WXUNUSED(m_widget), wxWindow *win )
|
gtk_window_realized_callback( GtkWidget *WXUNUSED(m_widget), wxWindow *win )
|
||||||
{
|
{
|
||||||
|
DEBUG_MAIN_THREAD
|
||||||
|
|
||||||
if (g_isIdle)
|
if (g_isIdle)
|
||||||
wxapp_install_idle_handler();
|
wxapp_install_idle_handler();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user