Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Side by Side Diff: gpu/demos/framework/window_linux.cc

Issue 565041: Implemented window class on linux. Standalone demos are working on linux now. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gpu/demos/framework/main_exe.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "gpu/demos/framework/window.h" 5 #include "gpu/demos/framework/window.h"
6 6
7 #include <gdk/gdkx.h>
8 #include <gtk/gtk.h>
9
10 #include "base/utf_string_conversions.h"
11
12 namespace {
13 using gpu::demos::Window;
14
15 gboolean OnDelete(GtkWidget* widget, GdkEventExpose* event) {
16 gtk_main_quit();
17 return FALSE;
18 }
19
20 gboolean OnExpose(GtkWidget* widget, GdkEventExpose* event, gpointer data) {
21 Window* window = static_cast<Window*>(data);
22 window->OnPaint();
23
24 // TODO(alokp): Figure out why this is crashing. Animation will not work
25 // until then.
26 //gtk_widget_queue_draw(widget);
27 return FALSE;
28 }
29 } // namespace
30
7 namespace gpu { 31 namespace gpu {
8 namespace demos { 32 namespace demos {
9 33
10 void Window::MainLoop() { 34 void Window::MainLoop() {
35 gtk_signal_connect(GTK_OBJECT(window_handle_),
36 "delete_event",
37 reinterpret_cast<GtkSignalFunc>(OnDelete),
38 NULL);
39 gtk_signal_connect(GTK_OBJECT(window_handle_),
40 "expose_event",
41 reinterpret_cast<GtkSignalFunc>(OnExpose),
42 this);
43 gtk_main();
11 } 44 }
12 45
13 gfx::NativeWindow Window::CreateNativeWindow(const wchar_t* title, 46 gfx::NativeWindow Window::CreateNativeWindow(const wchar_t* title,
14 int width, int height) { 47 int width, int height) {
15 return NULL; 48 GtkWidget* hwnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
49
50 gtk_window_set_title(GTK_WINDOW(hwnd), WideToUTF8(title).c_str());
51 gtk_window_set_default_size(GTK_WINDOW(hwnd), width, height);
52 gtk_widget_set_double_buffered(hwnd, FALSE);
53 gtk_widget_set_app_paintable(hwnd, TRUE);
54
55 gtk_widget_show(hwnd);
56 return GTK_WINDOW(hwnd);
16 } 57 }
17 58
18 gfx::PluginWindowHandle Window::PluginWindow(gfx::NativeWindow hwnd) { 59 gfx::PluginWindowHandle Window::PluginWindow(gfx::NativeWindow hwnd) {
19 return gfx::kNullPluginWindow; 60 return GDK_WINDOW_XWINDOW(GTK_WIDGET(hwnd)->window);
20 } 61 }
21 62
22 } // namespace demos 63 } // namespace demos
23 } // namespace gpu 64 } // namespace gpu
24 65
OLDNEW
« no previous file with comments | « gpu/demos/framework/main_exe.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698