Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: plugin/cross/o3d_glue.cc

Issue 651066: Linux: Implement cursor type NONE. Also ensure fullscreen windows are created... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/o3d/
Patch Set: Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | plugin/linux/main_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2009, Google Inc. 2 * Copyright 2009, Google Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 if (cursors_[i]) { 880 if (cursors_[i]) {
881 XFreeCursor(display_, cursors_[i]); 881 XFreeCursor(display_, cursors_[i]);
882 cursors_[i] = 0; 882 cursors_[i] = 0;
883 } 883 }
884 } 884 }
885 } 885 }
886 display_ = display; 886 display_ = display;
887 } 887 }
888 } 888 }
889 889
890 static unsigned int O3DToX11Cursor(o3d::Cursor::CursorType cursor_type) { 890 static unsigned int O3DToX11CursorShape(o3d::Cursor::CursorType cursor_type) {
891 switch (cursor_type) { 891 switch (cursor_type) {
892 case o3d::Cursor::DEFAULT: 892 case o3d::Cursor::DEFAULT:
893 return XC_arrow; 893 return XC_arrow;
894 case o3d::Cursor::NONE:
895 NOTIMPLEMENTED();
896 return XC_arrow;
897 case o3d::Cursor::CROSSHAIR: 894 case o3d::Cursor::CROSSHAIR:
898 return XC_crosshair; 895 return XC_crosshair;
899 case o3d::Cursor::POINTER: 896 case o3d::Cursor::POINTER:
900 return XC_hand2; 897 return XC_hand2;
901 case o3d::Cursor::E_RESIZE: 898 case o3d::Cursor::E_RESIZE:
902 return XC_right_side; 899 return XC_right_side;
903 case o3d::Cursor::NE_RESIZE: 900 case o3d::Cursor::NE_RESIZE:
904 return XC_top_right_corner; 901 return XC_top_right_corner;
905 case o3d::Cursor::NW_RESIZE: 902 case o3d::Cursor::NW_RESIZE:
906 return XC_top_left_corner; 903 return XC_top_left_corner;
(...skipping 13 matching lines...) Expand all
920 return XC_xterm; 917 return XC_xterm;
921 case o3d::Cursor::WAIT: 918 case o3d::Cursor::WAIT:
922 return XC_watch; 919 return XC_watch;
923 case o3d::Cursor::PROGRESS: 920 case o3d::Cursor::PROGRESS:
924 NOTIMPLEMENTED(); 921 NOTIMPLEMENTED();
925 return XC_watch; 922 return XC_watch;
926 case o3d::Cursor::HELP: 923 case o3d::Cursor::HELP:
927 NOTIMPLEMENTED(); 924 NOTIMPLEMENTED();
928 return XC_arrow; 925 return XC_arrow;
929 } 926 }
927 NOTIMPLEMENTED();
930 return XC_arrow; 928 return XC_arrow;
931 } 929 }
932 930
931 static Cursor O3DToX11Cursor(Display *display, Window window,
932 o3d::Cursor::CursorType cursor_type) {
933 switch (cursor_type) {
934 case o3d::Cursor::NONE: {
935 // There is no X11 primitive for hiding the cursor. The standard practice
936 // is to define a custom cursor from a 1x1 invisible pixmap.
937 static char zero[1] = {0};
938 Pixmap zero_pixmap = XCreateBitmapFromData(display, window, zero, 1, 1);
939 DLOG_ASSERT(zero_pixmap);
940 if (!zero_pixmap) {
941 return 0;
942 }
943 // This could actually be any colour, since our mask pixmap specifies that
944 // no pixels are visible.
945 XColor black;
946 black.red = 0;
947 black.green = 0;
948 black.blue = 0;
949 Cursor cursor = XCreatePixmapCursor(display, zero_pixmap, zero_pixmap,
950 &black, &black, 0, 0);
951 XFreePixmap(display, zero_pixmap);
952 return cursor;
953 }
954
955 default:
956 return XCreateFontCursor(display, O3DToX11CursorShape(cursor_type));
957 }
958 }
959
933 void PluginObject::PlatformSpecificSetCursor() { 960 void PluginObject::PlatformSpecificSetCursor() {
934 if (!cursors_[cursor_type_]) { 961 if (!cursors_[cursor_type_]) {
935 cursors_[cursor_type_] = 962 // According to the docs, the window here is only relevant for selecting the
936 XCreateFontCursor(display_, O3DToX11Cursor(cursor_type_)); 963 // screen, and we always create our fullscreen and embedded windows on the
964 // same screen, so we can just always use the embedded window.
965 cursors_[cursor_type_] = O3DToX11Cursor(display_, window_, cursor_type_);
937 } 966 }
938 Window window = fullscreen_ ? fullscreen_window_ : window_; 967 Window window = fullscreen_ ? fullscreen_window_ : window_;
939 XDefineCursor(display_, window, cursors_[cursor_type_]); 968 XDefineCursor(display_, window, cursors_[cursor_type_]);
940 } 969 }
941 970
942 #endif // OS_LINUX 971 #endif // OS_LINUX
943 972
944 namespace { 973 namespace {
945 void TickPluginObject(void* data) { 974 void TickPluginObject(void* data) {
946 PluginObject* plugin_object = static_cast<PluginObject*>(data); 975 PluginObject* plugin_object = static_cast<PluginObject*>(data);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 PluginObject *plugin_object = static_cast<PluginObject *>(npp->pdata); 1088 PluginObject *plugin_object = static_cast<PluginObject *>(npp->pdata);
1060 if (plugin_object) { // May not be initialized yet. 1089 if (plugin_object) { // May not be initialized yet.
1061 return plugin_object->client()->ProfileToString(); 1090 return plugin_object->client()->ProfileToString();
1062 } else { 1091 } else {
1063 return ""; 1092 return "";
1064 } 1093 }
1065 } 1094 }
1066 1095
1067 } // namespace globals 1096 } // namespace globals
1068 } // namespace glue 1097 } // namespace glue
OLDNEW
« no previous file with comments | « no previous file | plugin/linux/main_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698