Panda3D
Loading...
Searching...
No Matches
x11GraphicsWindow.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file x11GraphicsWindow.h
10 * @author rdb
11 * @date 2009-07-07
12 */
13
14#ifndef X11GRAPHICSWINDOW_H
15#define X11GRAPHICSWINDOW_H
16
17#include "pandabase.h"
18
19#include "x11GraphicsPipe.h"
20#include "graphicsWindow.h"
21#include "buttonHandle.h"
22
23/**
24 * Interfaces to the X11 window system.
25 */
26class x11GraphicsWindow : public GraphicsWindow {
27public:
28 x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
29 const std::string &name,
30 const FrameBufferProperties &fb_prop,
31 const WindowProperties &win_prop,
32 int flags,
34 GraphicsOutput *host);
35 virtual ~x11GraphicsWindow();
36
37 virtual MouseData get_pointer(int device) const;
38 virtual bool move_pointer(int device, int x, int y);
39
40 virtual void clear(Thread *current_thread);
41 virtual bool begin_frame(FrameMode mode, Thread *current_thread);
42 virtual void end_frame(FrameMode mode, Thread *current_thread);
43
44 virtual void process_events();
45 virtual void set_properties_now(WindowProperties &properties);
46
47 INLINE X11_Window get_xwindow() const;
48
50
51protected:
52 virtual void close_window();
53 virtual bool open_window();
54
55 virtual void mouse_mode_absolute();
56 virtual void mouse_mode_relative();
57
58 void set_wm_properties(const WindowProperties &properties,
59 bool already_mapped);
60
61 virtual void setup_colormap(XVisualInfo *visual);
62 void handle_keystroke(XKeyEvent &event);
63 void handle_keypress(XKeyEvent &event);
64 void handle_keyrelease(XKeyEvent &event);
65
66 ButtonHandle get_button(XKeyEvent &key_event, bool allow_shift);
67 ButtonHandle map_button(KeySym key) const;
68 ButtonHandle map_raw_button(KeyCode key) const;
69 ButtonHandle get_mouse_button(XButtonEvent &button_event);
70 virtual ButtonMap *get_keyboard_map() const;
71
72 static Bool check_event(X11_Display *display, XEvent *event, char *arg);
73
74 void open_raw_mice();
75
76private:
77 X11_Cursor get_cursor(const Filename &filename);
78 X11_Cursor read_ico(std::istream &ico);
79
80protected:
81 X11_Display *_display;
82 int _screen;
83 X11_Window _xwindow;
84 Colormap _colormap;
85 XIC _ic;
86 XVisualInfo *_visual_info;
87 Rotation _orig_rotation;
88 SizeID _orig_size_id;
89
90 LVecBase2i _fixed_size;
91
93
94 long _event_mask;
95 clock_t _awaiting_configure_since;
96 bool _dga_mouse_enabled;
97 Bool _override_redirect;
98 Atom _wm_delete_window;
99
100 x11GraphicsPipe::pfn_XRRGetScreenInfo _XRRGetScreenInfo;
101 x11GraphicsPipe::pfn_XRRSetScreenConfig _XRRSetScreenConfig;
102
103public:
104 static TypeHandle get_class_type() {
105 return _type_handle;
106 }
107 static void init_type() {
108 GraphicsWindow::init_type();
109 register_type(_type_handle, "x11GraphicsWindow",
110 GraphicsWindow::get_class_type());
111 }
112 virtual TypeHandle get_type() const {
113 return get_class_type();
114 }
115 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
116
117private:
118 static TypeHandle _type_handle;
119
120 // Since the Panda API requests icons and cursors by filename, we need a
121 // table mapping filenames to handles, so we can avoid re-reading the file
122 // each time we change icons.
123 pmap<Filename, X11_Cursor> _cursor_filenames;
124};
125
126#include "x11GraphicsWindow.I"
127
128#endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A ButtonHandle represents a single button from any device, including keyboard buttons and mouse butto...
This class represents a map containing all of the buttons of a (keyboard) device, though it can also ...
Definition buttonMap.h:30
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
Encapsulates all the communication with a particular instance of a given rendering backend.
This is a virtual input device that represents the keyboard and mouse pair that is associated with a ...
A thread; that is, a lightweight process.
Definition thread.h:46
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
A container for the various kinds of properties we might ask to have on a graphics window before we o...
virtual bool begin_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread before beginning rendering for a given frame.
virtual void process_events()
Do whatever processing is necessary to ensure that the window responds to user events.
virtual void clear(Thread *current_thread)
Clears the entire framebuffer before rendering, according to the settings of get_color_clear_active()...
virtual bool move_pointer(int device, int x, int y)
Forces the pointer to the indicated position within the window, if possible.
void enable_detectable_auto_repeat()
Enables detectable auto-repeat if supported by the X server.
virtual void set_properties_now(WindowProperties &properties)
Applies the requested set of properties to the window, if possible, for instance to request a change ...
virtual MouseData get_pointer(int device) const
Returns the MouseData associated with the nth input device's pointer.
X11_Window get_xwindow() const
Returns the X11 Window handle.
virtual void end_frame(FrameMode mode, Thread *current_thread)
This function will be called within the draw thread after rendering is completed for a given frame.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BEGIN_PUBLISH typedef PointerData MouseData
Deprecated alias for PointerData.
Definition mouseData.h:23
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.