* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* By Owen Taylor <otaylor@gtk.org> 98/4/4 */
/*
- * Modified by the GTK+ Team and others 1997-1999. See the AUTHORS
+ * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*/
-#include "gdkx.h"
+#include "gdkconfig.h"
+#include "gdkprivate.h"
+
+#if defined (GDK_WINDOWING_X11)
+#include "x11/gdkx.h"
+#elif defined (GDK_WINDOWING_WIN32)
+#include "win32/gdkwin32.h"
+#elif defined (GDK_WINDOWING_NANOX)
+#include "nanox/gdkprivate-nanox.h"
+#elif defined (GDK_WINDOWING_FB)
+#include "linux-fb/gdkfb.h"
+#endif
+
#include "gdk/gdkkeysyms.h"
#include "gtkplug.h"
static void gtk_plug_init (GtkPlug *plug);
static void gtk_plug_realize (GtkWidget *widget);
+static void gtk_plug_unrealize (GtkWidget *widget);
static gint gtk_plug_key_press_event (GtkWidget *widget,
GdkEventKey *event);
static void gtk_plug_forward_key_press (GtkPlug *plug, GdkEventKey *event);
/* From Tk */
#define EMBEDDED_APP_WANTS_FOCUS NotifyNormal+20
+
+static GtkWindowClass *parent_class = NULL;
-guint
+GtkType
gtk_plug_get_type ()
{
- static guint plug_type = 0;
+ static GtkType plug_type = 0;
if (!plug_type)
{
- static const GtkTypeInfo plug_info =
+ static const GTypeInfo plug_info =
{
- "GtkPlug",
- sizeof (GtkPlug),
sizeof (GtkPlugClass),
- (GtkClassInitFunc) gtk_plug_class_init,
- (GtkObjectInitFunc) gtk_plug_init,
- (GtkArgSetFunc) NULL,
- (GtkArgGetFunc) NULL
+ NULL, /* base_init */
+ NULL, /* base_finalize */
+ (GClassInitFunc) gtk_plug_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (GtkPlug),
+ 16, /* n_preallocs */
+ (GInstanceInitFunc) gtk_plug_init,
};
- plug_type = gtk_type_unique (gtk_window_get_type (), &plug_info);
+ plug_type = g_type_register_static (GTK_TYPE_WINDOW, "GtkPlug", &plug_info, 0);
}
return plug_type;
widget_class = (GtkWidgetClass *)class;
window_class = (GtkWindowClass *)class;
+ parent_class = gtk_type_class (GTK_TYPE_WINDOW);
+
widget_class->realize = gtk_plug_realize;
+ widget_class->unrealize = gtk_plug_unrealize;
widget_class->key_press_event = gtk_plug_key_press_event;
widget_class->focus_in_event = gtk_plug_focus_in_event;
widget_class->focus_out_event = gtk_plug_focus_out_event;
}
void
-gtk_plug_construct (GtkPlug *plug, guint32 socket_id)
+gtk_plug_construct (GtkPlug *plug, GdkNativeWindow socket_id)
{
plug->socket_window = gdk_window_lookup (socket_id);
plug->same_app = TRUE;
}
GtkWidget*
-gtk_plug_new (guint32 socket_id)
+gtk_plug_new (GdkNativeWindow socket_id)
{
GtkPlug *plug;
- plug = GTK_PLUG (gtk_type_new (gtk_plug_get_type ()));
+ plug = GTK_PLUG (gtk_type_new (GTK_TYPE_PLUG));
gtk_plug_construct (plug, socket_id);
return GTK_WIDGET (plug);
}
+static void
+gtk_plug_unrealize (GtkWidget *widget)
+{
+ GtkPlug *plug;
+
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (GTK_IS_PLUG (widget));
+
+ plug = GTK_PLUG (widget);
+
+ if (plug->socket_window != NULL)
+ {
+ gdk_window_set_user_data (plug->socket_window, NULL);
+ gdk_window_unref (plug->socket_window);
+ plug->socket_window = NULL;
+ }
+
+ if (GTK_WIDGET_CLASS (parent_class)->unrealize)
+ (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
+}
+
static void
gtk_plug_realize (GtkWidget *widget)
{
widget->window = gdk_window_new (NULL, &attributes, attributes_mask);
}
- ((GdkWindowPrivate *)widget->window)->window_type = GDK_WINDOW_TOPLEVEL;
+ GDK_WINDOW_TYPE (window) = GDK_WINDOW_TOPLEVEL;
gdk_window_set_user_data (widget->window, window);
widget->style = gtk_style_attach (widget->style, widget->window);
gtk_window_set_focus (GTK_WINDOW (widget), NULL);
gdk_error_trap_push ();
-#if GDK_WINDOWING == GDK_WINDOWING_X11
+#ifdef GDK_WINDOWING_X11
XSetInputFocus (GDK_DISPLAY (),
GDK_WINDOW_XWINDOW (plug->socket_window),
RevertToParent, event->time);
-#elif GDK_WINDOWING == GDK_WINDOWING_WIN32
- SetFocus (GDK_WINDOW_XWINDOW (plug->socket_window));
+#elif defined (GDK_WINDOWING_WIN32)
+ SetFocus (GDK_WINDOW_HWND (plug->socket_window));
#endif
gdk_flush ();
gdk_error_trap_pop ();
static void
gtk_plug_forward_key_press (GtkPlug *plug, GdkEventKey *event)
{
-#if GDK_WINDOWING == GDK_WINDOWING_X11
+#ifdef GDK_WINDOWING_X11
XEvent xevent;
xevent.xkey.type = KeyPress;
False, NoEventMask, &xevent);
gdk_flush ();
gdk_error_trap_pop ();
-#elif GDK_WINDOWING == GDK_WINDOWING_WIN32
+#elif defined (GDK_WINDOWING_WIN32)
/* This is pretty bogus, and not tested at all. */
WPARAM wParam;
LPARAM lParam;
break;
}
- PostMessage (GDK_WINDOW_XWINDOW (plug->socket_window),
+ PostMessage (GDK_WINDOW_HWND (plug->socket_window),
WM_KEYDOWN, wParam, lParam);
if (!no_WM_CHAR)
- PostMessage (GDK_WINDOW_XWINDOW (plug->socket_window),
+ PostMessage (GDK_WINDOW_HWND (plug->socket_window),
WM_CHAR, wParam, lParam);
- PostMessage (GDK_WINDOW_XWINDOW (plug->socket_window),
+ PostMessage (GDK_WINDOW_HWND (plug->socket_window),
WM_KEYUP, wParam, lParam);
#endif
}
if (focus && !GTK_WIDGET_HAS_FOCUS(window))
{
-#if GDK_WINDOWING == GDK_WINDOWING_X11
+#ifdef GDK_WINDOWING_X11
XEvent xevent;
xevent.xfocus.type = FocusIn;
False, NoEventMask, &xevent);
gdk_flush ();
gdk_error_trap_pop ();
-#elif GDK_WINDOWING == GDK_WINDOWING_WIN32
+#elif defined (GDK_WINDOWING_WIN32)
/* XXX Not implemented */
#endif
}