00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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
00031
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 bool _have_xrandr;
00092 #ifdef HAVE_XRANDR
00093 Rotation _orig_rotation;
00094 SizeID _orig_size_id;
00095 #endif
00096
00097 long _event_mask;
00098 bool _awaiting_configure;
00099 bool _dga_mouse_enabled;
00100 Atom _wm_delete_window;
00101 Atom _net_wm_window_type;
00102 Atom _net_wm_window_type_splash;
00103 Atom _net_wm_window_type_fullscreen;
00104 Atom _net_wm_state;
00105 Atom _net_wm_state_fullscreen;
00106 Atom _net_wm_state_above;
00107 Atom _net_wm_state_below;
00108 Atom _net_wm_state_add;
00109 Atom _net_wm_state_remove;
00110
00111 struct MouseDeviceInfo {
00112 int _fd;
00113 int _input_device_index;
00114 string _io_buffer;
00115 };
00116 pvector<MouseDeviceInfo> _mouse_device_info;
00117
00118 public:
00119 static TypeHandle get_class_type() {
00120 return _type_handle;
00121 }
00122 static void init_type() {
00123 GraphicsWindow::init_type();
00124 register_type(_type_handle, "x11GraphicsWindow",
00125 GraphicsWindow::get_class_type());
00126 }
00127 virtual TypeHandle get_type() const {
00128 return get_class_type();
00129 }
00130 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00131
00132 private:
00133 static TypeHandle _type_handle;
00134
00135
00136
00137
00138 pmap<Filename, X11_Cursor> _cursor_filenames;
00139 };
00140
00141 #include "x11GraphicsWindow.I"
00142
00143 #endif