| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_gtk.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
| 9 #include <cairo/cairo.h> | 9 #include <cairo/cairo.h> |
| 10 | 10 |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/gfx/gtk_util.h" |
| 12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 13 #include "chrome/common/native_web_keyboard_event.h" | 14 #include "chrome/common/native_web_keyboard_event.h" |
| 14 #include "chrome/common/x11_util.h" | 15 #include "chrome/common/x11_util.h" |
| 15 #include "chrome/browser/renderer_host/backing_store.h" | 16 #include "chrome/browser/renderer_host/backing_store.h" |
| 16 #include "chrome/browser/renderer_host/render_widget_host.h" | 17 #include "chrome/browser/renderer_host/render_widget_host.h" |
| 17 #include "webkit/glue/webinputevent.h" | 18 #include "webkit/glue/webinputevent.h" |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 // This class is a simple convenience wrapper for Gtk functions. It has only | 22 // This class is a simple convenience wrapper for Gtk functions. It has only |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 bool use_shared_memory = x11_util::QuerySharedMemorySupport(display); | 334 bool use_shared_memory = x11_util::QuerySharedMemorySupport(display); |
| 334 int depth = gtk_widget_get_visual(view_.get())->depth; | 335 int depth = gtk_widget_get_visual(view_.get())->depth; |
| 335 | 336 |
| 336 return new BackingStore(size, display, depth, visual, root_window, | 337 return new BackingStore(size, display, depth, visual, root_window, |
| 337 use_render, use_shared_memory); | 338 use_render, use_shared_memory); |
| 338 } | 339 } |
| 339 | 340 |
| 340 void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { | 341 void RenderWidgetHostViewGtk::Paint(const gfx::Rect& damage_rect) { |
| 341 BackingStore* backing_store = host_->GetBackingStore(); | 342 BackingStore* backing_store = host_->GetBackingStore(); |
| 342 | 343 |
| 344 GdkWindow* window = view_.get()->window; |
| 343 if (backing_store) { | 345 if (backing_store) { |
| 344 // Only render the widget if it is attached to a window; there's a short | 346 // Only render the widget if it is attached to a window; there's a short |
| 345 // period where this object isn't attached to a window but hasn't been | 347 // period where this object isn't attached to a window but hasn't been |
| 346 // Destroy()ed yet and it receives paint messages... | 348 // Destroy()ed yet and it receives paint messages... |
| 347 GdkWindow* window = view_.get()->window; | |
| 348 if (window) { | 349 if (window) { |
| 349 backing_store->ShowRect( | 350 backing_store->ShowRect( |
| 350 damage_rect, x11_util::GetX11WindowFromGtkWidget(view_.get())); | 351 damage_rect, x11_util::GetX11WindowFromGtkWidget(view_.get())); |
| 351 } | 352 } |
| 352 } else { | 353 } else { |
| 354 if (window) { |
| 355 // Set the window background to sea foam green. |
| 356 if (!gfx::kGdkSeafoamGreen.pixel) { |
| 357 // We need the color "allocated" to use for the window background. |
| 358 gdk_colormap_alloc_color(gdk_colormap_get_system(), |
| 359 &gfx::kGdkSeafoamGreen, |
| 360 FALSE /* not writable */, |
| 361 TRUE /* best match */); |
| 362 } |
| 363 gdk_window_set_background(window, &gfx::kGdkSeafoamGreen); |
| 364 gdk_window_clear(window); |
| 365 } |
| 353 NOTIMPLEMENTED(); | 366 NOTIMPLEMENTED(); |
| 354 } | 367 } |
| 355 } | 368 } |
| OLD | NEW |