These are the changes necessary for views to be able to build w/ use_aura implying no gtk.

BUG=97131
TEST=views_unittests

Review URL: http://codereview.chromium.org/7996008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102335 0039d316-1c4b-4281-b951-d872f2087c98
parent 5b5e1e2f
......@@ -43,12 +43,6 @@
#error Please add support for your platform in build/build_config.h
#endif
// A flag derived from the above flags, used to cover GTK code in
// both TOOLKIT_GTK and TOOLKIT_VIEWS.
#if defined(TOOLKIT_GTK) || (defined(TOOLKIT_VIEWS) && !defined(OS_WIN))
#define TOOLKIT_USES_GTK 1
#endif
#if defined(OS_LINUX) || defined(OS_FREEBSD) || defined(OS_OPENBSD) || \
defined(OS_SOLARIS) || defined(OS_ANDROID)
#if !defined(USE_OPENSSL)
......
......@@ -237,7 +237,7 @@
'use_x11%': 1,
}],
['use_aura==1 and OS!="win"', {
'toolkit_uses_gtk%': 1,
'toolkit_uses_gtk%': 0,
}],
# A flag to enable or disable our compile-time dependency
......@@ -856,6 +856,9 @@
['use_aura==1', {
'defines': ['USE_AURA=1'],
}],
['toolkit_uses_gtk==1', {
'defines': ['TOOLKIT_USES_GTK=1'],
}],
['chromeos==1', {
'defines': ['OS_CHROMEOS=1'],
}],
......
......@@ -6,7 +6,7 @@
#if defined(OS_WIN)
#include <windows.h>
#elif defined(OS_LINUX)
#elif defined(TOOLKIT_USES_GTK)
#include <gdk/gdk.h>
#endif
......@@ -83,7 +83,7 @@ string16 Accelerator::GetShortcutText() const {
else
key = LOWORD(::MapVirtualKeyW(key_code_, MAPVK_VK_TO_CHAR));
shortcut += key;
#elif defined(OS_LINUX)
#elif defined(TOOLKIT_USES_GTK)
const gchar* name = NULL;
switch (key_code_) {
case ui::VKEY_OEM_2:
......
......@@ -6,7 +6,7 @@
#include "build/build_config.h"
#if defined(OS_LINUX)
#if defined(TOOLKIT_USES_GTK)
#include <gdk/gdk.h>
#endif
......@@ -18,7 +18,7 @@
#include "views/controls/link_listener.h"
#include "views/events/event.h"
#if defined(OS_LINUX)
#if defined(TOOLKIT_USES_GTK)
#include "ui/gfx/gtk_util.h"
#endif
......@@ -103,11 +103,11 @@ gfx::NativeCursor Link::GetCursor(const MouseEvent& event) {
#if defined(OS_WIN)
static HCURSOR g_hand_cursor = LoadCursor(NULL, IDC_HAND);
return g_hand_cursor;
#elif defined(USE_AURA)
#elif defined(TOOLKIT_USES_GTK)
return gfx::GetCursor(GDK_HAND2);
#else
// TODO(saintlou):
return NULL;
#elif defined(OS_LINUX)
return gfx::GetCursor(GDK_HAND2);
#endif
}
......
......@@ -4,7 +4,7 @@
#include "views/controls/single_split_view.h"
#if defined(OS_LINUX)
#if defined(TOOLKIT_USES_GTK)
#include <gdk/gdk.h>
#endif
......@@ -13,7 +13,7 @@
#include "ui/gfx/canvas.h"
#include "views/background.h"
#if defined(OS_LINUX)
#if defined(TOOLKIT_USES_GTK)
#include "ui/gfx/gtk_util.h"
#endif
......@@ -100,12 +100,12 @@ gfx::NativeCursor SingleSplitView::GetCursor(const MouseEvent& event) {
static HCURSOR we_resize_cursor = LoadCursor(NULL, IDC_SIZEWE);
static HCURSOR ns_resize_cursor = LoadCursor(NULL, IDC_SIZENS);
return is_horizontal_ ? we_resize_cursor : ns_resize_cursor;
#elif defined(USE_AURA)
// TODO(saintlou):
return NULL;
#elif defined(OS_LINUX)
#elif defined(TOOLKIT_USES_GTK)
return gfx::GetCursor(is_horizontal_ ? GDK_SB_H_DOUBLE_ARROW :
GDK_SB_V_DOUBLE_ARROW);
#else
// TODO(saintlou):
return NULL;
#endif
}
......
......@@ -715,6 +715,7 @@ TEST_F(NativeTextfieldViewsTest, DragToSelect) {
EXPECT_EQ(textfield_->text(), textfield_->GetSelectedText());
}
#if defined(OS_WIN) || defined(TOOLKIT_USES_GTK)
TEST_F(NativeTextfieldViewsTest, DragAndDrop_AcceptDrop) {
InitTextfield(Textfield::STYLE_DEFAULT);
textfield_->SetText(ASCIIToUTF16("hello world"));
......@@ -769,6 +770,7 @@ TEST_F(NativeTextfieldViewsTest, DragAndDrop_AcceptDrop) {
#endif
EXPECT_FALSE(textfield_view_->CanDrop(bad_data));
}
#endif
#if !defined(TOUCH_UI)
TEST_F(NativeTextfieldViewsTest, DragAndDrop_InitiateDrag) {
......
......@@ -4,7 +4,7 @@
#include "views/controls/textfield/textfield.h"
#if defined(OS_LINUX)
#if defined(TOOLKIT_USES_GTK)
#include <gdk/gdkkeysyms.h>
#endif
......
......@@ -8,10 +8,6 @@
#include "build/build_config.h"
#if defined(OS_LINUX)
#include <gdk/gdk.h>
#endif
#include <string>
#include "base/basictypes.h"
......
......@@ -8,7 +8,7 @@
#include "build/build_config.h"
#if defined(OS_LINUX)
#if defined(TOOLKIT_USES_GTK)
#include <gdk/gdk.h>
#endif
......
......@@ -35,10 +35,10 @@ class MouseWatcher::Observer : public MessageLoopForUI::Observer {
// MessageLoop::Observer implementation:
#if defined(OS_WIN)
void WillProcessMessage(const MSG& msg) {
void WillProcessMessage(const MSG& msg) OVERRIDE {
}
void DidProcessMessage(const MSG& msg) {
void DidProcessMessage(const MSG& msg) OVERRIDE {
// We spy on three different Windows messages here to see if the mouse has
// moved out of the bounds of the view. The messages are:
//
......@@ -62,7 +62,7 @@ class MouseWatcher::Observer : public MessageLoopForUI::Observer {
}
#elif defined(USE_WAYLAND)
MessageLoopForUI::Observer::EventStatus WillProcessEvent(
ui::WaylandEvent* event) {
ui::WaylandEvent* event) OVERRIDE {
switch (event->type) {
case ui::WAYLAND_MOTION:
HandleGlobalMouseMoveEvent(false);
......@@ -76,11 +76,11 @@ class MouseWatcher::Observer : public MessageLoopForUI::Observer {
}
return EVENT_CONTINUE;
}
#else
void WillProcessEvent(GdkEvent* event) {
#elif defined(TOOLKIT_USES_GTK)
void WillProcessEvent(GdkEvent* event) OVERRIDE {
}
void DidProcessEvent(GdkEvent* event) {
void DidProcessEvent(GdkEvent* event) OVERRIDE {
switch (event->type) {
case GDK_MOTION_NOTIFY:
HandleGlobalMouseMoveEvent(false);
......@@ -92,6 +92,11 @@ class MouseWatcher::Observer : public MessageLoopForUI::Observer {
break;
}
}
#else
EventStatus WillProcessXEvent(XEvent* event) OVERRIDE {
// TODO(davemoore) Implement.
return EVENT_CONTINUE;
}
#endif
private:
......
......@@ -4,8 +4,11 @@
#include "views/touchui/touch_factory.h"
#if defined(TOOLKIT_USES_GTK)
// TODO(sad) Remove all TOOLKIT_USES_GTK uses once we move to aura only.
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#endif
#include <X11/cursorfont.h>
#include <X11/extensions/XInput.h>
#include <X11/extensions/XInput2.h>
......@@ -71,6 +74,7 @@ XIValuatorClassInfo* FindTPValuator(Display* display,
return NULL;
}
#if defined(TOOLKIT_USES_GTK)
// Setup XInput2 select for the GtkWidget.
gboolean GtkWidgetRealizeCallback(GSignalInvocationHint* hint, guint nparams,
const GValue* pvalues, gpointer data) {
......@@ -112,6 +116,7 @@ void RemoveGtkWidgetRealizeNotifier() {
realize_signal_id = 0;
realize_hook_id = 0;
}
#endif
} // namespace
......@@ -147,11 +152,12 @@ TouchFactory::TouchFactory()
SetCursorVisible(false, false);
UpdateDeviceList(display);
#if defined(TOOLKIT_USES_GTK)
// TODO(sad): Here, we only setup so that the X windows created by GTK+ are
// setup for XInput2 events. We need a way to listen for XInput2 events for X
// windows created by other means (e.g. for context menus).
SetupGtkWidgetRealizeNotifier(this);
#endif
// Make sure the list of devices is kept up-to-date by listening for
// XI_HierarchyChanged event on the root window.
unsigned char mask[XIMaskLen(XI_LASTEVENT)];
......@@ -177,7 +183,9 @@ TouchFactory::~TouchFactory() {
XFreeCursor(display, invisible_cursor_);
XFreeCursor(display, arrow_cursor_);
#if defined(TOOLKIT_USES_GTK)
RemoveGtkWidgetRealizeNotifier();
#endif
}
void TouchFactory::UpdateDeviceList(Display* display) {
......
......@@ -38,7 +38,7 @@
#include "base/win/scoped_gdi_object.h"
#include "views/accessibility/native_view_accessibility_win.h"
#endif
#if defined(OS_LINUX)
#if defined(TOOLKIT_USES_GTK)
#include "ui/base/gtk/scoped_handle_gtk.h"
#endif
......
......@@ -481,7 +481,7 @@ TEST_F(ViewTest, DISABLED_Painting) {
#if defined(OS_WIN)
TEST_F(ViewTest, RemoveNotification) {
#elif defined(TOOLKIT_USES_GTK)
#else
// TODO(beng): stopped working with widget hierarchy split,
// http://crbug.com/82364
TEST_F(ViewTest, DISABLED_RemoveNotification) {
......
......@@ -550,12 +550,14 @@
'../base/base.gyp:base',
'../base/base.gyp:test_support_base',
'../build/temp_gyp/googleurl.gyp:googleurl',
'../chrome/chrome.gyp:packed_resources',
'../skia/skia.gyp:skia',
'../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest',
'../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc',
'../ui/base/strings/ui_strings.gyp:ui_strings',
'../ui/gfx/compositor/compositor.gyp:compositor',
'../ui/ui.gyp:gfx_resources',
'../ui/ui.gyp:ui',
'../ui/ui.gyp:ui_resources',
......
......@@ -157,12 +157,12 @@ bool WidgetHasMouseCapture(const Widget* widget) {
TEST_F(WidgetTest, GetTopLevelWidget_Native) {
// Create a hierarchy of native widgets.
Widget* toplevel = CreateTopLevelPlatformWidget();
#if defined(OS_WIN)
gfx::NativeView parent = toplevel->GetNativeView();
#elif defined(TOOLKIT_USES_GTK)
#if defined(TOOLKIT_USES_GTK)
NativeWidgetGtk* native_widget =
static_cast<NativeWidgetGtk*>(toplevel->native_widget());
gfx::NativeView parent = native_widget->window_contents();
#else
gfx::NativeView parent = toplevel->GetNativeView();
#endif
Widget* child = CreateChildPlatformWidget(parent);
......
......@@ -10,7 +10,7 @@
#include <windows.h>
#include <uxtheme.h>
#include <vsstyle.h>
#else
#elif defined(TOOLKIT_USES_GTK)
#include <gtk/gtk.h>
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment