15 #include "graphicsWindow.h"
16 #include "graphicsPipe.h"
17 #include "config_display.h"
18 #include "mouseButton.h"
19 #include "keyboardButton.h"
20 #include "lightMutexHolder.h"
21 #include "lightReMutexHolder.h"
22 #include "throw_event.h"
23 #include "string_utils.h"
42 GraphicsOutput(engine, pipe, name, fb_prop, win_prop, flags, gsg, host, true),
43 _input_lock(
"GraphicsWindow::_input_lock"),
44 _properties_lock(
"GraphicsWindow::_properties_lock")
46 #ifdef DO_MEMORY_USAGE
47 MemoryUsage::update_type(
this,
this);
50 if (display_cat.is_debug()) {
52 <<
"Creating new window " << get_name() <<
"\n";
55 _properties.set_open(
false);
56 _properties.set_undecorated(
false);
57 _properties.set_fullscreen(
false);
58 _properties.set_minimized(
false);
59 _properties.set_cursor_hidden(
false);
62 request_properties(win_prop);
64 _window_event =
"window-event";
65 _got_expose_event =
false;
66 _unexposed_draw = win_unexposed_draw;
67 set_pixel_zoom(pixel_zoom);
79 PythonWinProcClasses::iterator iter;
80 for (iter = _python_window_proc_classes.begin();
81 iter != _python_window_proc_classes.end();
116 result = _requested_properties;
130 _rejected_properties.
clear();
147 result = _rejected_properties;
168 if (!_has_size && _requested_properties.
has_size()) {
173 _size = _requested_properties.
get_size();
206 _window_event = window_event;
220 result = _window_event;
251 _close_request_event = close_request_event;
267 result = _close_request_event;
286 result = _input_devices.size();
301 nassertr(device >= 0 && device < (
int)_input_devices.size(),
"");
302 result = _input_devices[device].get_name();
319 nassertr(device >= 0 && device < (
int)_input_devices.size(),
false);
320 result = _input_devices[device].has_pointer();
336 nassertr(device >= 0 && device < (
int)_input_devices.size(),
false);
337 result = _input_devices[device].has_keyboard();
361 nassertv(device >= 0 && device < (
int)_input_devices.size());
362 _input_devices[device].enable_pointer_events();
373 nassertv(device >= 0 && device < (
int)_input_devices.size());
374 _input_devices[device].disable_pointer_events();
385 nassertv(device >= 0 && device < (
int)_input_devices.size());
386 _input_devices[device].enable_pointer_mode(speed);
397 nassertv(device >= 0 && device < (
int)_input_devices.size());
398 _input_devices[device].disable_pointer_mode();
414 nassertr(device >= 0 && device < (
int)_input_devices.size(),
MouseData());
415 result = _input_devices[device].get_pointer();
460 nassertr(device >= 0 && device < (
int)_input_devices.size(),
false);
461 result = _input_devices[device].has_button_event();
477 nassertr(device >= 0 && device < (
int)_input_devices.size(),
ButtonEvent());
479 result = _input_devices[device].get_button_event();
497 nassertr(device >= 0 && device < (
int)_input_devices.size(),
false);
498 result = _input_devices[device].has_pointer_event();
510 get_pointer_events(
int device) {
514 nassertr(device >= 0 && device < (
int)_input_devices.size(), NULL);
515 nassertr(_input_devices[device].has_pointer_event(), NULL);
516 result = _input_devices[device].get_pointer_events();
613 properties = _requested_properties;
614 _requested_properties.
clear();
619 <<
"Unable to set window properties: " << properties <<
"\n";
712 int x_origin = 0, y_origin = 0;
720 (has_origin && (x_origin != _properties.
get_x_origin() ||
722 if (do_reshape_request(x_origin, y_origin, has_origin,
739 if (properties.has_mouse_mode() &&
752 void GraphicsWindow::
755 <<
"Closing " << get_type() <<
"\n";
760 _parent_window_handle->detach_child(_window_handle);
763 _window_handle = NULL;
764 _parent_window_handle = NULL;
775 bool GraphicsWindow::
786 void GraphicsWindow::
787 reset_window(
bool swapchain) {
789 <<
"Resetting " << get_type() <<
"\n";
801 bool GraphicsWindow::
802 do_reshape_request(
int x_origin,
int y_origin,
bool has_origin,
803 int x_size,
int y_size) {
815 void GraphicsWindow::
817 if (display_cat.is_debug()) {
819 <<
"system_changed_properties(" << properties <<
")\n";
830 if (_properties != old_properties) {
831 throw_event(_window_event,
this);
843 void GraphicsWindow::
844 system_changed_size(
int x_size,
int y_size) {
845 if (display_cat.is_debug()) {
847 <<
"system_changed_size(" << x_size <<
", " << y_size <<
")\n";
865 int index = (int)_input_devices.size();
866 _input_devices.push_back(device);
867 _input_devices.back().set_device_index(index);
877 void GraphicsWindow::
878 mouse_mode_relative() {
887 void GraphicsWindow::
888 mouse_mode_absolute() {
virtual bool supports_window_procs() const
Returns whether this window supports adding of Windows proc handlers.
int get_x_origin() const
Returns the x coordinate of the window's top-left corner, not including decorations.
This specialization on CallbackData is passed when the callback is initiated from from an implementat...
virtual void process_events()
Do whatever processing is necessary to ensure that the window responds to user events.
void set_size_and_recalc(int x, int y)
Changes the x_size and y_size, then recalculates structures that depend on size.
void clear()
Unsets all properties that have been specified so far, and resets the WindowProperties structure to i...
int get_num_input_devices() const
Returns the number of separate input devices associated with the window.
virtual void close_ime()
Forces the ime window to close if any.
This object represents a window on the desktop, not necessarily a Panda window.
bool is_fullscreen() const
Returns true if the window has been opened as a fullscreen window, false otherwise.
virtual bool move_pointer(int device, int x, int y)
Forces the pointer to the indicated position within the window, if possible.
virtual int get_num_touches()
Returns the current number of touches on this window.
void disable_pointer_mode(int device)
See GraphicsWindowInputDevice::disable_pointer_mode.
const WindowProperties get_properties() const
Returns the current properties of the window.
bool get_open() const
Returns true if the window is open.
void clear_origin()
Removes the origin specification from the properties.
bool get_minimized() const
Returns true if the window is minimized.
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 ButtonMap * get_keyboard_map() const
Returns a ButtonMap containing the association between raw buttons and virtual buttons.
const WindowProperties get_requested_properties() const
Returns the properties of the window that are currently requested.
int get_y_size() const
Returns size in pixels in the y dimension of the useful part of the window, not including decorations...
void set_size(const LVector2i &size)
Specifies the requested size of the window, in pixels.
void set_window_event(const string &window_event)
Changes the name of the event that is generated when this window is modified externally, e.g.
int get_y_origin() const
Returns the y coordinate of the window's top-left corner, not including decorations.
bool has_pointer(int device) const
Returns true if the nth input device has a screen-space pointer (for instance, a mouse), false otherwise.
virtual bool is_active() const
Returns true if the window is ready to be rendered into, false otherwise.
Records a set of pointer events that happened recently.
void request_properties(const WindowProperties &requested_properties)
Requests a property change on the window.
bool has_keyboard(int device) const
Returns true if the nth input device has a keyboard, false otherwise.
virtual void request_close()
This is called by the GraphicsEngine to request that the window (or whatever) close itself or...
string get_window_event() const
Returns the name of the event that is generated when this window is modified externally, e.g.
bool get_fullscreen() const
Returns true if the window is in fullscreen mode.
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
MouseData get_pointer(int device) const
Returns the MouseData associated with the nth input device's pointer.
const LVector2i & get_size() const
Returns size in pixels of the useful part of the window, not including decorations.
MouseMode get_mouse_mode() const
See set_mouse_mode().
A container for the various kinds of properties we might ask to have on a graphics window before we o...
ButtonEvent get_button_event(int device)
Assuming a previous call to has_button_event() returned true, this returns the pending button event...
string get_close_request_event() const
Returns the name of the event set via set_close_request_event().
Stores information for a single touch event.
void clear_mouse_mode()
Removes the mouse_mode specification from the properties.
static WindowProperties get_default()
Returns the "default" WindowProperties.
Similar to MutexHolder, but for a light mutex.
void clear_size()
Removes the size specification from the properties.
An object to create GraphicsOutputs that share a particular 3-D API.
virtual int verify_window_sizes(int numsizes, int *dimen)
Determines which of the indicated window sizes are supported by available hardware (e...
void set_origin(const LPoint2i &origin)
Specifies the origin on the screen (in pixels, relative to the top-left corner) at which the window s...
void enable_pointer_mode(int device, double speed)
See GraphicsWindowInputDevice::enable_pointer_mode.
void clear_open()
Removes the open specification from the properties.
This is a base class for the various different classes that represent the result of a frame of render...
Similar to MutexHolder, but for a light reentrant mutex.
bool is_any_specified() const
Returns true if any properties have been specified, false otherwise.
bool has_origin() const
Returns true if the window origin has been specified, false otherwise.
bool has_size() const
Returns true if the window size has been specified, false otherwise.
virtual TouchInfo get_touch_info(int index)
Returns the TouchInfo object describing the specified touch.
Holds the data that might be generated by a 2-d pointer input device, such as the mouse in the Graphi...
int get_x_size() const
Returns size in pixels in the x dimension of the useful part of the window, not including decorations...
void add_properties(const WindowProperties &other)
Sets any properties that are explicitly specified in other on this object.
void enable_pointer_events(int device)
Turn on the generation of pointer events.
string get_input_device_name(int device) const
Returns the name of the nth input device.
virtual void set_close_now()
This is called by the GraphicsEngine to insist that the window be closed immediately.
Encapsulates all the communication with a particular instance of a given rendering backend...
bool has_pointer_event(int device) const
Returns true if the indicated device has a pending pointer event (a mouse movement).
void clear_rejected_properties()
Empties the set of failed properties that will be returned by get_rejected_properties().
This class is the main interface to controlling the render process.
virtual bool is_touch_event(GraphicsWindowProcCallbackData *callbackData)
Returns whether the specified event msg is a touch message.
TypeHandle is the identifier used to differentiate C++ class types.
void disable_pointer_events(int device)
Turn off the generation of pointer events.
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
bool has_button_event(int device) const
Returns true if the indicated device has a pending button event (a mouse button or keyboard button do...
void set_open(bool open)
Specifies whether the window should be open.
bool has_open() const
Returns true if set_open() has been specified.
WindowProperties get_rejected_properties() const
Returns the set of properties that have recently been requested, but could not be applied to the wind...
virtual bool is_active() const
Returns true if the window is ready to be rendered into, false otherwise.
void clear_fullscreen()
Removes the fullscreen specification from the properties.
virtual void request_open()
This is called by the GraphicsEngine to request that the window (or whatever) open itself or...
bool has_fullscreen() const
Returns true if set_fullscreen() has been specified.
void set_close_request_event(const string &close_request_event)
Sets the event that is triggered when the user requests to close the window, e.g. ...