diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-23 00:08:46 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-23 00:08:46 +0000 |
commit | 02065c61d8f4b019bc0addb5b53db8426e0e5ce5 (patch) | |
tree | 943c00fe2093a97559b0c8abb4fa75a852b19fc3 | |
parent | 35d5d5d6bcc213e12f073867f36aff082afc47ca (diff) | |
download | chromium_src-02065c61d8f4b019bc0addb5b53db8426e0e5ce5.zip chromium_src-02065c61d8f4b019bc0addb5b53db8426e0e5ce5.tar.gz chromium_src-02065c61d8f4b019bc0addb5b53db8426e0e5ce5.tar.bz2 |
aura: Have aura and aura_demo build and run without gtk on linux.
BUG=97131
TEST=manually
Review URL: http://codereview.chromium.org/7981030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102403 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | build/common.gypi | 10 | ||||
-rw-r--r-- | ui/base/x/x11_util.cc | 46 | ||||
-rw-r--r-- | ui/base/x/x11_util.h | 11 | ||||
-rw-r--r-- | ui/ui.gyp | 2 |
4 files changed, 51 insertions, 18 deletions
diff --git a/build/common.gypi b/build/common.gypi index 27a1f08..4e8057e 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -1103,11 +1103,17 @@ ['exclude', '(^|/)(cocoa|mac)/'], ['exclude', '\\.mm?$' ] ], }], + ['use_x11!=1', { + 'sources/': [ + ['exclude', '_(chromeos|x|x11)(_unittest)?\\.(h|cc)$'], + ['exclude', '(^|/)x11_[^/]*\\.(h|cc)$'], + ], + }], ['toolkit_uses_gtk!=1', { 'sources/': [ - ['exclude', '_(chromeos|gtk|x|x11|xdg)(_unittest)?\\.(h|cc)$'], + ['exclude', '_(gtk|xdg)(_unittest)?\\.(h|cc)$'], ['exclude', '(^|/)gtk/'], - ['exclude', '(^|/)(gtk|x11)_[^/]*\\.(h|cc)$'], + ['exclude', '(^|/)gtk_[^/]*\\.(h|cc)$'], ], }], ['use_wayland!=1', { diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc index 82cdab7..39c2cff 100644 --- a/ui/base/x/x11_util.cc +++ b/ui/base/x/x11_util.cc @@ -8,10 +8,6 @@ #include "ui/base/x/x11_util.h" -#include <gdk/gdk.h> -#include <gdk/gdkx.h> -#include <gtk/gtk.h> - #include <sys/ipc.h> #include <sys/shm.h> @@ -28,6 +24,18 @@ #include "ui/gfx/rect.h" #include "ui/gfx/size.h" +#if defined(TOOLKIT_USES_GTK) +#include <gdk/gdk.h> +#include <gdk/gdkx.h> +#include <gtk/gtk.h> +#else +// TODO(sad): Use the new way of handling X errors when +// http://codereview.chromium.org/7889040/ lands. +#define gdk_error_trap_push() +#define gdk_error_trap_pop() false +#define gdk_flush() +#endif + namespace ui { namespace { @@ -68,13 +76,20 @@ int DefaultX11IOErrorHandler(Display* d) { _exit(1); } +Atom GetAtom(const char* name) { +#if defined(TOOLKIT_USES_GTK) + return gdk_x11_get_xatom_by_name_for_display( + gdk_display_get_default(), name); +#else + return XInternAtom(GetXDisplay(), name, false); +#endif +} + // Note: The caller should free the resulting value data. bool GetProperty(XID window, const std::string& property_name, long max_length, Atom* type, int* format, unsigned long* num_items, unsigned char** property) { - Atom property_atom = gdk_x11_get_xatom_by_name_for_display( - gdk_display_get_default(), property_name.c_str()); - + Atom property_atom = GetAtom(property_name.c_str()); unsigned long remaining_bytes = 0; return XGetWindowProperty(GetXDisplay(), window, @@ -93,7 +108,7 @@ bool GetProperty(XID window, const std::string& property_name, long max_length, } // namespace bool XDisplayExists() { - return (gdk_display_get_default() != NULL); + return (GetXDisplay() != NULL); } Display* GetXDisplay() { @@ -166,13 +181,14 @@ int GetDefaultScreen(Display* display) { } XID GetX11RootWindow() { - return GDK_WINDOW_XID(gdk_get_default_root_window()); + return DefaultRootWindow(GetXDisplay()); } bool GetCurrentDesktop(int* desktop) { return GetIntProperty(GetX11RootWindow(), "_NET_CURRENT_DESKTOP", desktop); } +#if defined(TOOLKIT_USES_GTK) XID GetX11WindowFromGtkWidget(GtkWidget* widget) { return GDK_WINDOW_XID(widget->window); } @@ -197,6 +213,7 @@ GtkWindow* GetGtkWindowFromX11Window(XID xid) { void* GetVisualFromGtkWidget(GtkWidget* widget) { return GDK_VISUAL_XVISUAL(gtk_widget_get_visual(widget)); } +#endif // defined(TOOLKIT_USES_GTK) int BitsPerPixelForPixmapDepth(Display* dpy, int depth) { int count; @@ -667,8 +684,7 @@ bool ChangeWindowDesktop(XID window, XID destination) { XEvent event; event.xclient.type = ClientMessage; event.xclient.window = window; - event.xclient.message_type = gdk_x11_get_xatom_by_name_for_display( - gdk_display_get_default(), "_NET_WM_DESKTOP"); + event.xclient.message_type = GetAtom("_NET_WM_DESKTOP"); event.xclient.format = 32; event.xclient.data.l[0] = desktop; event.xclient.data.l[1] = 1; // source indication @@ -684,8 +700,7 @@ void SetDefaultX11ErrorHandlers() { bool IsX11WindowFullScreen(XID window) { // First check if _NET_WM_STATE property contains _NET_WM_STATE_FULLSCREEN. - static Atom atom = gdk_x11_get_xatom_by_name_for_display( - gdk_display_get_default(), "_NET_WM_STATE_FULLSCREEN"); + static Atom atom = GetAtom("_NET_WM_STATE_FULLSCREEN"); std::vector<Atom> atom_properties; if (GetAtomArrayProperty(window, @@ -695,6 +710,7 @@ bool IsX11WindowFullScreen(XID window) { != atom_properties.end()) return true; +#if defined(TOOLKIT_USES_GTK) // As the last resort, check if the window size is as large as the main // screen. GdkRectangle monitor_rect; @@ -708,6 +724,10 @@ bool IsX11WindowFullScreen(XID window) { monitor_rect.y == window_rect.y() && monitor_rect.width == window_rect.width() && monitor_rect.height == window_rect.height(); +#else + NOTIMPLEMENTED(); + return false; +#endif } // ---------------------------------------------------------------------------- diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h index fb0304e..6763c04 100644 --- a/ui/base/x/x11_util.h +++ b/ui/base/x/x11_util.h @@ -19,13 +19,16 @@ #include "ui/base/ui_export.h" typedef unsigned long Atom; -typedef struct _GdkDrawable GdkWindow; -typedef struct _GtkWidget GtkWidget; -typedef struct _GtkWindow GtkWindow; typedef unsigned long XID; typedef unsigned long XSharedMemoryId; // ShmSeg in the X headers. typedef struct _XDisplay Display; +#if defined(TOOLKIT_USES_GTK) +typedef struct _GdkDrawable GdkWindow; +typedef struct _GtkWidget GtkWidget; +typedef struct _GtkWindow GtkWindow; +#endif + namespace gfx { class Rect; } @@ -72,6 +75,7 @@ UI_EXPORT XID GetX11RootWindow(); // Returns the user's current desktop. bool GetCurrentDesktop(int* desktop); +#if defined(TOOLKIT_USES_GTK) // Get the X window id for the given GTK widget. UI_EXPORT XID GetX11WindowFromGtkWidget(GtkWidget* widget); XID GetX11WindowFromGdkWindow(GdkWindow* window); @@ -84,6 +88,7 @@ UI_EXPORT GtkWindow* GetGtkWindowFromX11Window(XID xid); // Get a Visual from the given widget. Since we don't include the Xlib // headers, this is returned as a void*. UI_EXPORT void* GetVisualFromGtkWidget(GtkWidget* widget); +#endif // defined(TOOLKIT_USES_GTK) // Return the number of bits-per-pixel for a pixmap of the given depth UI_EXPORT int BitsPerPixelForPixmapDepth(Display* display, int depth); @@ -306,6 +306,8 @@ ['exclude', 'gfx/screen_win.cc'], ['exclude', 'base/win/mouse_wheel_util.cc'], ['exclude', 'base/win/mouse_wheel_util.h'], + ['exclude', 'base/x/active_window_watcher_x.cc'], + ['exclude', 'base/x/active_window_watcher_x.h'], ], }], ['use_glib == 1', { |