diff options
-rw-r--r-- | o3d/plugin/cross/o3d_glue.cc | 41 | ||||
-rw-r--r-- | o3d/plugin/linux/main_linux.cc | 5 |
2 files changed, 39 insertions, 7 deletions
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_]); diff --git a/o3d/plugin/linux/main_linux.cc b/o3d/plugin/linux/main_linux.cc index 3f0f2c5..3ecf51f 100644 --- a/o3d/plugin/linux/main_linux.cc +++ b/o3d/plugin/linux/main_linux.cc @@ -925,6 +925,10 @@ bool PluginObject::RequestFullscreenDisplay() { GtkWidget *widget = gtk_window_new(GTK_WINDOW_TOPLEVEL); // The returned object counts as both a widget and a window. GtkWindow *window = GTK_WINDOW(widget); + // Ensure that the fullscreen window is displayed on the same screen as the + // embedded window. + GdkScreen *screen = gtk_window_get_screen(GTK_WINDOW(gtk_container_)); + gtk_window_set_screen(window, screen); // The window title shouldn't normally be visible, but the user will see it // if they Alt+Tab to another app. gtk_window_set_title(window, "O3D Application"); @@ -934,7 +938,6 @@ bool PluginObject::RequestFullscreenDisplay() { // with our GL rendering. gtk_widget_set_double_buffered(widget, FALSE); gtk_window_set_keep_above(window, TRUE); - GdkScreen *screen = gtk_window_get_screen(window); // In the case of Xinerama or TwinView, these will be the dimensions of the // whole desktop, which is wrong, but the window manager is smart enough to // restrict our size to that of the main screen. |