diff options
author | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 02:20:08 +0000 |
---|---|---|
committer | agl@chromium.org <agl@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 02:20:08 +0000 |
commit | e5380f532572a127962f40d242650d136a51d896 (patch) | |
tree | 58ffaa8f5b3c9893ed00bc508f0840fd53f3121e /chrome | |
parent | 4edb0b93463b7cd8e52bf6dff7fc7b460afe887b (diff) | |
download | chromium_src-e5380f532572a127962f40d242650d136a51d896.zip chromium_src-e5380f532572a127962f40d242650d136a51d896.tar.gz chromium_src-e5380f532572a127962f40d242650d136a51d896.tar.bz2 |
Linux: fix GDK error when switching tab contents
When we remove a drawing area from a container, GTK destroys the X
window. However, the BackingStore remembers the old X window id and
emits X requests using the wrong id.
This change makes the window id an argument to ShowRect and makes the
pixmaps from the root window instead.
Review: http://codereview.chromium.org/27169
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10439 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/renderer_host/backing_store.h | 8 | ||||
-rw-r--r-- | chrome/browser/renderer_host/backing_store_x.cc | 16 | ||||
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_gtk.cc | 11 | ||||
-rw-r--r-- | chrome/common/x11_util.cc | 4 | ||||
-rw-r--r-- | chrome/common/x11_util.h | 2 |
5 files changed, 24 insertions, 17 deletions
diff --git a/chrome/browser/renderer_host/backing_store.h b/chrome/browser/renderer_host/backing_store.h index ce18c7d..a74fe5d 100644 --- a/chrome/browser/renderer_host/backing_store.h +++ b/chrome/browser/renderer_host/backing_store.h @@ -36,10 +36,10 @@ class BackingStore { // x_connection: the display to target // depth: the depth of the X window which will be drawn into // visual: An Xlib Visual describing the format of the target window - // parent_window: The X id of the target window + // root_window: The X id of the root window // use_shared_memory: if true, the X server is local BackingStore(const gfx::Size& size, Display* x_connection, int depth, - void* visual, XID parent_window, bool use_shared_memory); + void* visual, XID root_window, bool use_shared_memory); // This is for unittesting only. An object constructed using this constructor // will silently ignore all paints explicit BackingStore(const gfx::Size& size); @@ -57,7 +57,7 @@ class BackingStore { // display: the display of the backing store and target window // damage: the area to copy // target: the X id of the target window - void ShowRect(const gfx::Rect& damage); + void ShowRect(const gfx::Rect& damage, XID target); #endif // Paints the bitmap from the renderer onto the backing store. @@ -104,7 +104,7 @@ class BackingStore { // If this is true, then |connection_| is good for MIT-SHM (X shared memory). const bool use_shared_memory_; // The parent window (probably a GtkDrawingArea) for this backing store. - const XID parent_window_; + const XID root_window_; // This is a handle to the server side pixmap which is our backing store. XID pixmap_; // This is the RENDER picture pointing at |pixmap_|. diff --git a/chrome/browser/renderer_host/backing_store_x.cc b/chrome/browser/renderer_host/backing_store_x.cc index b4a7cae..e37fe77 100644 --- a/chrome/browser/renderer_host/backing_store_x.cc +++ b/chrome/browser/renderer_host/backing_store_x.cc @@ -26,16 +26,16 @@ BackingStore::BackingStore(const gfx::Size& size, Display* display, int depth, void* visual, - Drawable parent_window, + Drawable root_window, bool use_shared_memory) : size_(size), display_(display), use_shared_memory_(use_shared_memory), - parent_window_(parent_window) { + root_window_(root_window) { const int width = size.width(); const int height = size.height(); - pixmap_ = XCreatePixmap(display_, parent_window, width, height, depth); + pixmap_ = XCreatePixmap(display_, root_window, width, height, depth); picture_ = XRenderCreatePicture( display_, pixmap_, x11_util::GetRenderVisualFormat(display_, static_cast<Visual*>(visual)), @@ -47,7 +47,7 @@ BackingStore::BackingStore(const gfx::Size& size) : size_(size), display_(NULL), use_shared_memory_(false), - parent_window_(0) { + root_window_(0) { } BackingStore::~BackingStore() { @@ -85,7 +85,7 @@ void BackingStore::PaintRect(base::ProcessHandle process, // difference between the |data| pointer and the address of the mapping in // |shminfo|. Since both are NULL, the offset will be calculated to be 0, // which is correct for us. - pixmap = XShmCreatePixmap(display_, parent_window_, NULL, &shminfo, width, + pixmap = XShmCreatePixmap(display_, root_window_, NULL, &shminfo, width, height, 32); } else { // No shared memory support, we have to copy the bitmap contents to the X @@ -109,7 +109,7 @@ void BackingStore::PaintRect(base::ProcessHandle process, image.blue_mask = 0xff0000; image.data = static_cast<char*>(bitmap->memory()); - pixmap = XCreatePixmap(display_, parent_window_, width, height, 32); + pixmap = XCreatePixmap(display_, root_window_, width, height, 32); GC gc = XCreateGC(display_, pixmap, 0, NULL); XPutImage(display_, pixmap, gc, &image, 0, 0 /* source x, y */, 0, 0 /* dest x, y */, @@ -162,8 +162,8 @@ void BackingStore::ScrollRect(base::ProcessHandle process, PaintRect(process, bitmap, bitmap_rect); } -void BackingStore::ShowRect(const gfx::Rect& rect) { - XCopyArea(display_, pixmap_, parent_window_, static_cast<GC>(pixmap_gc_), +void BackingStore::ShowRect(const gfx::Rect& rect, XID target) { + XCopyArea(display_, pixmap_, target, static_cast<GC>(pixmap_gc_), rect.x(), rect.y(), rect.width(), rect.height(), rect.x(), rect.y()); } diff --git a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc index f4ef560..4b5f19e 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_gtk.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_gtk.cc @@ -287,11 +287,11 @@ BackingStore* RenderWidgetHostViewGtk::AllocBackingStore( const gfx::Size& size) { Display* display = x11_util::GetXDisplay(); void* visual = x11_util::GetVisualFromGtkWidget(view_); - XID parent_window = x11_util::GetX11WindowFromGtkWidget(view_); + XID root_window = x11_util::GetX11RootWindow(); bool use_shared_memory = x11_util::QuerySharedMemorySupport(display); int depth = gtk_widget_get_visual(view_)->depth; - return new BackingStore(size, display, depth, visual, parent_window, + return new BackingStore(size, display, depth, visual, root_window, use_shared_memory); } @@ -303,9 +303,10 @@ void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { // period where this object isn't attached to a window but hasn't been // Destroy()ed yet and it receives paint messages... GdkWindow* window = view_->window; - if (window) - backing_store->ShowRect(damage_rect); - + if (window) { + backing_store->ShowRect( + damage_rect, x11_util::GetX11WindowFromGtkWidget(view_)); + } } else { NOTIMPLEMENTED(); } diff --git a/chrome/common/x11_util.cc b/chrome/common/x11_util.cc index 0f74120..ec54f7b 100644 --- a/chrome/common/x11_util.cc +++ b/chrome/common/x11_util.cc @@ -82,6 +82,10 @@ bool QuerySharedMemorySupport(Display* dpy) { return shared_memory_support; } +XID GetX11RootWindow() { + return GDK_WINDOW_XID(gdk_get_default_root_window()); +} + XID GetX11WindowFromGtkWidget(GtkWidget* widget) { return GDK_WINDOW_XID(widget->window); } diff --git a/chrome/common/x11_util.h b/chrome/common/x11_util.h index 130ecc7..6e5072b 100644 --- a/chrome/common/x11_util.h +++ b/chrome/common/x11_util.h @@ -30,6 +30,8 @@ namespace x11_util { // These functions do not cache their results + // Get the X window id for the default root window + XID GetX11RootWindow(); // Get the X window id for the given GTK widget. XID GetX11WindowFromGtkWidget(GtkWidget*); // Get a Visual from the given widget. Since we don't include the Xlib |