Compare commits

..

11 Commits

Author SHA1 Message Date
blizzard%redhat.com
ad20a1de67 this is the first landing of code that really works pretty well. it's still got some refcounting problems, doesn't do menus quite right but it's a good start. It needs to have owen's drawing queue code merged in. also, this has merges from head in it.
git-svn-id: svn://10.0.0.236/branches/DIE_GTKLAYOUT_DIE@50973 18797224-902f-48f8-a5cc-f745e15eee43
1999-10-18 03:10:29 +00:00
blizzard%redhat.com
9966f3f1a8 more work on getting ConfigureNotify events and Expose events to play nice together. More progress here but it's not done yet.
git-svn-id: svn://10.0.0.236/branches/DIE_GTKLAYOUT_DIE@48897 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-23 04:57:36 +00:00
blizzard%redhat.com
6d93c5d47f resizing the toplevel window now works. remove some hacks for determining if the window might be too small to show, might be added back in later.
git-svn-id: svn://10.0.0.236/branches/DIE_GTKLAYOUT_DIE@48678 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-22 00:35:38 +00:00
blizzard%redhat.com
8059e538b5 Make sure that a the superwin is destroyed on the nsWindow's object destruction. Add preliminary support for size changes and ConfigureNotify events.
git-svn-id: svn://10.0.0.236/branches/DIE_GTKLAYOUT_DIE@48488 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-21 03:39:13 +00:00
blizzard%redhat.com
a45efc822e work on destroying objects properly
git-svn-id: svn://10.0.0.236/branches/DIE_GTKLAYOUT_DIE@47983 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-17 18:58:45 +00:00
blizzard%redhat.com
ed2fbcb18b initial checkin of changes to kill gtklayout
git-svn-id: svn://10.0.0.236/branches/DIE_GTKLAYOUT_DIE@47902 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-17 03:32:52 +00:00
blizzard%redhat.com
1ba2a1ebb2 remove gtk_moz_window.*
git-svn-id: svn://10.0.0.236/branches/DIE_GTKLAYOUT_DIE@47898 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-17 02:32:27 +00:00
blizzard%redhat.com
1d8185735b bring branch up to date. add gtklayout clone called gtk_moz_window.
git-svn-id: svn://10.0.0.236/branches/DIE_GTKLAYOUT_DIE@46173 18797224-902f-48f8-a5cc-f745e15eee43
1999-09-07 11:52:25 +00:00
blizzard%redhat.com
df70f9f698 add MPL
git-svn-id: svn://10.0.0.236/branches/DIE_GTKLAYOUT_DIE@36043 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-21 14:06:28 +00:00
blizzard%redhat.com
b2d8e5ef55 modifications for trying to optimize the gtk window widget
git-svn-id: svn://10.0.0.236/branches/DIE_GTKLAYOUT_DIE@36042 18797224-902f-48f8-a5cc-f745e15eee43
1999-06-21 14:00:22 +00:00
(no author)
70ef32cff9 This commit was manufactured by cvs2svn to create branch
'DIE_GTKLAYOUT_DIE'.

git-svn-id: svn://10.0.0.236/branches/DIE_GTKLAYOUT_DIE@33311 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-31 19:41:44 +00:00
7 changed files with 819 additions and 105 deletions

View File

@@ -1,105 +0,0 @@
/*
The contents of this file are subject to the Mozilla Public
License Version 1.1 (the "License"); you may not use this file
except in compliance with the License. You may obtain a copy of
the License at http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
implied. See the License for the specific language governing
rights and limitations under the License.
The Original Code is mozilla.org code.
The Initial Developer of the Original Code is Sun Microsystems,
Inc. Portions created by Sun are
Copyright (C) 1999 Sun Microsystems, Inc. All
Rights Reserved.
Contributor(s):
*/
#ifndef __JavaDOMGlobals_h__
#define __JavaDOMGlobals_h__
#include "jni.h"
#include "prclist.h"
#include "nsError.h"
#ifdef ERROR
#undef ERROR
#endif
class nsISupports;
class nsIDOMNode;
struct PRLogModuleInfo;
struct PRLock;
class JavaDOMGlobals {
public:
static jclass attrClass;
static jclass cDataSectionClass;
static jclass commentClass;
static jclass documentClass;
static jclass documentFragmentClass;
static jclass documentTypeClass;
static jclass domImplementationClass;
static jclass elementClass;
static jclass entityClass;
static jclass entityReferenceClass;
static jclass namedNodeMapClass;
static jclass nodeClass;
static jclass nodeListClass;
static jclass notationClass;
static jclass processingInstructionClass;
static jclass textClass;
static jfieldID nodePtrFID;
static jfieldID nodeListPtrFID;
static jfieldID domImplementationPtrFID;
static jfieldID nodeTypeAttributeFID;
static jfieldID nodeTypeCDataSectionFID;
static jfieldID nodeTypeCommentFID;
static jfieldID nodeTypeDocumentFragmentFID;
static jfieldID nodeTypeDocumentFID;
static jfieldID nodeTypeDocumentTypeFID;
static jfieldID nodeTypeElementFID;
static jfieldID nodeTypeEntityFID;
static jfieldID nodeTypeEntityReferenceFID;
static jfieldID nodeTypeNotationFID;
static jfieldID nodeTypeProcessingInstructionFID;
static jfieldID nodeTypeTextFID;
static jclass domExceptionClass;
static jmethodID domExceptionInitMID;
static jclass runtimeExceptionClass;
static jmethodID runtimeExceptionInitMID;
static const char* const DOM_EXCEPTION_MESSAGE[];
typedef enum ExceptionType { EXCEPTION_RUNTIME,
EXCEPTION_DOM } ExceptionType;
static PRLogModuleInfo* log;
static PRCList garbage;
static PRLock* garbageLock;
static PRInt32 javaMaxInt;
static void Initialize(JNIEnv *env);
static void Destroy(JNIEnv *env);
static jobject CreateNodeSubtype(JNIEnv *env,
nsIDOMNode *node);
static void AddToGarbage(nsISupports* domObject);
static void TakeOutGarbage();
static void ThrowException(JNIEnv *env,
const char * message = NULL,
nsresult rv = NS_OK,
ExceptionType exceptionType = EXCEPTION_RUNTIME);
};
#endif /* __JavaDOMGlobals_h__ */

View File

@@ -0,0 +1,345 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "MPL"); you may not use this file except in
* compliance with the MPL. You may obtain a copy of the MPL at
* http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL
* for the specific language governing rights and limitations under the
* MPL.
*
* The Initial Developers of this code under the MPL are Owen Taylor
* <otaylor@redhat.com> and Christopher Blizzard <blizzard@redhat.com>.
* Portions created by the Initial Developers are Copyright (C) 1999
* Owen Taylor and Christopher Blizzard. All Rights Reserved.
*/
#include "gdksuperwin.h"
static void gdk_superwin_class_init(GdkSuperWinClass *klass);
static void gdk_superwin_init(GdkSuperWin *superwin);
typedef struct _GdkSuperWinTranslate GdkSuperWinTranslate;
struct _GdkSuperWinTranslate
{
unsigned long serial;
gint dx;
gint dy;
};
GtkType
gdk_superwin_get_type(void)
{
static GtkType superwin_type = 0;
if (!superwin_type)
{
static const GtkTypeInfo superwin_info =
{
"GtkSuperWin",
sizeof(GdkSuperWin),
sizeof(GdkSuperWinClass),
(GtkClassInitFunc) gdk_superwin_class_init,
(GtkObjectInitFunc) gdk_superwin_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
superwin_type = gtk_type_unique (gtk_object_get_type(), &superwin_info);
}
return superwin_type;
}
static void
gdk_superwin_class_init(GdkSuperWinClass *klass)
{
GtkObjectClass *object_class;
object_class = GTK_OBJECT_CLASS(klass);
/* XXX do we need a finalize in here to destroy the
window? */
}
static void
gdk_superwin_init(GdkSuperWin *superwin)
{
}
static GdkFilterReturn gdk_superwin_bin_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data);
static GdkFilterReturn gdk_superwin_shell_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data);
static void gdk_superwin_expose_area (GdkSuperWin *superwin,
gint x,
gint y,
gint width,
gint height);
static gboolean gravity_works;
GdkSuperWin *
gdk_superwin_new (GdkWindow *parent_window,
guint x,
guint y,
guint width,
guint height)
{
GdkWindowAttr attributes;
gint attributes_mask;
GdkSuperWin *superwin = gtk_type_new(GDK_TYPE_SUPERWIN);
superwin->translate_queue = NULL;
superwin->shell_func = NULL;
superwin->bin_func = NULL;
superwin->func_data = NULL;
superwin->notify = NULL;
/* Create the shell (clipping) window */
attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = x;
attributes.y = y;
attributes.width = width;
attributes.height = height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y;
superwin->shell_window = gdk_window_new (parent_window,
&attributes, attributes_mask);
/* Create the bin window for drawing */
attributes.x = 0;
attributes.y = 0;
attributes.event_mask = GDK_EXPOSURE_MASK;
superwin->bin_window = gdk_window_new (superwin->shell_window,
&attributes, attributes_mask);
gdk_window_show (superwin->bin_window);
gdk_window_add_filter (superwin->shell_window, gdk_superwin_shell_filter, superwin);
gdk_window_add_filter (superwin->bin_window, gdk_superwin_bin_filter, superwin);
gravity_works = gdk_window_set_static_gravities (superwin->bin_window, TRUE);
return superwin;
}
/* XXX this should really be part of the object... */
/* XXX and it should chain up to the object's destructor */
void gdk_superwin_destroy(GdkSuperWin *superwin)
{
gdk_window_remove_filter(superwin->shell_window,
gdk_superwin_shell_filter,
superwin);
gdk_window_remove_filter(superwin->bin_window,
gdk_superwin_bin_filter,
superwin);
gdk_window_destroy(superwin->bin_window);
gdk_window_destroy(superwin->shell_window);
/* XXX this needs to free itself */
}
void
gdk_superwin_scroll (GdkSuperWin *superwin,
gint dx,
gint dy)
{
GdkSuperWinTranslate *translate;
gint width, height;
gdk_window_get_size (superwin->shell_window, &width, &height);
if (dx > 0 || dy > 0)
{
translate = g_new (GdkSuperWinTranslate, 1);
translate->dx = MAX (0, dx);
translate->dy = MAX (0, dy);
translate->serial = NextRequest (GDK_DISPLAY());
superwin->translate_queue = g_list_append (superwin->translate_queue, translate);
}
gdk_window_move_resize (superwin->bin_window,
MIN (0, -dx), MIN (0, -dy),
width + ABS(dx), height + ABS(dy));
gdk_window_move (superwin->bin_window,
MIN (0, -dx) + dx, MIN (0, -dy) + dy);
if (dx < 0 || dy < 0)
{
translate = g_new (GdkSuperWinTranslate, 1);
translate->dx = MIN (0, dx);
translate->dy = MIN (0, dy);
translate->serial = NextRequest (GDK_DISPLAY());
superwin->translate_queue = g_list_append (superwin->translate_queue, translate);
}
gdk_window_move_resize (superwin->bin_window,
0, 0, width, height);
if (dx < 0)
gdk_superwin_expose_area (superwin,
MAX (width + dx, 0), 0,
MIN (-dx, width), height);
else
gdk_superwin_expose_area (superwin,
0, 0,
MIN (dx, width), height);
if (dy < 0)
gdk_superwin_expose_area (superwin,
MIN (dx, 0), MAX (height + dy, 0),
MIN (width - ABS(dx), 0), MIN (-dy, height));
else
gdk_superwin_expose_area (superwin,
MIN (dx, 0), 0,
MIN (width - ABS(dx), 0), MIN (dy, height));
}
void
gdk_superwin_set_event_funcs (GdkSuperWin *superwin,
GdkSuperWinFunc shell_func,
GdkSuperWinFunc bin_func,
gpointer func_data,
GDestroyNotify notify)
{
if (superwin->notify && superwin->func_data)
superwin->notify (superwin->func_data);
superwin->shell_func = shell_func;
superwin->bin_func = bin_func;
superwin->func_data = func_data;
superwin->notify = notify;
}
void gdk_superwin_resize (GdkSuperWin *superwin,
gint width,
gint height)
{
gdk_window_resize (superwin->bin_window, width, height);
gdk_window_resize (superwin->shell_window, width, height);
}
static void
gdk_superwin_expose_area (GdkSuperWin *superwin,
gint x,
gint y,
gint width,
gint height)
{
}
static GdkFilterReturn
gdk_superwin_bin_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data)
{
XEvent *xevent = (XEvent *)gdk_xevent;
GdkSuperWin *superwin = data;
GdkSuperWinTranslate *translate;
GList *tmp_list;
switch (xevent->xany.type) {
case Expose:
tmp_list = superwin->translate_queue;
while (tmp_list) {
translate = tmp_list->data;
xevent->xexpose.x += translate->dx;
xevent->xexpose.y += translate->dy;
tmp_list = tmp_list->next;
}
if (superwin->bin_func) {
superwin->bin_func (superwin, xevent, superwin->func_data);
}
return GDK_FILTER_REMOVE;
break;
case ConfigureNotify:
gdk_superwin_clear_translate_queue(superwin, xevent->xany.serial);
break;
}
return GDK_FILTER_CONTINUE;
}
static GdkFilterReturn
gdk_superwin_shell_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data)
{
XEvent *xevent = (XEvent *)gdk_xevent;
GdkSuperWin *superwin = data;
if (xevent->type == VisibilityNotify)
{
switch (xevent->xvisibility.state)
{
case VisibilityFullyObscured:
superwin->visibility = GDK_VISIBILITY_FULLY_OBSCURED;
break;
case VisibilityPartiallyObscured:
superwin->visibility = GDK_VISIBILITY_PARTIAL;
break;
case VisibilityUnobscured:
superwin->visibility = GDK_VISIBILITY_UNOBSCURED;
break;
}
return GDK_FILTER_REMOVE;
}
if (superwin->shell_func) {
/* g_print("calling func %p with arg %p in win %p\n",
superwin->event_func, superwin->func_data, superwin); */
superwin->shell_func (superwin, xevent, superwin->func_data);
}
return GDK_FILTER_CONTINUE;
}
void
gdk_superwin_clear_translate_queue(GdkSuperWin *superwin, unsigned long serial)
{
GdkSuperWinTranslate *translate;
GList *tmp_list;
GList *link_to_remove = NULL;
if (superwin->translate_queue) {
tmp_list = superwin->translate_queue;
while (tmp_list) {
translate = tmp_list->data;
if (serial == translate->serial) {
g_free (tmp_list->data);
superwin->translate_queue = g_list_remove_link (superwin->translate_queue, tmp_list);
link_to_remove = tmp_list;
}
tmp_list = tmp_list->next;
if (link_to_remove) {
g_list_free_1(link_to_remove);
link_to_remove = NULL;
}
}
}
}

View File

@@ -0,0 +1,93 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "MPL"); you may not use this file except in
* compliance with the MPL. You may obtain a copy of the MPL at
* http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL
* for the specific language governing rights and limitations under the
* MPL.
*
* The Initial Developers of this code under the MPL are Owen Taylor
* <otaylor@redhat.com> and Christopher Blizzard <blizzard@redhat.com>.
* Portions created by the Initial Developers are Copyright (C) 1999
* Owen Taylor and Christopher Blizzard. All Rights Reserved.
*/
#ifndef __GDK_SUPERWIN_H__
#define __GDK_SUPERWIN_H__
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gtk/gtkobject.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _GdkSuperWin GdkSuperWin;
typedef struct _GdkSuperWinClass GdkSuperWinClass;
#define GDK_TYPE_SUPERWIN (gdk_superwin_get_type())
#define GDK_SUPERWIN(obj) (GTK_CHECK_CAST((obj), GDK_TYPE_SUPERWIN, GdkSuperWin))
#define GDK_SUPERWIN_CLASS(klass) (GTK_CHECK_CLASS_CAST((klass), GDK_TYPE_SUPERWIN, GdkSuperWinClass))
#define GDK_IS_SUPERWIN(obj) (GTK_CHECK_TYPE((obj), GDK_TYPE_SUPERWIN))
#define GDK_IS_SUPERWIN_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), GDK_TYPE_SUPERWIN))
typedef void (*GdkSuperWinFunc) (GdkSuperWin *super_win,
XEvent *event,
gpointer data);
struct _GdkSuperWin
{
GtkObject object;
GdkWindow *shell_window;
GdkWindow *bin_window;
/* Private */
GList *translate_queue;
GdkSuperWinFunc shell_func;
GdkSuperWinFunc bin_func;
gpointer func_data;
GDestroyNotify notify;
GdkVisibilityState visibility;
};
struct _GdkSuperWinClass
{
GtkObjectClass object_class;
};
GtkType gdk_superwin_get_type(void);
GdkSuperWin *gdk_superwin_new (GdkWindow *parent_window,
guint x,
guint y,
guint width,
guint height);
void
gdk_superwin_set_event_funcs (GdkSuperWin *superwin,
GdkSuperWinFunc shell_func,
GdkSuperWinFunc bin_func,
gpointer func_data,
GDestroyNotify notify);
void gdk_superwin_scroll (GdkSuperWin *superwin,
gint dx,
gint dy);
void gdk_superwin_resize (GdkSuperWin *superwin,
gint width,
gint height);
void gdk_superwin_destroy(GdkSuperWin *superwin);
void gdk_superwin_clear_translate_queue(GdkSuperWin *superwin,
unsigned long serial);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _GDK_SUPERWIN_H__ */

View File

@@ -0,0 +1,110 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "MPL"); you may not use this file except in
* compliance with the MPL. You may obtain a copy of the MPL at
* http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL
* for the specific language governing rights and limitations under the
* MPL.
*
* The Initial Developers of this code under the MPL are Owen Taylor
* <otaylor@redhat.com> and Christopher Blizzard <blizzard@redhat.com>.
* Portions created by the Initial Developers are Copyright (C) 1999
* Owen Taylor and Christopher Blizzard. All Rights Reserved.
*/
#include "gtkmozarea.h"
#include <X11/Xlib.h>
static void gtk_mozarea_class_init (GtkMozAreaClass *klass);
static void gtk_mozarea_init (GtkMozArea *mozarea);
static void gtk_mozarea_realize (GtkWidget *widget);
static void gtk_mozarea_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
GtkType
gtk_mozarea_get_type (void)
{
static GtkType mozarea_type = 0;
if (!mozarea_type)
{
static const GtkTypeInfo mozarea_info =
{
"GtkMozArea",
sizeof (GtkMozArea),
sizeof (GtkMozAreaClass),
(GtkClassInitFunc) gtk_mozarea_class_init,
(GtkObjectInitFunc) gtk_mozarea_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
mozarea_type = gtk_type_unique (GTK_TYPE_WIDGET, &mozarea_info);
}
return mozarea_type;
}
static void
gtk_mozarea_class_init (GtkMozAreaClass *klass)
{
GtkWidgetClass *widget_class;
widget_class = GTK_WIDGET_CLASS (klass);
widget_class->realize = gtk_mozarea_realize;
widget_class->size_allocate = gtk_mozarea_size_allocate;
}
static void
gtk_mozarea_init (GtkMozArea *mozarea)
{
mozarea->superwin = NULL;
}
static void
gtk_mozarea_realize (GtkWidget *widget)
{
GtkMozArea *mozarea;
g_return_if_fail (GTK_IS_MOZAREA (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
mozarea = GTK_MOZAREA (widget);
mozarea->superwin = gdk_superwin_new (gtk_widget_get_parent_window (widget),
widget->allocation.x, widget->allocation.y,
widget->allocation.width, widget->allocation.height);
gdk_window_set_user_data (mozarea->superwin->shell_window, mozarea);
widget->window = mozarea->superwin->shell_window;
}
static void
gtk_mozarea_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkMozArea *mozarea;
g_return_if_fail (GTK_IS_MOZAREA (widget));
mozarea = GTK_MOZAREA (widget);
if (GTK_WIDGET_REALIZED (widget))
{
gdk_window_move (mozarea->superwin->shell_window,
allocation->x, allocation->y);
gdk_superwin_resize (mozarea->superwin,
allocation->width, allocation->height);
}
}
GtkWidget*
gtk_mozarea_new (GdkWindow *parent_window)
{
return GTK_WIDGET (gtk_type_new (GTK_TYPE_MOZAREA));
}

View File

@@ -0,0 +1,56 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "MPL"); you may not use this file except in
* compliance with the MPL. You may obtain a copy of the MPL at
* http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL
* for the specific language governing rights and limitations under the
* MPL.
*
* The Initial Developers of this code under the MPL are Owen Taylor
* <otaylor@redhat.com> and Christopher Blizzard <blizzard@redhat.com>.
* Portions created by the Initial Developers are Copyright (C) 1999
* Owen Taylor and Christopher Blizzard. All Rights Reserved.
*/
#ifndef __GTK_MOZAREA_H__
#define __GTK_MOZAREA_H__
#include <gtk/gtkwindow.h>
#include "gdksuperwin.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _GtkMozArea GtkMozArea;
typedef struct _GtkMozAreaClass GtkMozAreaClass;
#define GTK_TYPE_MOZAREA (gtk_mozarea_get_type ())
#define GTK_MOZAREA(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_MOZAREA, GtkMozArea))
#define GTK_MOZAREA_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MOZAREA, GtkMozAreaClass))
#define GTK_IS_MOZAREA(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_MOZAREA))
#define GTK_IS_MOZAREA_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MOZAREA))
struct _GtkMozArea
{
GtkWidget widget;
GdkSuperWin *superwin;
};
struct _GtkMozAreaClass
{
GtkWindowClass window_class;
};
GtkType gtk_mozarea_get_type (void);
GtkWidget *gtk_mozarea_new ();
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GTK_MOZAREA_H__ */

View File

@@ -0,0 +1,155 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "MPL"); you may not use this file except in
* compliance with the MPL. You may obtain a copy of the MPL at
* http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL
* for the specific language governing rights and limitations under the
* MPL.
*
* The Initial Developers of this code under the MPL are Owen Taylor
* <otaylor@redhat.com> and Christopher Blizzard <blizzard@redhat.com>.
* Portions created by the Initial Developers are Copyright (C) 1999
* Owen Taylor and Christopher Blizzard. All Rights Reserved.
*/
#include "gtkmozbox.h"
#include <X11/Xlib.h>
static void gtk_mozbox_class_init (GtkMozBoxClass *klass);
static void gtk_mozbox_init (GtkMozBox *mozbox);
static void gtk_mozbox_realize (GtkWidget *widget);
static GdkFilterReturn gtk_mozbox_filter (GdkXEvent *xevent,
GdkEvent *event,
gpointer data);
GtkType
gtk_mozbox_get_type (void)
{
static GtkType mozbox_type = 0;
if (!mozbox_type)
{
static const GtkTypeInfo mozbox_info =
{
"GtkMozBox",
sizeof (GtkMozBox),
sizeof (GtkMozBoxClass),
(GtkClassInitFunc) gtk_mozbox_class_init,
(GtkObjectInitFunc) gtk_mozbox_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
mozbox_type = gtk_type_unique (GTK_TYPE_WINDOW, &mozbox_info);
}
return mozbox_type;
}
static void
gtk_mozbox_class_init (GtkMozBoxClass *klass)
{
GtkWidgetClass *widget_class;
widget_class = GTK_WIDGET_CLASS (klass);
widget_class->realize = gtk_mozbox_realize;
}
static void
gtk_mozbox_init (GtkMozBox *mozbox)
{
mozbox->parent_window = NULL;
mozbox->x = 0;
mozbox->y = 0;
}
static void
gtk_mozbox_realize (GtkWidget *widget)
{
GdkWindowAttr attributes;
gint attributes_mask;
GtkMozBox *mozbox;
g_return_if_fail (GTK_IS_MOZBOX (widget));
mozbox = GTK_MOZBOX (widget);
/* GtkWindow checks against premature realization here. Just
* don't do it.
*/
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = mozbox->x;
attributes.y = mozbox->y;
attributes.width = widget->allocation.width;
attributes.height = widget->allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= GDK_EXPOSURE_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
widget->window = gdk_window_new (mozbox->parent_window,
&attributes, attributes_mask);
gdk_window_set_user_data (widget->window, mozbox);
widget->style = gtk_style_attach (widget->style, widget->window);
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
gdk_window_add_filter (widget->window, gtk_mozbox_filter, mozbox);
}
static GdkFilterReturn
gtk_mozbox_filter (GdkXEvent *xevent,
GdkEvent *event,
gpointer data)
{
XEvent *xev = xevent;
GtkWidget *widget = data;
switch (xev->xany.type)
{
case ConfigureNotify:
event->configure.type = GDK_CONFIGURE;
event->configure.window = widget->window;
event->configure.x = 0;
event->configure.y = 0;
event->configure.width = xev->xconfigure.width;
event->configure.height = xev->xconfigure.height;
return GDK_FILTER_TRANSLATE;
default:
return GDK_FILTER_CONTINUE;
}
}
GtkWidget*
gtk_mozbox_new (GdkWindow *parent_window)
{
GtkMozBox *mozbox;
mozbox = gtk_type_new (GTK_TYPE_MOZBOX);
mozbox->parent_window = parent_window;
return GTK_WIDGET (mozbox);
}
void
gtk_mozbox_set_position (GtkMozBox *mozbox,
gint x,
gint y)
{
mozbox->x = x;
mozbox->y = y;
if (GTK_WIDGET_REALIZED (mozbox))
gdk_window_move (GTK_WIDGET (mozbox)->window, x, y);
}

View File

@@ -0,0 +1,60 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "MPL"); you may not use this file except in
* compliance with the MPL. You may obtain a copy of the MPL at
* http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL
* for the specific language governing rights and limitations under the
* MPL.
*
* The Initial Developers of this code under the MPL are Owen Taylor
* <otaylor@redhat.com> and Christopher Blizzard <blizzard@redhat.com>.
* Portions created by the Initial Developers are Copyright (C) 1999
* Owen Taylor and Christopher Blizzard. All Rights Reserved.
*/
#ifndef __GTK_MOZBOX_H__
#define __GTK_MOZBOX_H__
#include <gtk/gtkwindow.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _GtkMozBox GtkMozBox;
typedef struct _GtkMozBoxClass GtkMozBoxClass;
#define GTK_TYPE_MOZBOX (gtk_mozbox_get_type ())
#define GTK_MOZBOX(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_MOZBOX, GtkMozBox))
#define GTK_MOZBOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MOZBOX, GtkMozBoxClass))
#define GTK_IS_MOZBOX(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_MOZBOX))
#define GTK_IS_MOZBOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MOZBOX))
struct _GtkMozBox
{
GtkWindow window;
GdkWindow *parent_window;
gint x;
gint y;
};
struct _GtkMozBoxClass
{
GtkWindowClass window_class;
};
GtkType gtk_mozbox_get_type (void);
GtkWidget *gtk_mozbox_new (GdkWindow *parent_window);
void gtk_mozbox_set_position (GtkMozBox *mozbox,
gint x,
gint y);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GTK_MOZBOX_H__ */