#include "wx/gtk/private.h"
#include "wx/timer.h"
#include "wx/settings.h"
+#include "wx/evtloop.h"
#include <glib.h>
#include <gdk/gdk.h>
// "focus_in_event"
//-----------------------------------------------------------------------------
+extern "C" {
static gint gtk_frame_focus_in_callback( GtkWidget *widget,
GdkEvent *WXUNUSED(event),
wxTopLevelWindowGTK *win )
return FALSE;
}
+}
//-----------------------------------------------------------------------------
// "focus_out_event"
//-----------------------------------------------------------------------------
+extern "C" {
static gint gtk_frame_focus_out_callback( GtkWidget *widget,
GdkEventFocus *WXUNUSED(gdk_event),
wxTopLevelWindowGTK *win )
return FALSE;
}
+}
//-----------------------------------------------------------------------------
// "focus" from m_window
//-----------------------------------------------------------------------------
+extern "C" {
static gint gtk_frame_focus_callback( GtkWidget *widget, GtkDirectionType WXUNUSED(d), wxWindow *WXUNUSED(win) )
{
if (g_isIdle)
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus" );
return TRUE;
}
+}
//-----------------------------------------------------------------------------
// "size_allocate"
//-----------------------------------------------------------------------------
+extern "C" {
static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxTopLevelWindowGTK *win )
{
if (g_isIdle)
win->GtkUpdateSize();
}
}
+}
//-----------------------------------------------------------------------------
// "delete_event"
//-----------------------------------------------------------------------------
+extern "C" {
static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxTopLevelWindowGTK *win )
{
if (g_isIdle)
return TRUE;
}
+}
//-----------------------------------------------------------------------------
// "configure_event"
//-----------------------------------------------------------------------------
+extern "C" {
static gint
gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxTopLevelWindowGTK *win )
{
return FALSE;
}
+}
//-----------------------------------------------------------------------------
// "realize" from m_widget
// we cannot MWM hints and icons before the widget has been realized,
// so we do this directly after realization
+extern "C" {
static void
gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget),
wxTopLevelWindowGTK *win )
win->SetIcons( iconsOld );
}
}
+}
//-----------------------------------------------------------------------------
// "map_event" from m_widget
//-----------------------------------------------------------------------------
+extern "C" {
static void
gtk_frame_map_callback( GtkWidget * WXUNUSED(widget),
GdkEvent * WXUNUSED(event),
{
win->SetIconizeState(FALSE);
}
+}
//-----------------------------------------------------------------------------
// "unmap_event" from m_widget
//-----------------------------------------------------------------------------
+extern "C" {
static void
gtk_frame_unmap_callback( GtkWidget * WXUNUSED(widget),
GdkEvent * WXUNUSED(event),
{
win->SetIconizeState(TRUE);
}
+}
//-----------------------------------------------------------------------------
// "expose_event" of m_client
//-----------------------------------------------------------------------------
+extern "C" {
static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxWindow *win )
{
GtkPizza *pizza = GTK_PIZZA(widget);
return FALSE;
}
+}
//-----------------------------------------------------------------------------
// "draw" of m_client
#ifndef __WXGTK20__
+extern "C" {
static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxWindow *win )
{
GtkPizza *pizza = GTK_PIZZA(widget);
(char *)"base",
0, 0, -1, -1);
}
+}
#endif // GTK+ 1.x
{
m_widget = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#if GTK_CHECK_VERSION(2,1,0)
- if (style & wxFRAME_TOOL_WINDOW)
- gtk_window_set_type_hint(GTK_WINDOW(m_widget),
- GDK_WINDOW_TYPE_HINT_UTILITY);
+ if (!gtk_check_version(2,1,0))
+ {
+ if (style & wxFRAME_TOOL_WINDOW)
+ {
+ gtk_window_set_type_hint(GTK_WINDOW(m_widget),
+ GDK_WINDOW_TYPE_HINT_UTILITY);
+
+ // On some WMs, like KDE, a TOOL_WINDOW will still show
+ // on the taskbar, but on Gnome a TOOL_WINDOW will not.
+ // For consistency between WMs and with Windows, we
+ // should set the NO_TASKBAR flag which will apply
+ // the set_skip_taskbar_hint if it is available,
+ // ensuring no taskbar entry will appear.
+ style |= wxFRAME_NO_TASKBAR;
+ }
+ }
#endif
-
}
}
}
#if GTK_CHECK_VERSION(2,2,0)
- if (style & wxFRAME_NO_TASKBAR)
+ if (!gtk_check_version(2,2,0))
{
- gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_widget), TRUE);
+ if (style & wxFRAME_NO_TASKBAR)
+ {
+ gtk_window_set_skip_taskbar_hint(GTK_WINDOW(m_widget), TRUE);
+ }
+ }
+#endif
+
+#if GTK_CHECK_VERSION(2,4,0)
+ if (!gtk_check_version(2,4,0))
+ {
+ if (style & wxSTAY_ON_TOP)
+ {
+ gtk_window_set_keep_above(GTK_WINDOW(m_widget), TRUE);
+ }
}
#endif
bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long style )
{
- if (show == m_fsIsShowing) return FALSE; // return what?
+ if (show == m_fsIsShowing)
+ return FALSE; // return what?
m_fsIsShowing = show;
-
-#ifdef __WXGTK20__
-
- if (show)
- gtk_window_fullscreen( GTK_WINDOW( m_widget ) );
- else
- gtk_window_unfullscreen( GTK_WINDOW( m_widget ) );
-
-#else
-
- GdkWindow *window = m_widget->window;
+
wxX11FullScreenMethod method =
wxGetFullScreenMethodX11((WXDisplay*)GDK_DISPLAY(),
(WXWindow)GDK_ROOT_WINDOW());
- if (show)
+#if GTK_CHECK_VERSION(2,2,0)
+ // NB: gtk_window_fullscreen() uses freedesktop.org's WMspec extensions
+ // to switch to fullscreen, which is not always available. We must
+ // check if WM supports the spec and use legacy methods if it
+ // doesn't.
+ if ( (method == wxX11_FS_WMSPEC) && !gtk_check_version(2,2,0) )
{
- m_fsSaveFlag = style;
- GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y );
- GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height );
-
- int screen_width,screen_height;
- wxDisplaySize( &screen_width, &screen_height );
-
- gint client_x, client_y, root_x, root_y;
- gint width, height;
-
- if (method != wxX11_FS_WMSPEC)
- {
- // don't do it always, Metacity hates it
- m_fsSaveGdkFunc = m_gdkFunc;
- m_fsSaveGdkDecor = m_gdkDecor;
- m_gdkFunc = m_gdkDecor = 0;
- gdk_window_set_decorations(window, (GdkWMDecoration)0);
- gdk_window_set_functions(window, (GdkWMFunction)0);
- }
-
- gdk_window_get_origin (m_widget->window, &root_x, &root_y);
- gdk_window_get_geometry (m_widget->window, &client_x, &client_y,
- &width, &height, NULL);
-
- gdk_window_move_resize (m_widget->window, -client_x, -client_y,
- screen_width + 1, screen_height + 1);
+ if (show)
+ gtk_window_fullscreen( GTK_WINDOW( m_widget ) );
+ else
+ gtk_window_unfullscreen( GTK_WINDOW( m_widget ) );
- wxSetFullScreenStateX11((WXDisplay*)GDK_DISPLAY(),
- (WXWindow)GDK_ROOT_WINDOW(),
- (WXWindow)GDK_WINDOW_XWINDOW(window),
- show, &m_fsSaveFrame, method);
+ return TRUE;
}
else
+#endif // GTK+ >= 2.2.0
{
- if (method != wxX11_FS_WMSPEC)
+ GdkWindow *window = m_widget->window;
+
+ if (show)
{
- // don't do it always, Metacity hates it
- m_gdkFunc = m_fsSaveGdkFunc;
- m_gdkDecor = m_fsSaveGdkDecor;
- gdk_window_set_decorations(window, (GdkWMDecoration)m_gdkDecor);
- gdk_window_set_functions(window, (GdkWMFunction)m_gdkFunc);
+ m_fsSaveFlag = style;
+ GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y );
+ GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height );
+
+ int screen_width,screen_height;
+ wxDisplaySize( &screen_width, &screen_height );
+
+ gint client_x, client_y, root_x, root_y;
+ gint width, height;
+
+ if (method != wxX11_FS_WMSPEC)
+ {
+ // don't do it always, Metacity hates it
+ m_fsSaveGdkFunc = m_gdkFunc;
+ m_fsSaveGdkDecor = m_gdkDecor;
+ m_gdkFunc = m_gdkDecor = 0;
+ gdk_window_set_decorations(window, (GdkWMDecoration)0);
+ gdk_window_set_functions(window, (GdkWMFunction)0);
+ }
+
+ gdk_window_get_origin (m_widget->window, &root_x, &root_y);
+ gdk_window_get_geometry (m_widget->window, &client_x, &client_y,
+ &width, &height, NULL);
+
+ gdk_window_move_resize (m_widget->window, -client_x, -client_y,
+ screen_width + 1, screen_height + 1);
+
+ wxSetFullScreenStateX11((WXDisplay*)GDK_DISPLAY(),
+ (WXWindow)GDK_ROOT_WINDOW(),
+ (WXWindow)GDK_WINDOW_XWINDOW(window),
+ show, &m_fsSaveFrame, method);
+ }
+ else
+ {
+ if (method != wxX11_FS_WMSPEC)
+ {
+ // don't do it always, Metacity hates it
+ m_gdkFunc = m_fsSaveGdkFunc;
+ m_gdkDecor = m_fsSaveGdkDecor;
+ gdk_window_set_decorations(window, (GdkWMDecoration)m_gdkDecor);
+ gdk_window_set_functions(window, (GdkWMFunction)m_gdkFunc);
+ }
+
+ wxSetFullScreenStateX11((WXDisplay*)GDK_DISPLAY(),
+ (WXWindow)GDK_ROOT_WINDOW(),
+ (WXWindow)GDK_WINDOW_XWINDOW(window),
+ show, &m_fsSaveFrame, method);
+
+ SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y,
+ m_fsSaveFrame.width, m_fsSaveFrame.height);
}
-
- wxSetFullScreenStateX11((WXDisplay*)GDK_DISPLAY(),
- (WXWindow)GDK_ROOT_WINDOW(),
- (WXWindow)GDK_WINDOW_XWINDOW(window),
- show, &m_fsSaveFrame, method);
-
- SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y,
- m_fsSaveFrame.width, m_fsSaveFrame.height);
}
-#endif
return TRUE;
}
return wxWindow::Show( show );
}
+void wxTopLevelWindowGTK::Raise()
+{
+#ifdef __WXGTK20__
+ gtk_window_present( GTK_WINDOW( m_widget ) );
+#else
+ wxWindow::Raise();
+#endif
+}
+
void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
{
wxFAIL_MSG( wxT("DoMoveWindow called for wxTopLevelWindowGTK") );
{
m_grabbed = TRUE;
gtk_grab_add( m_widget );
- gtk_main();
+ wxEventLoop().Run();
gtk_grab_remove( m_widget );
}
}