From 2535a2f5393527e97a1146579d19311aa6b9ffdc Mon Sep 17 00:00:00 2001 From: "tschmelcher@chromium.org" Date: Fri, 19 Feb 2010 23:12:54 +0000 Subject: Linux: Implement cursor type NONE. Also ensure fullscreen windows are created on the same X11 screen as the embedded window. Review URL: http://codereview.chromium.org/651066 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39507 0039d316-1c4b-4281-b951-d872f2087c98 --- o3d/plugin/cross/o3d_glue.cc | 41 +++++++++++++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 6 deletions(-) (limited to 'o3d/plugin/cross') diff --git a/o3d/plugin/cross/o3d_glue.cc b/o3d/plugin/cross/o3d_glue.cc index 18b31c6..b3dbf6b 100644 --- a/o3d/plugin/cross/o3d_glue.cc +++ b/o3d/plugin/cross/o3d_glue.cc @@ -887,13 +887,10 @@ void PluginObject::SetDisplay(Display *display) { } } -static unsigned int O3DToX11Cursor(o3d::Cursor::CursorType cursor_type) { +static unsigned int O3DToX11CursorShape(o3d::Cursor::CursorType cursor_type) { switch (cursor_type) { case o3d::Cursor::DEFAULT: return XC_arrow; - case o3d::Cursor::NONE: - NOTIMPLEMENTED(); - return XC_arrow; case o3d::Cursor::CROSSHAIR: return XC_crosshair; case o3d::Cursor::POINTER: @@ -927,13 +924,45 @@ static unsigned int O3DToX11Cursor(o3d::Cursor::CursorType cursor_type) { NOTIMPLEMENTED(); return XC_arrow; } + NOTIMPLEMENTED(); return XC_arrow; } +static Cursor O3DToX11Cursor(Display *display, Window window, + o3d::Cursor::CursorType cursor_type) { + switch (cursor_type) { + case o3d::Cursor::NONE: { + // There is no X11 primitive for hiding the cursor. The standard practice + // is to define a custom cursor from a 1x1 invisible pixmap. + static char zero[1] = {0}; + Pixmap zero_pixmap = XCreateBitmapFromData(display, window, zero, 1, 1); + DLOG_ASSERT(zero_pixmap); + if (!zero_pixmap) { + return 0; + } + // This could actually be any colour, since our mask pixmap specifies that + // no pixels are visible. + XColor black; + black.red = 0; + black.green = 0; + black.blue = 0; + Cursor cursor = XCreatePixmapCursor(display, zero_pixmap, zero_pixmap, + &black, &black, 0, 0); + XFreePixmap(display, zero_pixmap); + return cursor; + } + + default: + return XCreateFontCursor(display, O3DToX11CursorShape(cursor_type)); + } +} + void PluginObject::PlatformSpecificSetCursor() { if (!cursors_[cursor_type_]) { - cursors_[cursor_type_] = - XCreateFontCursor(display_, O3DToX11Cursor(cursor_type_)); + // According to the docs, the window here is only relevant for selecting the + // screen, and we always create our fullscreen and embedded windows on the + // same screen, so we can just always use the embedded window. + cursors_[cursor_type_] = O3DToX11Cursor(display_, window_, cursor_type_); } Window window = fullscreen_ ? fullscreen_window_ : window_; XDefineCursor(display_, window, cursors_[cursor_type_]); -- cgit v1.1