Panda3D
|
00001 // Filename: x11GraphicsWindow.h 00002 // Created by: rdb (07Jul09) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef X11GRAPHICSWINDOW_H 00016 #define X11GRAPHICSWINDOW_H 00017 00018 #include "pandabase.h" 00019 00020 #include "x11GraphicsPipe.h" 00021 #include "graphicsWindow.h" 00022 #include "buttonHandle.h" 00023 00024 #ifdef HAVE_XRANDR 00025 typedef unsigned short Rotation; 00026 typedef unsigned short SizeID; 00027 #endif 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Class : x11GraphicsWindow 00031 // Description : Interfaces to the X11 window system. 00032 //////////////////////////////////////////////////////////////////// 00033 class x11GraphicsWindow : public GraphicsWindow { 00034 public: 00035 x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe, 00036 const string &name, 00037 const FrameBufferProperties &fb_prop, 00038 const WindowProperties &win_prop, 00039 int flags, 00040 GraphicsStateGuardian *gsg, 00041 GraphicsOutput *host); 00042 virtual ~x11GraphicsWindow(); 00043 00044 virtual bool move_pointer(int device, int x, int y); 00045 virtual bool begin_frame(FrameMode mode, Thread *current_thread); 00046 virtual void end_frame(FrameMode mode, Thread *current_thread); 00047 00048 virtual void process_events(); 00049 virtual void set_properties_now(WindowProperties &properties); 00050 00051 INLINE X11_Window get_xwindow() const; 00052 00053 protected: 00054 virtual void close_window(); 00055 virtual bool open_window(); 00056 00057 virtual void mouse_mode_absolute(); 00058 virtual void mouse_mode_relative(); 00059 00060 void set_wm_properties(const WindowProperties &properties, 00061 bool already_mapped); 00062 00063 virtual void setup_colormap(XVisualInfo *visual); 00064 void handle_keystroke(XKeyEvent &event); 00065 void handle_keypress(XKeyEvent &event); 00066 void handle_keyrelease(XKeyEvent &event); 00067 00068 ButtonHandle get_button(XKeyEvent &key_event, bool allow_shift); 00069 ButtonHandle map_button(KeySym key); 00070 ButtonHandle get_mouse_button(XButtonEvent &button_event); 00071 00072 static Bool check_event(X11_Display *display, XEvent *event, char *arg); 00073 00074 void open_raw_mice(); 00075 void poll_raw_mice(); 00076 00077 private: 00078 X11_Cursor get_cursor(const Filename &filename); 00079 #ifdef HAVE_XCURSOR 00080 X11_Cursor read_ico(istream &ico); 00081 #endif 00082 00083 protected: 00084 X11_Display *_display; 00085 int _screen; 00086 X11_Window _xwindow; 00087 Colormap _colormap; 00088 XIC _ic; 00089 XVisualInfo *_visual_info; 00090 00091 #ifdef HAVE_XRANDR 00092 Rotation _orig_rotation; 00093 SizeID _orig_size_id; 00094 #endif 00095 00096 long _event_mask; 00097 bool _awaiting_configure; 00098 bool _dga_mouse_enabled; 00099 Atom _wm_delete_window; 00100 Atom _net_wm_window_type; 00101 Atom _net_wm_window_type_splash; 00102 Atom _net_wm_window_type_fullscreen; 00103 Atom _net_wm_state; 00104 Atom _net_wm_state_fullscreen; 00105 Atom _net_wm_state_above; 00106 Atom _net_wm_state_below; 00107 Atom _net_wm_state_add; 00108 Atom _net_wm_state_remove; 00109 00110 struct MouseDeviceInfo { 00111 int _fd; 00112 int _input_device_index; 00113 string _io_buffer; 00114 }; 00115 pvector<MouseDeviceInfo> _mouse_device_info; 00116 00117 public: 00118 static TypeHandle get_class_type() { 00119 return _type_handle; 00120 } 00121 static void init_type() { 00122 GraphicsWindow::init_type(); 00123 register_type(_type_handle, "x11GraphicsWindow", 00124 GraphicsWindow::get_class_type()); 00125 } 00126 virtual TypeHandle get_type() const { 00127 return get_class_type(); 00128 } 00129 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00130 00131 private: 00132 static TypeHandle _type_handle; 00133 00134 // Since the Panda API requests icons and cursors by filename, we 00135 // need a table mapping filenames to handles, so we can avoid 00136 // re-reading the file each time we change icons. 00137 pmap<Filename, X11_Cursor> _cursor_filenames; 00138 }; 00139 00140 #include "x11GraphicsWindow.I" 00141 00142 #endif