b=506433 replace mozDrawingarea with a single GdkWindow. r=roc

--HG--
extra : rebase_source : 02003e8745f8602d1620b7a477100e0e8be1c434
This commit is contained in:
Karl Tomlinson 2009-07-27 13:39:36 +12:00
Родитель 360519bc23
Коммит ed9615bf41
5 изменённых файлов: 163 добавлений и 526 удалений

Просмотреть файл

@ -78,7 +78,6 @@ endif
CSRCS = \ CSRCS = \
mozcontainer.c \ mozcontainer.c \
mozdrawingarea.c \
keysym2ucs.c \ keysym2ucs.c \
$(NULL) $(NULL)
@ -159,7 +158,6 @@ endif
EXPORTS = \ EXPORTS = \
nsGTKToolkit.h \ nsGTKToolkit.h \
nsIImageToPixbuf.h \ nsIImageToPixbuf.h \
mozdrawingarea.h \
mozcontainer.h \ mozcontainer.h \
$(NULL) $(NULL)

Просмотреть файл

@ -1,241 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Christopher Blizzard
* <blizzard@mozilla.org>. Portions created by the Initial Developer
* are Copyright (C) 2001 the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "mozdrawingarea.h"
/* init methods */
static void moz_drawingarea_class_init (MozDrawingareaClass *klass);
static void moz_drawingarea_init (MozDrawingarea *drawingarea);
/* static methods */
static void moz_drawingarea_create_windows (MozDrawingarea *drawingarea,
GdkWindow *parent,
GtkWidget *widget,
GdkVisual *visual);
static void moz_drawingarea_finalize (GObject *object);
static GObjectClass *parent_class = NULL;
GType
moz_drawingarea_get_type(void)
{
static GType moz_drawingarea_type = 0;
if (!moz_drawingarea_type) {
static GTypeInfo moz_drawingarea_info = {
sizeof(MozDrawingareaClass), /* class size */
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) moz_drawingarea_class_init, /* class_init */
NULL, /* class_destroy */
NULL, /* class_data */
sizeof(MozDrawingarea), /* instance_size */
0, /* n_preallocs */
(GInstanceInitFunc) moz_drawingarea_init, /* instance_init */
NULL, /* value_table */
};
moz_drawingarea_type =
g_type_register_static (G_TYPE_OBJECT,
"MozDrawingarea",
&moz_drawingarea_info, 0);
}
return moz_drawingarea_type;
}
MozDrawingarea *
moz_drawingarea_new (MozDrawingarea *parent, MozContainer *widget_parent,
GdkVisual *visual)
{
MozDrawingarea *drawingarea;
drawingarea = g_object_new(MOZ_DRAWINGAREA_TYPE, NULL);
if (!parent)
moz_drawingarea_create_windows(drawingarea,
GTK_WIDGET(widget_parent)->window,
GTK_WIDGET(widget_parent),
visual);
else
moz_drawingarea_create_windows(drawingarea,
parent->inner_window,
GTK_WIDGET(widget_parent),
visual);
return drawingarea;
}
void
moz_drawingarea_class_init (MozDrawingareaClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = moz_drawingarea_finalize;
parent_class = g_type_class_peek_parent(klass);
}
void
moz_drawingarea_init (MozDrawingarea *drawingarea)
{
}
void
moz_drawingarea_reparent (MozDrawingarea *drawingarea, GdkWindow *aNewParent)
{
gdk_window_reparent(drawingarea->clip_window,
aNewParent, 0, 0);
}
void
moz_drawingarea_create_windows (MozDrawingarea *drawingarea, GdkWindow *parent,
GtkWidget *widget, GdkVisual *visual)
{
GdkWindowAttr attributes;
gint attributes_mask = 0;
/* create the clipping window */
attributes.event_mask = 0;
attributes.x = 0;
attributes.y = 0;
attributes.width = 1;
attributes.height = 1;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.window_type = GDK_WINDOW_CHILD;
if (!visual) {
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
} else {
attributes.visual = visual;
attributes.colormap = gdk_colormap_new(visual, 0);
}
attributes_mask |= GDK_WA_VISUAL | GDK_WA_COLORMAP |
GDK_WA_X | GDK_WA_Y;
drawingarea->clip_window = gdk_window_new (parent, &attributes,
attributes_mask);
gdk_window_set_user_data(drawingarea->clip_window, widget);
/* set the default pixmap to None so that you don't end up with the
gtk default which is BlackPixel. */
gdk_window_set_back_pixmap(drawingarea->clip_window, NULL, FALSE);
attributes.event_mask = (GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK |
GDK_VISIBILITY_NOTIFY_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
#ifdef HAVE_GTK_MOTION_HINTS
GDK_POINTER_MOTION_HINT_MASK |
#endif
GDK_POINTER_MOTION_MASK);
/* create the inner window */
drawingarea->inner_window = gdk_window_new (drawingarea->clip_window,
&attributes, attributes_mask);
gdk_window_set_user_data(drawingarea->inner_window, widget);
/* set the default pixmap to None so that you don't end up with the
gtk default which is BlackPixel. */
gdk_window_set_back_pixmap(drawingarea->inner_window, NULL, FALSE);
if (visual) {
g_object_unref(attributes.colormap);
}
}
void
moz_drawingarea_finalize (GObject *object)
{
MozDrawingarea *drawingarea;
gpointer user_data;
g_return_if_fail(IS_MOZ_DRAWINGAREA(object));
drawingarea = MOZ_DRAWINGAREA(object);
gdk_window_destroy(drawingarea->inner_window);
gdk_window_destroy(drawingarea->clip_window);
(* parent_class->finalize) (object);
}
void
moz_drawingarea_move (MozDrawingarea *drawingarea,
gint x, gint y)
{
gdk_window_move(drawingarea->clip_window, x, y);
}
void
moz_drawingarea_resize (MozDrawingarea *drawingarea,
gint width, gint height)
{
gdk_window_resize(drawingarea->clip_window, width, height);
gdk_window_resize(drawingarea->inner_window, width, height);
}
void
moz_drawingarea_move_resize (MozDrawingarea *drawingarea,
gint x, gint y, gint width, gint height)
{
gdk_window_resize(drawingarea->inner_window, width, height);
gdk_window_move_resize(drawingarea->clip_window, x, y, width, height);
}
void
moz_drawingarea_set_visibility (MozDrawingarea *drawingarea,
gboolean visibility)
{
if (visibility) {
gdk_window_show_unraised(drawingarea->inner_window);
gdk_window_show_unraised(drawingarea->clip_window);
}
else {
gdk_window_hide(drawingarea->clip_window);
gdk_window_hide(drawingarea->inner_window);
}
}
void
moz_drawingarea_scroll (MozDrawingarea *drawingarea,
gint x, gint y)
{
gdk_window_scroll(drawingarea->inner_window, x, y);
}

Просмотреть файл

@ -1,101 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 Christopher Blizzard
* <blizzard@mozilla.org>. Portions created by the Initial Developer
* are Copyright (C) 2001 the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __MOZ_DRAWINGAREA_H__
#define __MOZ_DRAWINGAREA_H__
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#include "mozcontainer.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#define MOZ_DRAWINGAREA_TYPE (moz_drawingarea_get_type())
#define MOZ_DRAWINGAREA(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), MOZ_DRAWINGAREA_TYPE, MozDrawingarea))
#define MOZ_DRAWINGAREA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), MOZ_DRAWINGAREA_TYPE, MozDrawingareaClass))
#define IS_MOZ_DRAWINGAREA(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), MOZ_DRAWINGAREA_TYPE))
#define IS_MOZ_DRAWINGAREA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), MOZ_DRAWINGAREA_TYPE))
#define MOZ_DRAWINGAREA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), MOZ_DRAWINGAREA_TYPE, MozDrawingareaClass))
#if (GTK_CHECK_VERSION(2, 12, 0) || \
(GTK_CHECK_VERSION(2, 10, 0) && defined(MOZ_PLATFORM_HILDON)))
#define HAVE_GTK_MOTION_HINTS
#endif
typedef struct _MozDrawingarea MozDrawingarea;
typedef struct _MozDrawingareaClass MozDrawingareaClass;
struct _MozDrawingarea
{
GObject parent_instance;
/* AFAIK this clip_window (and thus this whole class) exists solely to
* make gdk_window_scroll() smooth for nsIWidget::Scroll(). */
GdkWindow *clip_window;
GdkWindow *inner_window;
};
struct _MozDrawingareaClass
{
GObjectClass parent_class;
};
GType moz_drawingarea_get_type (void);
MozDrawingarea *moz_drawingarea_new (MozDrawingarea *parent,
MozContainer *widget_parent,
GdkVisual *visual);
void moz_drawingarea_reparent (MozDrawingarea *drawingarea,
GdkWindow *aNewParent);
void moz_drawingarea_move (MozDrawingarea *drawingarea,
gint x, gint y);
void moz_drawingarea_resize (MozDrawingarea *drawingarea,
gint width, gint height);
void moz_drawingarea_move_resize (MozDrawingarea *drawingarea,
gint x, gint y,
gint width, gint height);
void moz_drawingarea_set_visibility (MozDrawingarea *drawingarea,
gboolean visibility);
void moz_drawingarea_scroll (MozDrawingarea *drawingarea,
gint x, gint y);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __MOZ_DRAWINGAREA_H__ */

Просмотреть файл

@ -141,6 +141,11 @@ D_DEBUG_DOMAIN( ns_Window, "nsWindow", "nsWindow" );
#define D_DEBUG_AT(x,y...) do {} while (0) #define D_DEBUG_AT(x,y...) do {} while (0)
#endif #endif
#if (GTK_CHECK_VERSION(2, 12, 0) || \
(GTK_CHECK_VERSION(2, 10, 0) && defined(MOZ_PLATFORM_HILDON)))
#define HAVE_GTK_MOTION_HINTS
#endif
// Don't put more than this many rects in the dirty region, just fluff // Don't put more than this many rects in the dirty region, just fluff
// out to the bounding-box if there are more // out to the bounding-box if there are more
#define MAX_RECTS_IN_REGION 100 #define MAX_RECTS_IN_REGION 100
@ -371,7 +376,7 @@ nsWindow::nsWindow()
mPlaced = PR_FALSE; mPlaced = PR_FALSE;
mContainer = nsnull; mContainer = nsnull;
mDrawingarea = nsnull; mGdkWindow = nsnull;
mShell = nsnull; mShell = nsnull;
mWindowGroup = nsnull; mWindowGroup = nsnull;
mContainerGotFocus = PR_FALSE; mContainerGotFocus = PR_FALSE;
@ -802,25 +807,17 @@ nsWindow::Destroy(void)
// widget while the GdkWindow hierarchy is still available. // widget while the GdkWindow hierarchy is still available.
// (OnContainerUnrealize does this when the MozContainer widget is // (OnContainerUnrealize does this when the MozContainer widget is
// destroyed.) // destroyed.)
SetWidgetForHierarchy(mDrawingarea->clip_window, owningWidget, NULL); SetWidgetForHierarchy(mGdkWindow, owningWidget, NULL);
} }
if (mDrawingarea) { if (mGdkWindow) {
g_object_set_data(G_OBJECT(mDrawingarea->clip_window), g_object_set_data(G_OBJECT(mGdkWindow), "nsWindow", NULL);
"nsWindow", NULL);
g_object_set_data(G_OBJECT(mDrawingarea->inner_window),
"nsWindow", NULL);
g_object_set_data(G_OBJECT(mDrawingarea->clip_window), NS_ASSERTION(!get_gtk_widget_for_gdk_window(mGdkWindow),
"mozdrawingarea", NULL);
g_object_set_data(G_OBJECT(mDrawingarea->inner_window),
"mozdrawingarea", NULL);
NS_ASSERTION(!get_gtk_widget_for_gdk_window(mDrawingarea->inner_window),
"widget reference not removed"); "widget reference not removed");
g_object_unref(mDrawingarea); gdk_window_destroy(mGdkWindow);
mDrawingarea = nsnull; mGdkWindow = nsnull;
} }
if (gInvisibleContainer && owningWidget == gInvisibleContainer) { if (gInvisibleContainer && owningWidget == gInvisibleContainer) {
@ -847,7 +844,7 @@ nsWindow::GetParent(void)
NS_IMETHODIMP NS_IMETHODIMP
nsWindow::SetParent(nsIWidget *aNewParent) nsWindow::SetParent(nsIWidget *aNewParent)
{ {
if (mContainer || !mDrawingarea || !mParent) { if (mContainer || !mGdkWindow || !mParent) {
NS_NOTREACHED("nsWindow::SetParent - reparenting a non-child window"); NS_NOTREACHED("nsWindow::SetParent - reparenting a non-child window");
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
@ -862,12 +859,12 @@ nsWindow::SetParent(nsIWidget *aNewParent)
if (!oldContainer) { if (!oldContainer) {
// The GdkWindows have been destroyed so there is nothing else to // The GdkWindows have been destroyed so there is nothing else to
// reparent. // reparent.
NS_ABORT_IF_FALSE(GDK_WINDOW_OBJECT(mDrawingarea->inner_window)->destroyed, NS_ABORT_IF_FALSE(GDK_WINDOW_OBJECT(mGdkWindow)->destroyed,
"live GdkWindow with no widget"); "live GdkWindow with no widget");
return NS_OK; return NS_OK;
} }
NS_ABORT_IF_FALSE(!GDK_WINDOW_OBJECT(mDrawingarea->inner_window)->destroyed, NS_ABORT_IF_FALSE(!GDK_WINDOW_OBJECT(mGdkWindow)->destroyed,
"destroyed GdkWindow with widget"); "destroyed GdkWindow with widget");
GdkWindow* newParentWindow = NULL; GdkWindow* newParentWindow = NULL;
@ -897,11 +894,10 @@ nsWindow::SetParent(nsIWidget *aNewParent)
if (newContainer != oldContainer) { if (newContainer != oldContainer) {
NS_ABORT_IF_FALSE(!GDK_WINDOW_OBJECT(newParentWindow)->destroyed, NS_ABORT_IF_FALSE(!GDK_WINDOW_OBJECT(newParentWindow)->destroyed,
"destroyed GdkWindow with widget"); "destroyed GdkWindow with widget");
SetWidgetForHierarchy(mDrawingarea->clip_window, oldContainer, SetWidgetForHierarchy(mGdkWindow, oldContainer, newContainer);
newContainer);
} }
moz_drawingarea_reparent(mDrawingarea, newParentWindow); gdk_window_reparent(mGdkWindow, newParentWindow, 0, 0);
} }
return NS_OK; return NS_OK;
@ -1218,8 +1214,8 @@ nsWindow::Move(PRInt32 aX, PRInt32 aY)
if (mIsTopLevel) { if (mIsTopLevel) {
gtk_window_move(GTK_WINDOW(mShell), aX, aY); gtk_window_move(GTK_WINDOW(mShell), aX, aY);
} }
else if (mDrawingarea) { else if (mGdkWindow) {
moz_drawingarea_move(mDrawingarea, aX, aY); gdk_window_move(mGdkWindow, aX, aY);
} }
return NS_OK; return NS_OK;
@ -1246,19 +1242,19 @@ nsWindow::SetZIndex(PRInt32 aZIndex)
NS_ASSERTION(!mContainer, "Expected Mozilla child widget"); NS_ASSERTION(!mContainer, "Expected Mozilla child widget");
// We skip the nsWindows that don't have mDrawingareas. // We skip the nsWindows that don't have mGdkWindows.
// These are probably in the process of being destroyed. // These are probably in the process of being destroyed.
if (!GetNextSibling()) { if (!GetNextSibling()) {
// We're to be on top. // We're to be on top.
if (mDrawingarea) if (mGdkWindow)
gdk_window_raise(mDrawingarea->clip_window); gdk_window_raise(mGdkWindow);
} else { } else {
// All the siblings before us need to be below our widget. // All the siblings before us need to be below our widget.
for (nsWindow* w = this; w; for (nsWindow* w = this; w;
w = static_cast<nsWindow*>(w->GetPrevSibling())) { w = static_cast<nsWindow*>(w->GetPrevSibling())) {
if (w->mDrawingarea) if (w->mGdkWindow)
gdk_window_lower(w->mDrawingarea->clip_window); gdk_window_lower(w->mGdkWindow);
} }
} }
return NS_OK; return NS_OK;
@ -1480,7 +1476,7 @@ nsWindow::SetCursor(nsCursor aCursor)
{ {
// if we're not the toplevel window pass up the cursor request to // if we're not the toplevel window pass up the cursor request to
// the toplevel window to handle it. // the toplevel window to handle it.
if (!mContainer && mDrawingarea) { if (!mContainer && mGdkWindow) {
nsWindow *window = GetContainerWindow(); nsWindow *window = GetContainerWindow();
if (!window) if (!window)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -1563,7 +1559,7 @@ nsWindow::SetCursor(imgIContainer* aCursor,
{ {
// if we're not the toplevel window pass up the cursor request to // if we're not the toplevel window pass up the cursor request to
// the toplevel window to handle it. // the toplevel window to handle it.
if (!mContainer && mDrawingarea) { if (!mContainer && mGdkWindow) {
nsWindow *window = GetContainerWindow(); nsWindow *window = GetContainerWindow();
if (!window) if (!window)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
@ -1681,10 +1677,10 @@ nsWindow::Validate()
{ {
// Get the update for this window and, well, just drop it on the // Get the update for this window and, well, just drop it on the
// floor. // floor.
if (!mDrawingarea) if (!mGdkWindow)
return NS_OK; return NS_OK;
GdkRegion *region = gdk_window_get_update_area(mDrawingarea->inner_window); GdkRegion *region = gdk_window_get_update_area(mGdkWindow);
if (region) if (region)
gdk_region_destroy(region); gdk_region_destroy(region);
@ -1695,7 +1691,7 @@ nsWindow::Validate()
NS_IMETHODIMP NS_IMETHODIMP
nsWindow::Invalidate(PRBool aIsSynchronous) nsWindow::Invalidate(PRBool aIsSynchronous)
{ {
if (!mDrawingarea || !CanBeSeen()) if (!mGdkWindow || !CanBeSeen())
return NS_OK; return NS_OK;
GdkRectangle rect; GdkRectangle rect;
@ -1707,10 +1703,9 @@ nsWindow::Invalidate(PRBool aIsSynchronous)
LOGDRAW(("Invalidate (all) [%p]: %d %d %d %d\n", (void *)this, LOGDRAW(("Invalidate (all) [%p]: %d %d %d %d\n", (void *)this,
rect.x, rect.y, rect.width, rect.height)); rect.x, rect.y, rect.width, rect.height));
gdk_window_invalidate_rect(mDrawingarea->inner_window, gdk_window_invalidate_rect(mGdkWindow, &rect, FALSE);
&rect, FALSE);
if (aIsSynchronous) if (aIsSynchronous)
gdk_window_process_updates(mDrawingarea->inner_window, FALSE); gdk_window_process_updates(mGdkWindow, FALSE);
return NS_OK; return NS_OK;
} }
@ -1719,7 +1714,7 @@ NS_IMETHODIMP
nsWindow::Invalidate(const nsIntRect &aRect, nsWindow::Invalidate(const nsIntRect &aRect,
PRBool aIsSynchronous) PRBool aIsSynchronous)
{ {
if (!mDrawingarea || !CanBeSeen()) if (!mGdkWindow || !CanBeSeen())
return NS_OK; return NS_OK;
GdkRectangle rect; GdkRectangle rect;
@ -1731,10 +1726,9 @@ nsWindow::Invalidate(const nsIntRect &aRect,
LOGDRAW(("Invalidate (rect) [%p]: %d %d %d %d (sync: %d)\n", (void *)this, LOGDRAW(("Invalidate (rect) [%p]: %d %d %d %d (sync: %d)\n", (void *)this,
rect.x, rect.y, rect.width, rect.height, aIsSynchronous)); rect.x, rect.y, rect.width, rect.height, aIsSynchronous));
gdk_window_invalidate_rect(mDrawingarea->inner_window, gdk_window_invalidate_rect(mGdkWindow, &rect, FALSE);
&rect, FALSE);
if (aIsSynchronous) if (aIsSynchronous)
gdk_window_process_updates(mDrawingarea->inner_window, FALSE); gdk_window_process_updates(mGdkWindow, FALSE);
return NS_OK; return NS_OK;
} }
@ -1742,10 +1736,10 @@ nsWindow::Invalidate(const nsIntRect &aRect,
NS_IMETHODIMP NS_IMETHODIMP
nsWindow::Update() nsWindow::Update()
{ {
if (!mDrawingarea) if (!mGdkWindow)
return NS_OK; return NS_OK;
gdk_window_process_updates(mDrawingarea->inner_window, FALSE); gdk_window_process_updates(mGdkWindow, FALSE);
return NS_OK; return NS_OK;
} }
@ -1753,7 +1747,7 @@ void
nsWindow::Scroll(const nsIntPoint& aDelta, const nsIntRect& aSource, nsWindow::Scroll(const nsIntPoint& aDelta, const nsIntRect& aSource,
const nsTArray<Configuration>& aConfigurations) const nsTArray<Configuration>& aConfigurations)
{ {
if (!mDrawingarea) { if (!mGdkWindow) {
NS_ERROR("Cannot scroll widget"); NS_ERROR("Cannot scroll widget");
return; return;
} }
@ -1780,8 +1774,7 @@ nsWindow::Scroll(const nsIntPoint& aDelta, const nsIntRect& aSource,
GdkRectangle gdkSource = GdkRectangle gdkSource =
{ aSource.x, aSource.y, aSource.width, aSource.height }; { aSource.x, aSource.y, aSource.width, aSource.height };
GdkRegion* region = gdk_region_rectangle(&gdkSource); GdkRegion* region = gdk_region_rectangle(&gdkSource);
gdk_window_move_region(GDK_WINDOW(mDrawingarea->inner_window), gdk_window_move_region(GDK_WINDOW(mGdkWindow), region, aDelta.x, aDelta.y);
region, aDelta.x, aDelta.y);
gdk_region_destroy(region); gdk_region_destroy(region);
ConfigureChildren(aConfigurations); ConfigureChildren(aConfigurations);
@ -1797,10 +1790,10 @@ nsWindow::GetNativeData(PRUint32 aDataType)
switch (aDataType) { switch (aDataType) {
case NS_NATIVE_WINDOW: case NS_NATIVE_WINDOW:
case NS_NATIVE_WIDGET: { case NS_NATIVE_WIDGET: {
if (!mDrawingarea) if (!mGdkWindow)
return nsnull; return nsnull;
return mDrawingarea->inner_window; return mGdkWindow;
break; break;
} }
@ -1908,8 +1901,8 @@ nsWindow::WidgetToScreenOffset()
&x, &y); &x, &y);
LOG(("WidgetToScreenOffset (container) %d %d\n", x, y)); LOG(("WidgetToScreenOffset (container) %d %d\n", x, y));
} }
else if (mDrawingarea) { else if (mGdkWindow) {
gdk_window_get_origin(mDrawingarea->inner_window, &x, &y); gdk_window_get_origin(mGdkWindow, &x, &y);
LOG(("WidgetToScreenOffset (drawing) %d %d\n", x, y)); LOG(("WidgetToScreenOffset (drawing) %d %d\n", x, y));
} }
@ -1950,7 +1943,7 @@ nsWindow::CaptureMouse(PRBool aCapture)
{ {
LOG(("CaptureMouse %p\n", (void *)this)); LOG(("CaptureMouse %p\n", (void *)this));
if (!mDrawingarea) if (!mGdkWindow)
return NS_OK; return NS_OK;
GtkWidget *widget = GetMozContainerWidget(); GtkWidget *widget = GetMozContainerWidget();
@ -1974,7 +1967,7 @@ nsWindow::CaptureRollupEvents(nsIRollupListener *aListener,
PRBool aDoCapture, PRBool aDoCapture,
PRBool aConsumeRollupEvent) PRBool aConsumeRollupEvent)
{ {
if (!mDrawingarea) if (!mGdkWindow)
return NS_OK; return NS_OK;
GtkWidget *widget = GetMozContainerWidget(); GtkWidget *widget = GetMozContainerWidget();
@ -2143,11 +2136,7 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent)
return FALSE; return FALSE;
} }
if (!mDrawingarea) if (!mGdkWindow)
return FALSE;
// handle exposes for the inner window only
if (aEvent->window != mDrawingarea->inner_window)
return FALSE; return FALSE;
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID); static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
@ -2184,7 +2173,7 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent)
PRBool translucent = eTransparencyTransparent == GetTransparencyMode(); PRBool translucent = eTransparencyTransparent == GetTransparencyMode();
if (!translucent) { if (!translucent) {
GList *children = GList *children =
gdk_window_peek_children(mDrawingarea->inner_window); gdk_window_peek_children(mGdkWindow);
while (children) { while (children) {
GdkWindow *gdkWin = GDK_WINDOW(children->data); GdkWindow *gdkWin = GDK_WINDOW(children->data);
nsWindow *kid = get_window_for_gdk_window(gdkWin); nsWindow *kid = get_window_for_gdk_window(gdkWin);
@ -2218,7 +2207,7 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent)
nsRefPtr<gfxContext> ctx = rc->ThebesContext(); nsRefPtr<gfxContext> ctx = rc->ThebesContext();
gfxPlatformGtk::GetPlatform()->SetGdkDrawable(ctx->OriginalSurface(), gfxPlatformGtk::GetPlatform()->SetGdkDrawable(ctx->OriginalSurface(),
GDK_DRAWABLE(mDrawingarea->inner_window)); GDK_DRAWABLE(mGdkWindow));
// clip to the update region // clip to the update region
ctx->Save(); ctx->Save();
@ -2277,7 +2266,7 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent)
if (gForce24bpp) { if (gForce24bpp) {
depth = 24; // 24 always depth = 24; // 24 always
} else { } else {
depth = gdk_drawable_get_depth(GDK_DRAWABLE(mDrawingarea->inner_window)); depth = gdk_drawable_get_depth(GDK_DRAWABLE(mGdkWindow));
} }
// Make sure we won't create something that will overload the X server // Make sure we won't create something that will overload the X server
@ -2291,7 +2280,7 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent)
{ {
// create a one-off always if we're not using the global pixmap // create a one-off always if we're not using the global pixmap
// if gUseBufferPixmap == TRUE, who's redrawing an area bigger than the screen? // if gUseBufferPixmap == TRUE, who's redrawing an area bigger than the screen?
bufferPixmap = gdk_pixmap_new(GDK_DRAWABLE(mDrawingarea->inner_window), bufferPixmap = gdk_pixmap_new(GDK_DRAWABLE(mGdkWindow),
boundsRect.width, boundsRect.height, boundsRect.width, boundsRect.height,
depth); depth);
bufferPixmapSize.width = boundsRect.width; bufferPixmapSize.width = boundsRect.width;
@ -2306,7 +2295,7 @@ nsWindow::OnExposeEvent(GtkWidget *aWidget, GdkEventExpose *aEvent)
gBufferPixmapSize.width = PR_MAX(gBufferPixmapSize.width, boundsRect.width); gBufferPixmapSize.width = PR_MAX(gBufferPixmapSize.width, boundsRect.width);
gBufferPixmapSize.height = PR_MAX(gBufferPixmapSize.height, boundsRect.height); gBufferPixmapSize.height = PR_MAX(gBufferPixmapSize.height, boundsRect.height);
gBufferPixmap = gdk_pixmap_new(GDK_DRAWABLE(mDrawingarea->inner_window), gBufferPixmap = gdk_pixmap_new(GDK_DRAWABLE(mGdkWindow),
gBufferPixmapSize.width, gBufferPixmapSize.height, gBufferPixmapSize.width, gBufferPixmapSize.height,
depth); depth);
@ -2473,8 +2462,8 @@ nsWindow::OnContainerUnrealize(GtkWidget *aWidget)
NS_ASSERTION(mContainer == MOZ_CONTAINER(aWidget), NS_ASSERTION(mContainer == MOZ_CONTAINER(aWidget),
"unexpected \"unrealize\" signal"); "unexpected \"unrealize\" signal");
if (mDrawingarea) { if (mGdkWindow) {
SetWidgetForHierarchy(mDrawingarea->clip_window, aWidget, NULL); SetWidgetForHierarchy(mGdkWindow, aWidget, NULL);
} }
} }
@ -2493,10 +2482,10 @@ nsWindow::OnSizeAllocate(GtkWidget *aWidget, GtkAllocation *aAllocation)
mBounds.width = rect.width; mBounds.width = rect.width;
mBounds.height = rect.height; mBounds.height = rect.height;
if (!mDrawingarea) if (!mGdkWindow)
return; return;
moz_drawingarea_resize (mDrawingarea, rect.width, rect.height); gdk_window_resize (mGdkWindow, rect.width, rect.height);
if (mTransparencyBitmap) { if (mTransparencyBitmap) {
ApplyTransparencyBitmap(); ApplyTransparencyBitmap();
@ -2566,7 +2555,7 @@ nsWindow::OnLeaveNotifyEvent(GtkWidget *aWidget, GdkEventCrossing *aEvent)
event.time = aEvent->time; event.time = aEvent->time;
event.exit = is_top_level_mouse_exit(mDrawingarea->inner_window, aEvent) event.exit = is_top_level_mouse_exit(mGdkWindow, aEvent)
? nsMouseEvent::eTopLevel : nsMouseEvent::eChild; ? nsMouseEvent::eTopLevel : nsMouseEvent::eChild;
LOG(("OnLeaveNotify: %p\n", (void *)this)); LOG(("OnLeaveNotify: %p\n", (void *)this));
@ -2708,7 +2697,7 @@ nsWindow::OnMotionNotifyEvent(GtkWidget *aWidget, GdkEventMotion *aEvent)
} }
else { else {
// XXX see OnScrollEvent() // XXX see OnScrollEvent()
if (aEvent->window == mDrawingarea->inner_window) { if (aEvent->window == mGdkWindow) {
event.refPoint.x = nscoord(aEvent->x); event.refPoint.x = nscoord(aEvent->x);
event.refPoint.y = nscoord(aEvent->y); event.refPoint.y = nscoord(aEvent->y);
} else { } else {
@ -2736,7 +2725,7 @@ nsWindow::InitButtonEvent(nsMouseEvent &aEvent,
GdkEventButton *aGdkEvent) GdkEventButton *aGdkEvent)
{ {
// XXX see OnScrollEvent() // XXX see OnScrollEvent()
if (aGdkEvent->window == mDrawingarea->inner_window) { if (aGdkEvent->window == mGdkWindow) {
aEvent.refPoint.x = nscoord(aGdkEvent->x); aEvent.refPoint.x = nscoord(aGdkEvent->x);
aEvent.refPoint.y = nscoord(aGdkEvent->y); aEvent.refPoint.y = nscoord(aGdkEvent->y);
} else { } else {
@ -3311,7 +3300,7 @@ nsWindow::OnScrollEvent(GtkWidget *aWidget, GdkEventScroll *aEvent)
break; break;
} }
if (aEvent->window == mDrawingarea->inner_window) { if (aEvent->window == mGdkWindow) {
// we are the window that the event happened on so no need for expensive WidgetToScreenOffset // we are the window that the event happened on so no need for expensive WidgetToScreenOffset
event.refPoint.x = nscoord(aEvent->x); event.refPoint.x = nscoord(aEvent->x);
event.refPoint.y = nscoord(aEvent->y); event.refPoint.y = nscoord(aEvent->y);
@ -3404,12 +3393,12 @@ nsWindow::ThemeChanged()
nsEventStatus status = nsEventStatus_eIgnore; nsEventStatus status = nsEventStatus_eIgnore;
DispatchEvent(&event, status); DispatchEvent(&event, status);
if (!mDrawingarea || NS_UNLIKELY(mIsDestroyed)) if (!mGdkWindow || NS_UNLIKELY(mIsDestroyed))
return; return;
// Dispatch NS_THEMECHANGED to all child windows // Dispatch NS_THEMECHANGED to all child windows
GList *children = GList *children =
gdk_window_peek_children(mDrawingarea->inner_window); gdk_window_peek_children(mGdkWindow);
while (children) { while (children) {
GdkWindow *gdkWin = GDK_WINDOW(children->data); GdkWindow *gdkWin = GDK_WINDOW(children->data);
@ -3762,6 +3751,38 @@ GetBrandName(nsXPIDLString& brandName)
brandName.Assign(NS_LITERAL_STRING("Mozilla")); brandName.Assign(NS_LITERAL_STRING("Mozilla"));
} }
static GdkWindow *
CreateGdkWindow(GdkWindow *parent, GtkWidget *widget)
{
GdkWindowAttr attributes;
gint attributes_mask = GDK_WA_VISUAL | GDK_WA_COLORMAP;
attributes.event_mask = (GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK |
GDK_VISIBILITY_NOTIFY_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
#ifdef HAVE_GTK_MOTION_HINTS
GDK_POINTER_MOTION_HINT_MASK |
#endif
GDK_POINTER_MOTION_MASK);
attributes.width = 1;
attributes.height = 1;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual(widget);
attributes.colormap = gtk_widget_get_colormap(widget);
attributes.window_type = GDK_WINDOW_CHILD;
GdkWindow *window = gdk_window_new(parent, &attributes, attributes_mask);
gdk_window_set_user_data(window, widget);
/* set the default pixmap to None so that you don't end up with the
gtk default which is BlackPixel. */
gdk_window_set_back_pixmap(window, NULL, FALSE);
return window;
}
nsresult nsresult
nsWindow::NativeCreate(nsIWidget *aParent, nsWindow::NativeCreate(nsIWidget *aParent,
nsNativeWidget aNativeParent, nsNativeWidget aNativeParent,
@ -3805,8 +3826,7 @@ nsWindow::NativeCreate(nsIWidget *aParent,
} }
// figure out our parent window // figure out our parent window
MozDrawingarea *parentArea = nsnull; GtkWidget *parentMozContainer = nsnull;
MozContainer *parentMozContainer = nsnull;
GtkContainer *parentGtkContainer = nsnull; GtkContainer *parentGtkContainer = nsnull;
GdkWindow *parentGdkWindow = nsnull; GdkWindow *parentGdkWindow = nsnull;
GtkWindow *topLevelParent = nsnull; GtkWindow *topLevelParent = nsnull;
@ -3819,28 +3839,10 @@ nsWindow::NativeCreate(nsIWidget *aParent,
parentGtkContainer = GTK_CONTAINER(aNativeParent); parentGtkContainer = GTK_CONTAINER(aNativeParent);
if (parentGdkWindow) { if (parentGdkWindow) {
// find the mozarea on that window // get the widget for the window - it should be a moz container
gpointer user_data = nsnull; parentMozContainer = get_gtk_widget_for_gdk_window(parentGdkWindow);
user_data = g_object_get_data(G_OBJECT(parentGdkWindow),
"mozdrawingarea");
parentArea = MOZ_DRAWINGAREA(user_data);
NS_ASSERTION(parentArea, "no drawingarea for parent widget!\n"); if (!IS_MOZ_CONTAINER(parentMozContainer))
if (!parentArea)
return NS_ERROR_FAILURE;
// get the user data for the widget - it should be a container
user_data = nsnull;
gdk_window_get_user_data(parentArea->inner_window, &user_data);
NS_ASSERTION(user_data, "no user data for parentArea\n");
if (!user_data)
return NS_ERROR_FAILURE;
// Get the parent moz container
parentMozContainer = MOZ_CONTAINER(user_data);
NS_ASSERTION(parentMozContainer,
"owning widget is not a mozcontainer!\n");
if (!parentMozContainer)
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
// get the toplevel window just in case someone needs to use it // get the toplevel window just in case someone needs to use it
@ -3849,8 +3851,6 @@ nsWindow::NativeCreate(nsIWidget *aParent,
GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(parentMozContainer))); GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(parentMozContainer)));
} }
GdkVisual* visual = nsnull;
// ok, create our windows // ok, create our windows
switch (mWindowType) { switch (mWindowType) {
case eWindowType_dialog: case eWindowType_dialog:
@ -3878,11 +3878,11 @@ nsWindow::NativeCreate(nsIWidget *aParent,
GdkWindow* dialoglead = mShell->window; GdkWindow* dialoglead = mShell->window;
gdk_window_set_group(dialoglead, dialoglead); gdk_window_set_group(dialoglead, dialoglead);
} }
if (parentArea) { if (parentGdkWindow) {
nsWindow *parentnsWindow = nsWindow *parentnsWindow =
get_window_for_gdk_window(parentArea->inner_window); get_window_for_gdk_window(parentGdkWindow);
NS_ASSERTION(parentnsWindow, NS_ASSERTION(parentnsWindow,
"no nsWindow for parentArea!"); "no nsWindow for parentGdkWindow!");
if (parentnsWindow && parentnsWindow->mWindowGroup) { if (parentnsWindow && parentnsWindow->mWindowGroup) {
gtk_window_group_add_window(parentnsWindow->mWindowGroup, gtk_window_group_add_window(parentnsWindow->mWindowGroup,
GTK_WINDOW(mShell)); GTK_WINDOW(mShell));
@ -3948,18 +3948,19 @@ nsWindow::NativeCreate(nsIWidget *aParent,
} }
// create our container // create our container
mContainer = MOZ_CONTAINER(moz_container_new()); GtkWidget *container = moz_container_new();
gtk_container_add(GTK_CONTAINER(mShell), GTK_WIDGET(mContainer)); mContainer = MOZ_CONTAINER(container);
gtk_widget_realize(GTK_WIDGET(mContainer)); gtk_container_add(GTK_CONTAINER(mShell), container);
gtk_widget_realize(container);
// Don't let GTK mess with the shapes of our GdkWindows // Don't let GTK mess with the shapes of our GdkWindows
GTK_PRIVATE_SET_FLAG(GTK_WIDGET(mContainer), GTK_HAS_SHAPE_MASK); GTK_PRIVATE_SET_FLAG(container, GTK_HAS_SHAPE_MASK);
// make sure this is the focus widget in the container // make sure this is the focus widget in the container
gtk_window_set_focus(GTK_WINDOW(mShell), GTK_WIDGET(mContainer)); gtk_window_set_focus(GTK_WINDOW(mShell), container);
// and the drawing area // and the drawing window
mDrawingarea = moz_drawingarea_new(nsnull, mContainer, visual); mGdkWindow = CreateGdkWindow(container->window, container);
if (mWindowType == eWindowType_popup) { if (mWindowType == eWindowType_popup) {
// gdk does not automatically set the cursor for "temporary" // gdk does not automatically set the cursor for "temporary"
@ -3975,17 +3976,18 @@ nsWindow::NativeCreate(nsIWidget *aParent,
break; break;
case eWindowType_child: { case eWindowType_child: {
if (parentMozContainer) { if (parentMozContainer) {
mDrawingarea = moz_drawingarea_new(parentArea, parentMozContainer, visual); mGdkWindow = CreateGdkWindow(parentGdkWindow, parentMozContainer);
} }
else if (parentGtkContainer) { else if (parentGtkContainer) {
mContainer = MOZ_CONTAINER(moz_container_new()); GtkWidget *container = moz_container_new();
gtk_container_add(parentGtkContainer, GTK_WIDGET(mContainer)); mContainer = MOZ_CONTAINER(container);
gtk_widget_realize(GTK_WIDGET(mContainer)); gtk_container_add(parentGtkContainer, container);
gtk_widget_realize(container);
// Don't let GTK mess with the shapes of our GdkWindows // Don't let GTK mess with the shapes of our GdkWindows
GTK_PRIVATE_SET_FLAG(GTK_WIDGET(mContainer), GTK_HAS_SHAPE_MASK); GTK_PRIVATE_SET_FLAG(container, GTK_HAS_SHAPE_MASK);
mDrawingarea = moz_drawingarea_new(nsnull, mContainer, visual); mGdkWindow = CreateGdkWindow(container->window, container);
} }
else { else {
NS_WARNING("Warning: tried to create a new child widget with no parent!"); NS_WARNING("Warning: tried to create a new child widget with no parent!");
@ -4006,17 +4008,8 @@ nsWindow::NativeCreate(nsIWidget *aParent,
gtk_widget_set_double_buffered (GTK_WIDGET(mContainer),FALSE); gtk_widget_set_double_buffered (GTK_WIDGET(mContainer),FALSE);
#endif #endif
// label the drawing area with this object so we can find our way // label the drawing window with this object so we can find our way home
// home g_object_set_data(G_OBJECT(mGdkWindow), "nsWindow", this);
g_object_set_data(G_OBJECT(mDrawingarea->clip_window), "nsWindow",
this);
g_object_set_data(G_OBJECT(mDrawingarea->inner_window), "nsWindow",
this);
g_object_set_data(G_OBJECT(mDrawingarea->clip_window), "mozdrawingarea",
mDrawingarea);
g_object_set_data(G_OBJECT(mDrawingarea->inner_window), "mozdrawingarea",
mDrawingarea);
if (mContainer) if (mContainer)
g_object_set_data(G_OBJECT(mContainer), "nsWindow", this); g_object_set_data(G_OBJECT(mContainer), "nsWindow", this);
@ -4107,12 +4100,9 @@ nsWindow::NativeCreate(nsIWidget *aParent,
GDK_WINDOW_XWINDOW(GTK_WIDGET(mContainer)->window))); GDK_WINDOW_XWINDOW(GTK_WIDGET(mContainer)->window)));
} }
if (mDrawingarea) { if (mGdkWindow) {
LOG(("\tmDrawingarea %p %p %p %lx %lx\n", (void *)mDrawingarea, LOG(("\tmGdkWindow %p %lx\n", (void *)mGdkWindow,
(void *)mDrawingarea->clip_window, GDK_WINDOW_XWINDOW(mGdkWindow)));
(void *)mDrawingarea->inner_window,
GDK_WINDOW_XWINDOW(mDrawingarea->clip_window),
GDK_WINDOW_XWINDOW(mDrawingarea->inner_window)));
} }
// resize so that everything is set to the right dimensions // resize so that everything is set to the right dimensions
@ -4278,8 +4268,8 @@ nsWindow::NativeResize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
gtk_widget_size_allocate(GTK_WIDGET(mContainer), &allocation); gtk_widget_size_allocate(GTK_WIDGET(mContainer), &allocation);
} }
if (mDrawingarea) { if (mGdkWindow) {
moz_drawingarea_resize (mDrawingarea, aWidth, aHeight); gdk_window_resize(mGdkWindow, aWidth, aHeight);
} }
} }
@ -4305,7 +4295,7 @@ nsWindow::NativeResize(PRInt32 aX, PRInt32 aY,
gtk_window_move(GTK_WINDOW(mShell), aX, aY); gtk_window_move(GTK_WINDOW(mShell), aX, aY);
gtk_window_resize(GTK_WINDOW(mShell), aWidth, aHeight); gtk_window_resize(GTK_WINDOW(mShell), aWidth, aHeight);
moz_drawingarea_resize(mDrawingarea, aWidth, aHeight); gdk_window_resize(mGdkWindow, aWidth, aHeight);
} }
else if (mContainer) { else if (mContainer) {
GtkAllocation allocation; GtkAllocation allocation;
@ -4314,10 +4304,10 @@ nsWindow::NativeResize(PRInt32 aX, PRInt32 aY,
allocation.width = aWidth; allocation.width = aWidth;
allocation.height = aHeight; allocation.height = aHeight;
gtk_widget_size_allocate(GTK_WIDGET(mContainer), &allocation); gtk_widget_size_allocate(GTK_WIDGET(mContainer), &allocation);
moz_drawingarea_move_resize(mDrawingarea, aX, aY, aWidth, aHeight); gdk_window_move_resize(mGdkWindow, aX, aY, aWidth, aHeight);
} }
else if (mDrawingarea) { else if (mGdkWindow) {
moz_drawingarea_move_resize(mDrawingarea, aX, aY, aWidth, aHeight); gdk_window_move_resize(mGdkWindow, aX, aY, aWidth, aHeight);
} }
} }
@ -4346,16 +4336,16 @@ nsWindow::NativeShow (PRBool aAction)
SetUserTimeAndStartupIDForActivatedWindow(mShell); SetUserTimeAndStartupIDForActivatedWindow(mShell);
} }
moz_drawingarea_set_visibility(mDrawingarea, aAction); gdk_window_show_unraised(mGdkWindow);
gtk_widget_show(GTK_WIDGET(mContainer)); gtk_widget_show(GTK_WIDGET(mContainer));
gtk_widget_show(mShell); gtk_widget_show(mShell);
} }
else if (mContainer) { else if (mContainer) {
moz_drawingarea_set_visibility(mDrawingarea, TRUE); gdk_window_show_unraised(mGdkWindow);
gtk_widget_show(GTK_WIDGET(mContainer)); gtk_widget_show(GTK_WIDGET(mContainer));
} }
else if (mDrawingarea) { else if (mGdkWindow) {
moz_drawingarea_set_visibility(mDrawingarea, TRUE); gdk_window_show_unraised(mGdkWindow);
} }
} }
else { else {
@ -4365,10 +4355,10 @@ nsWindow::NativeShow (PRBool aAction)
} }
else if (mContainer) { else if (mContainer) {
gtk_widget_hide(GTK_WIDGET(mContainer)); gtk_widget_hide(GTK_WIDGET(mContainer));
moz_drawingarea_set_visibility(mDrawingarea, FALSE); gdk_window_hide(mGdkWindow);
} }
if (mDrawingarea) { if (mGdkWindow) {
moz_drawingarea_set_visibility(mDrawingarea, FALSE); gdk_window_hide(mGdkWindow);
} }
} }
} }
@ -4483,7 +4473,7 @@ nsWindow::SetWindowClipRegion(const nsTArray<nsIntRect>& aRects)
if (!StoreWindowClipRegion(aRects)) if (!StoreWindowClipRegion(aRects))
return NS_OK; return NS_OK;
if (!mDrawingarea) if (!mGdkWindow)
return NS_OK; return NS_OK;
GdkRegion *region = gdk_region_new(); GdkRegion *region = gdk_region_new();
@ -4495,7 +4485,7 @@ nsWindow::SetWindowClipRegion(const nsTArray<nsIntRect>& aRects)
gdk_region_union_with_rect(region, &rect); gdk_region_union_with_rect(region, &rect);
} }
gdk_window_shape_combine_region(mDrawingarea->clip_window, region, 0, 0); gdk_window_shape_combine_region(mGdkWindow, region, 0, 0);
gdk_region_destroy(region); gdk_region_destroy(region);
return NS_OK; return NS_OK;
@ -4672,11 +4662,11 @@ nsWindow::GrabPointer(void)
return; return;
} }
if (!mDrawingarea) if (!mGdkWindow)
return; return;
gint retval; gint retval;
retval = gdk_pointer_grab(mDrawingarea->inner_window, TRUE, retval = gdk_pointer_grab(mGdkWindow, TRUE,
(GdkEventMask)(GDK_BUTTON_PRESS_MASK | (GdkEventMask)(GDK_BUTTON_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_ENTER_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK |
@ -4716,8 +4706,8 @@ nsWindow::GrabKeyboard(void)
if (mTransientParent) if (mTransientParent)
grabWindow = GTK_WIDGET(mTransientParent)->window; grabWindow = GTK_WIDGET(mTransientParent)->window;
else if (mDrawingarea) else if (mGdkWindow)
grabWindow = mDrawingarea->inner_window; grabWindow = mGdkWindow;
else else
return; return;
@ -4763,11 +4753,11 @@ nsWindow::GetToplevelWidget(GtkWidget **aWidget)
GtkWidget * GtkWidget *
nsWindow::GetMozContainerWidget() nsWindow::GetMozContainerWidget()
{ {
if (!mDrawingarea) if (!mGdkWindow)
return NULL; return NULL;
GtkWidget *owningWidget = GtkWidget *owningWidget =
get_gtk_widget_for_gdk_window(mDrawingarea->inner_window); get_gtk_widget_for_gdk_window(mGdkWindow);
return owningWidget; return owningWidget;
} }
@ -4807,10 +4797,10 @@ nsWindow::SetUrgencyHint(GtkWidget *top_window, PRBool state)
void * void *
nsWindow::SetupPluginPort(void) nsWindow::SetupPluginPort(void)
{ {
if (!mDrawingarea) if (!mGdkWindow)
return nsnull; return nsnull;
if (GDK_WINDOW_OBJECT(mDrawingarea->inner_window)->destroyed == TRUE) if (GDK_WINDOW_OBJECT(mGdkWindow)->destroyed == TRUE)
return nsnull; return nsnull;
// we have to flush the X queue here so that any plugins that // we have to flush the X queue here so that any plugins that
@ -4818,22 +4808,19 @@ nsWindow::SetupPluginPort(void)
// this window in case it was just created // this window in case it was just created
#ifdef MOZ_X11 #ifdef MOZ_X11
XWindowAttributes xattrs; XWindowAttributes xattrs;
XGetWindowAttributes(GDK_DISPLAY (), XGetWindowAttributes(GDK_DISPLAY(), GDK_WINDOW_XWINDOW(mGdkWindow),
GDK_WINDOW_XWINDOW(mDrawingarea->inner_window),
&xattrs); &xattrs);
XSelectInput (GDK_DISPLAY (), XSelectInput (GDK_DISPLAY (),
GDK_WINDOW_XWINDOW(mDrawingarea->inner_window), GDK_WINDOW_XWINDOW(mGdkWindow),
xattrs.your_event_mask | xattrs.your_event_mask |
SubstructureNotifyMask); SubstructureNotifyMask);
gdk_window_add_filter(mDrawingarea->inner_window, gdk_window_add_filter(mGdkWindow, plugin_window_filter_func, this);
plugin_window_filter_func,
this);
XSync(GDK_DISPLAY(), False); XSync(GDK_DISPLAY(), False);
#endif /* MOZ_X11 */ #endif /* MOZ_X11 */
return (void *)GDK_WINDOW_XWINDOW(mDrawingarea->inner_window); return (void *)GDK_WINDOW_XWINDOW(mGdkWindow);
} }
nsresult nsresult
@ -4893,14 +4880,13 @@ nsWindow::SetNonXEmbedPluginFocus()
Window curFocusWindow; Window curFocusWindow;
int focusState; int focusState;
XGetInputFocus(GDK_WINDOW_XDISPLAY(mDrawingarea->inner_window), XGetInputFocus(GDK_WINDOW_XDISPLAY(mGdkWindow),
&curFocusWindow, &curFocusWindow,
&focusState); &focusState);
LOGFOCUS(("\t curFocusWindow=%p\n", curFocusWindow)); LOGFOCUS(("\t curFocusWindow=%p\n", curFocusWindow));
GdkWindow* toplevel = gdk_window_get_toplevel GdkWindow* toplevel = gdk_window_get_toplevel(mGdkWindow);
(mDrawingarea->inner_window);
GdkWindow *gdkfocuswin = gdk_window_lookup(curFocusWindow); GdkWindow *gdkfocuswin = gdk_window_lookup(curFocusWindow);
// lookup with the focus proxy window is supposed to get the // lookup with the focus proxy window is supposed to get the
@ -4912,11 +4898,11 @@ nsWindow::SetNonXEmbedPluginFocus()
// switch the focus from the focus proxy to the plugin window // switch the focus from the focus proxy to the plugin window
mOldFocusWindow = curFocusWindow; mOldFocusWindow = curFocusWindow;
XRaiseWindow(GDK_WINDOW_XDISPLAY(mDrawingarea->inner_window), XRaiseWindow(GDK_WINDOW_XDISPLAY(mGdkWindow),
GDK_WINDOW_XWINDOW(mDrawingarea->inner_window)); GDK_WINDOW_XWINDOW(mGdkWindow));
gdk_error_trap_push(); gdk_error_trap_push();
XSetInputFocus(GDK_WINDOW_XDISPLAY(mDrawingarea->inner_window), XSetInputFocus(GDK_WINDOW_XDISPLAY(mGdkWindow),
GDK_WINDOW_XWINDOW(mDrawingarea->inner_window), GDK_WINDOW_XWINDOW(mGdkWindow),
RevertToNone, RevertToNone,
CurrentTime); CurrentTime);
gdk_flush(); gdk_flush();
@ -4925,8 +4911,7 @@ nsWindow::SetNonXEmbedPluginFocus()
gdk_window_add_filter(NULL, plugin_client_message_filter, this); gdk_window_add_filter(NULL, plugin_client_message_filter, this);
LOGFOCUS(("nsWindow::SetNonXEmbedPluginFocus oldfocus=%p new=%p\n", LOGFOCUS(("nsWindow::SetNonXEmbedPluginFocus oldfocus=%p new=%p\n",
mOldFocusWindow, mOldFocusWindow, GDK_WINDOW_XWINDOW(mGdkWindow)));
GDK_WINDOW_XWINDOW(mDrawingarea->inner_window)));
} }
void void
@ -4943,7 +4928,7 @@ nsWindow::LoseNonXEmbedPluginFocus()
Window curFocusWindow; Window curFocusWindow;
int focusState; int focusState;
XGetInputFocus(GDK_WINDOW_XDISPLAY(mDrawingarea->inner_window), XGetInputFocus(GDK_WINDOW_XDISPLAY(mGdkWindow),
&curFocusWindow, &curFocusWindow,
&focusState); &focusState);
@ -4952,12 +4937,12 @@ nsWindow::LoseNonXEmbedPluginFocus()
// event filter that blocks the WM_TAKE_FOCUS is enough. WM and gtk2 // event filter that blocks the WM_TAKE_FOCUS is enough. WM and gtk2
// will take care of the focus later. // will take care of the focus later.
if (!curFocusWindow || if (!curFocusWindow ||
curFocusWindow == GDK_WINDOW_XWINDOW(mDrawingarea->inner_window)) { curFocusWindow == GDK_WINDOW_XWINDOW(mGdkWindow)) {
gdk_error_trap_push(); gdk_error_trap_push();
XRaiseWindow(GDK_WINDOW_XDISPLAY(mDrawingarea->inner_window), XRaiseWindow(GDK_WINDOW_XDISPLAY(mGdkWindow),
mOldFocusWindow); mOldFocusWindow);
XSetInputFocus(GDK_WINDOW_XDISPLAY(mDrawingarea->inner_window), XSetInputFocus(GDK_WINDOW_XDISPLAY(mGdkWindow),
mOldFocusWindow, mOldFocusWindow,
RevertToParent, RevertToParent,
CurrentTime); CurrentTime);
@ -6680,13 +6665,11 @@ nsWindow::IMESetCursorPosition(const nsTextEventReply& aReply)
// Get the position of the refWindow in screen. // Get the position of the refWindow in screen.
gint refX, refY; gint refX, refY;
gdk_window_get_origin(refWindow->mDrawingarea->inner_window, gdk_window_get_origin(refWindow->mGdkWindow, &refX, &refY);
&refX, &refY);
// Get the position of IM context owner window in screen. // Get the position of IM context owner window in screen.
gint ownerX, ownerY; gint ownerX, ownerY;
gdk_window_get_origin(ownerWindow->mDrawingarea->inner_window, gdk_window_get_origin(ownerWindow->mGdkWindow, &ownerX, &ownerY);
&ownerX, &ownerY);
// Compute the caret position in the IM owner window. // Compute the caret position in the IM owner window.
GdkRectangle area; GdkRectangle area;
@ -6844,7 +6827,7 @@ nsWindow::GetToggledKeyState(PRUint32 aKeyCode, PRBool* aLEDState)
GdkModifierType modifiers = gdk_keyboard_get_modifiers(); GdkModifierType modifiers = gdk_keyboard_get_modifiers();
PRUint32 capsLockMask, numLockMask, scrollLockMask; PRUint32 capsLockMask, numLockMask, scrollLockMask;
PRBool foundMasks = gdk_keyboard_get_modmap_masks( PRBool foundMasks = gdk_keyboard_get_modmap_masks(
GDK_WINDOW_XDISPLAY(mDrawingarea->inner_window), GDK_WINDOW_XDISPLAY(mGdkWindow),
&capsLockMask, &numLockMask, &scrollLockMask); &capsLockMask, &numLockMask, &scrollLockMask);
if (!foundMasks) if (!foundMasks)
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
@ -7177,8 +7160,7 @@ nsWindow::GetThebesSurface()
{ {
GdkDrawable* d; GdkDrawable* d;
gint x_offset, y_offset; gint x_offset, y_offset;
gdk_window_get_internal_paint_info(mDrawingarea->inner_window, gdk_window_get_internal_paint_info(mGdkWindow, &d, &x_offset, &y_offset);
&d, &x_offset, &y_offset);
#ifdef MOZ_X11 #ifdef MOZ_X11
gint width, height; gint width, height;
@ -7254,7 +7236,7 @@ nsWindow::BeginResizeDrag(nsGUIEvent* aEvent, PRInt32 aHorizontal, PRInt32 aVert
} }
// get the gdk window for this widget // get the gdk window for this widget
GdkWindow* gdk_window = mDrawingarea->inner_window; GdkWindow* gdk_window = mGdkWindow;
if (!GDK_IS_WINDOW(gdk_window)) { if (!GDK_IS_WINDOW(gdk_window)) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
} }

Просмотреть файл

@ -43,7 +43,6 @@
#include "nsAutoPtr.h" #include "nsAutoPtr.h"
#include "mozcontainer.h" #include "mozcontainer.h"
#include "mozdrawingarea.h"
#include "nsWeakReference.h" #include "nsWeakReference.h"
#include "nsIDragService.h" #include "nsIDragService.h"
@ -467,7 +466,7 @@ private:
GtkWidget *mShell; GtkWidget *mShell;
MozContainer *mContainer; MozContainer *mContainer;
MozDrawingarea *mDrawingarea; GdkWindow *mGdkWindow;
GtkWindowGroup *mWindowGroup; GtkWindowGroup *mWindowGroup;