b=506433 reuse the GdkWindow in MozContainers. r=roc

--HG--
extra : rebase_source : 27cdc9fd7b3371627730751b239da5226133bbb9
This commit is contained in:
Karl Tomlinson 2009-07-27 13:40:46 +12:00
Родитель ed9615bf41
Коммит 71e7b160c0
3 изменённых файлов: 38 добавлений и 33 удалений

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

@ -264,8 +264,15 @@ moz_container_realize (GtkWidget *widget)
/* create the shell window */
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= (GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK);
attributes.event_mask = (gtk_widget_get_events (widget) |
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.x = widget->allocation.x;
attributes.y = widget->allocation.y;
attributes.width = widget->allocation.width;

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

@ -83,6 +83,11 @@ extern "C" {
#define IS_MOZ_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOZ_CONTAINER_TYPE))
#define MOZ_CONAINTER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MOZ_CONTAINER_TYPE, MozContainerClass))
#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 _MozContainer MozContainer;
typedef struct _MozContainerClass MozContainerClass;

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

@ -141,11 +141,6 @@ D_DEBUG_DOMAIN( ns_Window, "nsWindow", "nsWindow" );
#define D_DEBUG_AT(x,y...) do {} while (0)
#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
// out to the bounding-box if there are more
#define MAX_RECTS_IN_REGION 100
@ -797,25 +792,27 @@ nsWindow::Destroy(void)
gtk_widget_destroy(mShell);
mShell = nsnull;
mContainer = nsnull;
NS_ABORT_IF_FALSE(!mGdkWindow,
"mGdkWindow should be NULL when mContainer is destroyed");
}
else if (mContainer) {
gtk_widget_destroy(GTK_WIDGET(mContainer));
mContainer = nsnull;
NS_ABORT_IF_FALSE(!mGdkWindow,
"mGdkWindow should be NULL when mContainer is destroyed");
}
else if (owningWidget) {
else if (mGdkWindow) {
// Remove references from GdkWindows back to their container
// widget while the GdkWindow hierarchy is still available.
// (OnContainerUnrealize does this when the MozContainer widget is
// destroyed.)
SetWidgetForHierarchy(mGdkWindow, owningWidget, NULL);
}
if (mGdkWindow) {
g_object_set_data(G_OBJECT(mGdkWindow), "nsWindow", NULL);
if (owningWidget) {
SetWidgetForHierarchy(mGdkWindow, owningWidget, NULL);
}
NS_ASSERTION(!get_gtk_widget_for_gdk_window(mGdkWindow),
"widget reference not removed");
g_object_set_data(G_OBJECT(mGdkWindow), "nsWindow", NULL);
gdk_window_destroy(mGdkWindow);
mGdkWindow = nsnull;
}
@ -2464,6 +2461,9 @@ nsWindow::OnContainerUnrealize(GtkWidget *aWidget)
if (mGdkWindow) {
SetWidgetForHierarchy(mGdkWindow, aWidget, NULL);
g_object_set_data(G_OBJECT(mGdkWindow), "nsWindow", NULL);
mGdkWindow = NULL;
}
}
@ -2485,8 +2485,6 @@ nsWindow::OnSizeAllocate(GtkWidget *aWidget, GtkAllocation *aAllocation)
if (!mGdkWindow)
return;
gdk_window_resize (mGdkWindow, rect.width, rect.height);
if (mTransparencyBitmap) {
ApplyTransparencyBitmap();
}
@ -3959,8 +3957,8 @@ nsWindow::NativeCreate(nsIWidget *aParent,
// make sure this is the focus widget in the container
gtk_window_set_focus(GTK_WINDOW(mShell), container);
// and the drawing window
mGdkWindow = CreateGdkWindow(container->window, container);
// the drawing window
mGdkWindow = container->window;
if (mWindowType == eWindowType_popup) {
// gdk does not automatically set the cursor for "temporary"
@ -3987,7 +3985,7 @@ nsWindow::NativeCreate(nsIWidget *aParent,
// Don't let GTK mess with the shapes of our GdkWindows
GTK_PRIVATE_SET_FLAG(container, GTK_HAS_SHAPE_MASK);
mGdkWindow = CreateGdkWindow(container->window, container);
mGdkWindow = container->window;
}
else {
NS_WARNING("Warning: tried to create a new child widget with no parent!");
@ -4099,8 +4097,7 @@ nsWindow::NativeCreate(nsIWidget *aParent,
(void *)GTK_WIDGET(mContainer)->window,
GDK_WINDOW_XWINDOW(GTK_WIDGET(mContainer)->window)));
}
if (mGdkWindow) {
else if (mGdkWindow) {
LOG(("\tmGdkWindow %p %lx\n", (void *)mGdkWindow,
GDK_WINDOW_XWINDOW(mGdkWindow)));
}
@ -4260,15 +4257,15 @@ nsWindow::NativeResize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint)
gtk_window_resize(GTK_WINDOW(mShell), aWidth, aHeight);
}
else if (mContainer) {
GtkWidget *widget = GTK_WIDGET(mContainer);
GtkAllocation allocation;
allocation.x = 0;
allocation.y = 0;
allocation.x = widget->allocation.x;
allocation.y = widget->allocation.y;
allocation.width = aWidth;
allocation.height = aHeight;
gtk_widget_size_allocate(GTK_WIDGET(mContainer), &allocation);
gtk_widget_size_allocate(widget, &allocation);
}
if (mGdkWindow) {
else if (mGdkWindow) {
gdk_window_resize(mGdkWindow, aWidth, aHeight);
}
}
@ -4299,12 +4296,11 @@ nsWindow::NativeResize(PRInt32 aX, PRInt32 aY,
}
else if (mContainer) {
GtkAllocation allocation;
allocation.x = 0;
allocation.y = 0;
allocation.x = aX;
allocation.y = aY;
allocation.width = aWidth;
allocation.height = aHeight;
gtk_widget_size_allocate(GTK_WIDGET(mContainer), &allocation);
gdk_window_move_resize(mGdkWindow, aX, aY, aWidth, aHeight);
}
else if (mGdkWindow) {
gdk_window_move_resize(mGdkWindow, aX, aY, aWidth, aHeight);
@ -4336,12 +4332,10 @@ nsWindow::NativeShow (PRBool aAction)
SetUserTimeAndStartupIDForActivatedWindow(mShell);
}
gdk_window_show_unraised(mGdkWindow);
gtk_widget_show(GTK_WIDGET(mContainer));
gtk_widget_show(mShell);
}
else if (mContainer) {
gdk_window_show_unraised(mGdkWindow);
gtk_widget_show(GTK_WIDGET(mContainer));
}
else if (mGdkWindow) {
@ -4355,9 +4349,8 @@ nsWindow::NativeShow (PRBool aAction)
}
else if (mContainer) {
gtk_widget_hide(GTK_WIDGET(mContainer));
gdk_window_hide(mGdkWindow);
}
if (mGdkWindow) {
else if (mGdkWindow) {
gdk_window_hide(mGdkWindow);
}
}