summaryrefslogtreecommitdiffstats
path: root/o3d/plugin
diff options
context:
space:
mode:
authortschmelcher@chromium.org <tschmelcher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-08 01:18:40 +0000
committertschmelcher@chromium.org <tschmelcher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-08 01:18:40 +0000
commit68884f33149a76b6e8b1c6614deb4b1aef74a4d2 (patch)
tree0d357f33da02b8e7f873eed1858c21375396bb3b /o3d/plugin
parent583b2a8cd1e7e5bcfd669e8858055dc6b8660a64 (diff)
downloadchromium_src-68884f33149a76b6e8b1c6614deb4b1aef74a4d2.zip
chromium_src-68884f33149a76b6e8b1c6614deb4b1aef74a4d2.tar.gz
chromium_src-68884f33149a76b6e8b1c6614deb4b1aef74a4d2.tar.bz2
Linux: implement setting cursor type
Review URL: http://codereview.chromium.org/527024 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35764 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/plugin')
-rw-r--r--o3d/plugin/cross/o3d_glue.cc78
-rw-r--r--o3d/plugin/cross/o3d_glue.h6
-rw-r--r--o3d/plugin/linux/main_linux.cc10
3 files changed, 83 insertions, 11 deletions
diff --git a/o3d/plugin/cross/o3d_glue.cc b/o3d/plugin/cross/o3d_glue.cc
index e6f7422..1914ac8 100644
--- a/o3d/plugin/cross/o3d_glue.cc
+++ b/o3d/plugin/cross/o3d_glue.cc
@@ -49,6 +49,10 @@
#include "plugin_mac.h"
#endif
+#ifdef OS_LINUX
+#include <X11/cursorfont.h>
+#endif
+
namespace glue {
namespace _o3d {
@@ -134,6 +138,7 @@ PluginObject::PluginObject(NPP npp)
#ifdef OS_LINUX
display_(NULL),
window_(0),
+ fullscreen_window_(0),
xt_widget_(NULL),
xt_app_context_(NULL),
xt_interval_(0),
@@ -156,7 +161,7 @@ PluginObject::PluginObject(NPP npp)
cursor_type_(o3d::Cursor::DEFAULT),
prev_width_(0),
prev_height_(0) {
-#ifdef OS_WIN
+#if defined(OS_WIN) || defined(OS_LINUX)
memset(cursors_, 0, sizeof(cursors_));
#endif
@@ -210,10 +215,11 @@ void PluginObject::Init(int argc, char* argn[], char* argv[]) {
void PluginObject::TearDown() {
#ifdef OS_WIN
ClearPluginProperty(hWnd_);
-#endif // OS_WIN
-#ifdef OS_MACOSX
+#elif defined(OS_MACOSX)
o3d::ReleaseSafariBrowserWindow(mac_cocoa_window_);
-#endif
+#elif defined(OS_LINUX)
+ SetDisplay(NULL);
+#endif // OS_WIN
UnmapAll();
// Delete the StreamManager to cleanup any streams that are in midflight.
@@ -866,8 +872,70 @@ void PluginObject::PlatformSpecificSetCursor() {
#ifdef OS_LINUX
+void PluginObject::SetDisplay(Display *display) {
+ if (display_ != display) {
+ if (display_) {
+ for (int i = 0; i < o3d::Cursor::NUM_CURSORS; ++i) {
+ if (cursors_[i]) {
+ XFreeCursor(display_, cursors_[i]);
+ cursors_[i] = 0;
+ }
+ }
+ }
+ display_ = display;
+ }
+}
+
+static unsigned int O3DToX11Cursor(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:
+ return XC_hand2;
+ case o3d::Cursor::E_RESIZE:
+ return XC_right_side;
+ case o3d::Cursor::NE_RESIZE:
+ return XC_top_right_corner;
+ case o3d::Cursor::NW_RESIZE:
+ return XC_top_left_corner;
+ case o3d::Cursor::N_RESIZE:
+ return XC_top_side;
+ case o3d::Cursor::SE_RESIZE:
+ return XC_bottom_right_corner;
+ case o3d::Cursor::SW_RESIZE:
+ return XC_bottom_left_corner;
+ case o3d::Cursor::S_RESIZE:
+ return XC_bottom_side;
+ case o3d::Cursor::W_RESIZE:
+ return XC_left_side;
+ case o3d::Cursor::MOVE:
+ return XC_fleur;
+ case o3d::Cursor::TEXT:
+ return XC_xterm;
+ case o3d::Cursor::WAIT:
+ return XC_watch;
+ case o3d::Cursor::PROGRESS:
+ NOTIMPLEMENTED();
+ return XC_watch;
+ case o3d::Cursor::HELP:
+ NOTIMPLEMENTED();
+ return XC_arrow;
+ }
+ return XC_arrow;
+}
+
void PluginObject::PlatformSpecificSetCursor() {
- // TODO: fill this in.
+ if (!cursors_[cursor_type_]) {
+ cursors_[cursor_type_] =
+ XCreateFontCursor(display_, O3DToX11Cursor(cursor_type_));
+ }
+ Window window = fullscreen_ ? fullscreen_window_ : window_;
+ XDefineCursor(display_, window, cursors_[cursor_type_]);
}
#endif // OS_LINUX
diff --git a/o3d/plugin/cross/o3d_glue.h b/o3d/plugin/cross/o3d_glue.h
index fb8c5b7..2375173 100644
--- a/o3d/plugin/cross/o3d_glue.h
+++ b/o3d/plugin/cross/o3d_glue.h
@@ -224,6 +224,7 @@ class PluginObject: public NPObject {
GdkEventConfigure *configure_event);
gboolean OnGtkDelete(GtkWidget *widget,
GdkEvent *configure);
+ void SetDisplay(Display *display);
#elif defined(OS_MACOSX)
void SetFullscreenOverlayMacWindow(WindowRef window) {
mac_fullscreen_overlay_window_ = window;
@@ -279,8 +280,8 @@ class PluginObject: public NPObject {
#endif // OS_MACOSX
#ifdef OS_LINUX
- Display *display_;
Window window_;
+ Window fullscreen_window_;
// Xt mode
Widget xt_widget_;
@@ -477,6 +478,9 @@ class PluginObject: public NPObject {
HCURSOR cursors_[o3d::Cursor::NUM_CURSORS]; // loaded windows cursors.
HCURSOR hCursor_;
bool painted_once_;
+#elif defined(OS_LINUX)
+ Display *display_;
+ Cursor cursors_[o3d::Cursor::NUM_CURSORS]; // loaded windows cursors.
#endif // OS_WIN
#if defined(CB_SERVICE_REMOTE)
diff --git a/o3d/plugin/linux/main_linux.cc b/o3d/plugin/linux/main_linux.cc
index 8184a19..9162a91 100644
--- a/o3d/plugin/linux/main_linux.cc
+++ b/o3d/plugin/linux/main_linux.cc
@@ -747,7 +747,6 @@ NPError NPP_Destroy(NPP instance, NPSavedData **save) {
obj->event_handler_id_ = 0;
obj->window_ = 0;
obj->drawable_ = 0;
- obj->display_ = NULL;
obj->TearDown();
NPN_ReleaseObject(obj);
@@ -807,7 +806,7 @@ NPError NPP_SetWindow(NPP instance, NPWindow *window) {
obj->CreateRenderer(default_display);
obj->client()->Init();
- obj->display_ = display;
+ obj->SetDisplay(display);
obj->window_ = xwindow;
obj->drawable_ = drawable;
}
@@ -863,16 +862,16 @@ gboolean PluginObject::OnGtkConfigure(GtkWidget *widget,
if (fullscreen_pending_) {
// Our fullscreen window has been placed and sized. Switch to it.
fullscreen_pending_ = false;
- Window fullscreen_window =
- GDK_WINDOW_XID(gtk_fullscreen_container_->window);
+ fullscreen_window_ = GDK_WINDOW_XID(gtk_fullscreen_container_->window);
DisplayWindowLinux display;
display.set_display(display_);
- display.set_window(fullscreen_window);
+ display.set_window(fullscreen_window_);
prev_width_ = renderer()->width();
prev_height_ = renderer()->height();
if (!renderer()->GoFullscreen(display, fullscreen_region_mode_id_)) {
gtk_widget_destroy(gtk_fullscreen_container_);
gtk_fullscreen_container_ = NULL;
+ fullscreen_window_ = 0;
// The return value is for whether we handled the event, not whether it
// was successful, so return TRUE event for error.
return TRUE;
@@ -964,6 +963,7 @@ void PluginObject::CancelFullscreenDisplay() {
gtk_widget_destroy(gtk_fullscreen_container_);
gtk_widget_unref(gtk_fullscreen_container_);
gtk_fullscreen_container_ = NULL;
+ fullscreen_window_ = 0;
fullscreen_ = false;
}
} // namespace _o3d