Panda3D
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends

GraphicsWindow Class Reference

A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive display. More...

#include "graphicsWindow.h"

Inheritance diagram for GraphicsWindow:
GraphicsOutput GraphicsOutputBase DrawableRegion TypedWritableReferenceCount TypedWritable ReferenceCount TypedObject MemoryBase MemoryBase eglGraphicsWindow IPhoneGraphicsWindow osxGraphicsWindow WinGraphicsWindow x11GraphicsWindow wdxGraphicsWindow8 wdxGraphicsWindow9 wglGraphicsWindow glxGraphicsWindow

List of all members.

Public Member Functions

void clear_rejected_properties ()
 Empties the set of failed properties that will be returned by get_rejected_properties().
virtual void close_ime ()
 Forces the ime window to close if any.
void disable_pointer_events (int device)
 Turn off the generation of pointer events.
void disable_pointer_mode (int device)
 See GraphicsWindowInputDevice::disable_pointer_mode.
void enable_pointer_events (int device)
 Turn on the generation of pointer events.
void enable_pointer_mode (int device, double speed)
 See GraphicsWindowInputDevice::enable_pointer_mode.
virtual TypeHandle force_init_type ()
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().
string get_input_device_name (int device) const
 Returns the name of the nth input device.
int get_num_input_devices () const
 Returns the number of separate input devices associated with the window.
MouseData get_pointer (int device) const
 Returns the MouseData associated with the nth input device's pointer.
const WindowProperties get_properties () const
 Returns the current properties of the window.
WindowProperties get_rejected_properties () const
 Returns the set of properties that have recently been requested, but could not be applied to the window for some reason.
const WindowProperties get_requested_properties () const
 Returns the properties of the window that are currently requested.
virtual TypeHandle get_type () const
string get_window_event () const
 Returns the name of the event that is generated when this window is modified externally, e.g.
WindowHandleget_window_handle () const
 Returns the WindowHandle corresponding to this window on the desktop.
bool has_button_event (int device) const
 Returns true if the indicated device has a pending button event (a mouse button or keyboard button down/up), false otherwise.
bool has_keyboard (int device) const
 Returns true if the nth input device has a keyboard, false otherwise.
bool has_pointer (int device) const
 Returns true if the nth input device has a screen-space pointer (for instance, a mouse), false otherwise.
bool has_pointer_event (int device) const
 Returns true if the indicated device has a pending pointer event (a mouse movement).
virtual bool is_active () const
 Returns true if the window is ready to be rendered into, false otherwise.
bool is_closed () const
 Returns true if the window has not yet been opened, or has been fully closed, false if it is open.
bool is_fullscreen () const
 Returns true if the window has been opened as a fullscreen window, false otherwise.
 MAKE_SEQ (get_input_device_names, get_num_input_devices, get_input_device_name)
virtual bool move_pointer (int device, int x, int y)
 Forces the pointer to the indicated position within the window, if possible.
virtual void process_events ()
 Do whatever processing is necessary to ensure that the window responds to user events.
 PT (PointerEventList) get_pointer_events(int device)
virtual void request_close ()
 This is called by the GraphicsEngine to request that the window (or whatever) close itself or, in general, make itself invalid, at the next call to process_events().
virtual void request_open ()
 This is called by the GraphicsEngine to request that the window (or whatever) open itself or, in general, make itself valid, at the next call to process_events().
void request_properties (const WindowProperties &requested_properties)
 Requests a property change on the window.
virtual void set_close_now ()
 This is called by the GraphicsEngine to insist that the window be closed immediately.
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.
virtual void set_properties_now (WindowProperties &properties)
 Applies the requested set of properties to the window, if possible, for instance to request a change in size or minimization status.
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.
virtual int verify_window_sizes (int numsizes, int *dimen)
 Determines which of the indicated window sizes are supported by available hardware (e.g.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()

Protected Types

typedef
vector_GraphicsWindowInputDevice 
InputDevices

Protected Member Functions

 GraphicsWindow (GraphicsEngine *engine, GraphicsPipe *pipe, const string &name, const FrameBufferProperties &fb_prop, const WindowProperties &win_prop, int flags, GraphicsStateGuardian *gsg, GraphicsOutput *host)
 Normally, the GraphicsWindow constructor is not called directly; these are created instead via the GraphicsEngine::make_window() function.
void add_input_device (const GraphicsWindowInputDevice &device)
 Adds a GraphicsWindowInputDevice to the vector.
virtual void close_window ()
 Closes the window right now.
virtual bool do_reshape_request (int x_origin, int y_origin, bool has_origin, int x_size, int y_size)
 Called from the window thread in response to a request from within the code (via request_properties()) to change the size and/or position of the window.
virtual void mouse_mode_absolute ()
 reattaches mouse to location
virtual void mouse_mode_relative ()
 detaches mouse.
virtual bool open_window ()
 Opens the window right now.
 PT (WindowHandle) _parent_window_handle
 PT (WindowHandle) _window_handle
virtual void reset_window (bool swapchain)
 resets the window framebuffer from its derived children.
void system_changed_properties (const WindowProperties &properties)
 Should be called (from within the window thread) when process_events() detects an external change in some important window property; for instance, when the user resizes the window.
void system_changed_size (int x_size, int y_size)
 An internal function to update all the DisplayRegions with the new size of the window.

Protected Attributes

InputDevices _input_devices
LightMutex _input_lock
WindowProperties _properties

Friends

class GraphicsEngine

Detailed Description

A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive display.

Definition at line 39 of file graphicsWindow.h.


Constructor & Destructor Documentation

GraphicsWindow::GraphicsWindow ( GraphicsEngine engine,
GraphicsPipe pipe,
const string &  name,
const FrameBufferProperties fb_prop,
const WindowProperties win_prop,
int  flags,
GraphicsStateGuardian gsg,
GraphicsOutput host 
) [protected]

Member Function Documentation

void GraphicsWindow::add_input_device ( const GraphicsWindowInputDevice device) [inline, protected]

Adds a GraphicsWindowInputDevice to the vector.

Definition at line 65 of file graphicsWindow.I.

Referenced by x11GraphicsWindow::open_raw_mice().

void GraphicsWindow::clear_rejected_properties ( )

Empties the set of failed properties that will be returned by get_rejected_properties().

Definition at line 122 of file graphicsWindow.cxx.

References WindowProperties::clear().

void GraphicsWindow::close_ime ( ) [virtual]

Forces the ime window to close if any.

Reimplemented in WinGraphicsWindow.

Definition at line 424 of file graphicsWindow.cxx.

void GraphicsWindow::close_window ( ) [protected, virtual]

Closes the window right now.

Called from the window thread.

Reimplemented in wdxGraphicsWindow8, wdxGraphicsWindow9, eglGraphicsWindow, glxGraphicsWindow, IPhoneGraphicsWindow, osxGraphicsWindow, wglGraphicsWindow, WinGraphicsWindow, and x11GraphicsWindow.

Definition at line 749 of file graphicsWindow.cxx.

Referenced by set_properties_now().

void GraphicsWindow::disable_pointer_events ( int  device)

Turn off the generation of pointer events.

Definition at line 355 of file graphicsWindow.cxx.

void GraphicsWindow::disable_pointer_mode ( int  device)
bool GraphicsWindow::do_reshape_request ( int  x_origin,
int  y_origin,
bool  has_origin,
int  x_size,
int  y_size 
) [protected, virtual]

Called from the window thread in response to a request from within the code (via request_properties()) to change the size and/or position of the window.

Returns true if the window is successfully changed, or false if there was a problem.

Reimplemented in osxGraphicsWindow, and WinGraphicsWindow.

Definition at line 798 of file graphicsWindow.cxx.

Referenced by set_properties_now().

void GraphicsWindow::enable_pointer_events ( int  device)

Turn on the generation of pointer events.

Definition at line 343 of file graphicsWindow.cxx.

void GraphicsWindow::enable_pointer_mode ( int  device,
double  speed 
)
ButtonEvent GraphicsWindow::get_button_event ( int  device)

Assuming a previous call to has_button_event() returned true, this returns the pending button event.

Definition at line 455 of file graphicsWindow.cxx.

References has_button_event().

string GraphicsWindow::get_close_request_event ( ) const

Returns the name of the event set via set_close_request_event().

If this string is nonempty, then when the user requests to close window, this event will be generated instead. See set_close_request_event().

Definition at line 259 of file graphicsWindow.cxx.

Referenced by x11GraphicsWindow::process_events(), eglGraphicsWindow::process_events(), and WinGraphicsWindow::window_proc().

string GraphicsWindow::get_input_device_name ( int  device) const

Returns the name of the nth input device.

Definition at line 292 of file graphicsWindow.cxx.

int GraphicsWindow::get_num_input_devices ( ) const

Returns the number of separate input devices associated with the window.

Typically, a window will have exactly one input device: the keyboard/mouse pair. However, some windows may have no input devices, and others may add additional devices, for instance for a joystick.

Definition at line 277 of file graphicsWindow.cxx.

MouseData GraphicsWindow::get_pointer ( int  device) const

Returns the MouseData associated with the nth input device's pointer.

Definition at line 392 of file graphicsWindow.cxx.

const WindowProperties GraphicsWindow::get_properties ( ) const
WindowProperties GraphicsWindow::get_rejected_properties ( ) const

Returns the set of properties that have recently been requested, but could not be applied to the window for some reason.

This set of properties will remain unchanged until they are changed by a new failed request, or clear_rejected_properties() is called.

Definition at line 137 of file graphicsWindow.cxx.

const WindowProperties GraphicsWindow::get_requested_properties ( ) const

Returns the properties of the window that are currently requested.

These properties will be applied to the window (if valid) at the next execution of process_events().

Definition at line 106 of file graphicsWindow.cxx.

string GraphicsWindow::get_window_event ( ) const

Returns the name of the event that is generated when this window is modified externally, e.g.

to be resized or closed by the user. See set_window_event().

Definition at line 212 of file graphicsWindow.cxx.

WindowHandle * GraphicsWindow::get_window_handle ( ) const [inline]

Returns the WindowHandle corresponding to this window on the desktop.

This is mainly useful for communicating with external libraries. Use window_handle->get_os_handle()->get_handle(), or window_handle->get_string_handle(), to get the actual OS-specific window handle object, whatever type that might be.

Definition at line 55 of file graphicsWindow.I.

bool GraphicsWindow::has_button_event ( int  device) const

Returns true if the indicated device has a pending button event (a mouse button or keyboard button down/up), false otherwise.

If this returns true, the particular event may be extracted via get_button_event().

Definition at line 438 of file graphicsWindow.cxx.

Referenced by get_button_event().

bool GraphicsWindow::has_keyboard ( int  device) const

Returns true if the nth input device has a keyboard, false otherwise.

Definition at line 327 of file graphicsWindow.cxx.

bool GraphicsWindow::has_pointer ( int  device) const

Returns true if the nth input device has a screen-space pointer (for instance, a mouse), false otherwise.

Definition at line 310 of file graphicsWindow.cxx.

bool GraphicsWindow::has_pointer_event ( int  device) const

Returns true if the indicated device has a pending pointer event (a mouse movement).

If this returns true, the particular event may be extracted via get_pointer_events().

Definition at line 475 of file graphicsWindow.cxx.

bool GraphicsWindow::is_active ( ) const [virtual]

Returns true if the window is ready to be rendered into, false otherwise.

Reimplemented from GraphicsOutput.

Definition at line 181 of file graphicsWindow.cxx.

References WindowProperties::get_minimized(), and WindowProperties::get_open().

Referenced by wdxGraphicsWindow9::end_flip(), and wdxGraphicsWindow8::end_flip().

bool GraphicsWindow::is_closed ( ) const [inline]

Returns true if the window has not yet been opened, or has been fully closed, false if it is open.

The window is not opened immediately after GraphicsEngine::make_window() is called; nor is it closed immediately after GraphicsEngine::remove_window() is called. Either operation may take a frame or two.

Definition at line 28 of file graphicsWindow.I.

References WindowProperties::get_open().

bool GraphicsWindow::is_fullscreen ( ) const [inline]
void GraphicsWindow::mouse_mode_absolute ( ) [protected, virtual]

reattaches mouse to location

Reimplemented in osxGraphicsWindow, and x11GraphicsWindow.

Definition at line 921 of file graphicsWindow.cxx.

Referenced by set_properties_now().

void GraphicsWindow::mouse_mode_relative ( ) [protected, virtual]

detaches mouse.

Only mouse delta from now on.

Reimplemented in osxGraphicsWindow, and x11GraphicsWindow.

Definition at line 909 of file graphicsWindow.cxx.

Referenced by set_properties_now().

bool GraphicsWindow::move_pointer ( int  device,
int  x,
int  y 
) [virtual]

Forces the pointer to the indicated position within the window, if possible.

Returns true if successful, false on failure. This may fail if the mouse is not currently within the window, or if the API doesn't support this operation.

Reimplemented in eglGraphicsWindow, osxGraphicsWindow, WinGraphicsWindow, and x11GraphicsWindow.

Definition at line 413 of file graphicsWindow.cxx.

bool GraphicsWindow::open_window ( ) [protected, virtual]

Opens the window right now.

Called from the window thread. Returns true if the window is successfully opened, or false if there was a problem.

Reimplemented in wdxGraphicsWindow8, wdxGraphicsWindow9, eglGraphicsWindow, glxGraphicsWindow, IPhoneGraphicsWindow, osxGraphicsWindow, wglGraphicsWindow, WinGraphicsWindow, and x11GraphicsWindow.

Definition at line 772 of file graphicsWindow.cxx.

Referenced by set_properties_now().

void GraphicsWindow::process_events ( ) [virtual]

Do whatever processing is necessary to ensure that the window responds to user events.

Also, honor any requests recently made via request_properties().

This function is called only within the window thread.

Reimplemented from GraphicsOutput.

Reimplemented in eglGraphicsWindow, IPhoneGraphicsWindow, osxGraphicsWindow, WinGraphicsWindow, and x11GraphicsWindow.

Definition at line 586 of file graphicsWindow.cxx.

References WindowProperties::add_properties(), WindowProperties::clear(), WindowProperties::is_any_specified(), and set_properties_now().

void GraphicsWindow::request_close ( ) [virtual]

This is called by the GraphicsEngine to request that the window (or whatever) close itself or, in general, make itself invalid, at the next call to process_events().

By that time we promise the gsg pointer will be cleared.

Reimplemented from GraphicsOutput.

Definition at line 555 of file graphicsWindow.cxx.

References request_properties(), and WindowProperties::set_open().

void GraphicsWindow::request_open ( ) [virtual]

This is called by the GraphicsEngine to request that the window (or whatever) open itself or, in general, make itself valid, at the next call to process_events().

Reimplemented from GraphicsOutput.

Definition at line 539 of file graphicsWindow.cxx.

References request_properties(), and WindowProperties::set_open().

void GraphicsWindow::request_properties ( const WindowProperties requested_properties)

Requests a property change on the window.

For example, use this method to request a window change size or minimize or something.

The change is not made immediately; rather, the request is saved and will be applied the next time the window task is run (probably at the next frame).

Definition at line 158 of file graphicsWindow.cxx.

References WindowProperties::add_properties(), WindowProperties::get_x_size(), WindowProperties::get_y_size(), and WindowProperties::has_size().

Referenced by GraphicsWindow(), request_close(), and request_open().

void GraphicsWindow::reset_window ( bool  swapchain) [protected, virtual]

resets the window framebuffer from its derived children.

Does nothing here.

Reimplemented from GraphicsOutput.

Reimplemented in wdxGraphicsWindow8, and wdxGraphicsWindow9.

Definition at line 783 of file graphicsWindow.cxx.

void GraphicsWindow::set_close_now ( ) [virtual]

This is called by the GraphicsEngine to insist that the window be closed immediately.

This is only called from the window thread.

Reimplemented from GraphicsOutput.

Definition at line 569 of file graphicsWindow.cxx.

References WindowProperties::set_open(), and set_properties_now().

void GraphicsWindow::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.

via alt-F4, or clicking on the close box.

The default for each window is for this event to be the empty string, which means the window-close request is handled immediately by Panda (and the window will be closed without the app getting a chance to intervene). If you set this to a nonempty string, then the window is not closed, but instead the event is thrown. It is then up to the app to respond appropriately, for instance by presenting an "are you sure?" dialog box, and eventually calling close_window() when the user is sure.

It is considered poor form to set this string and then not handle the event. This can frustrate the user by making it difficult for him to cleanly shut down the application (and may force the user to hard-kill the app, or reboot the machine).

Definition at line 244 of file graphicsWindow.cxx.

void GraphicsWindow::set_properties_now ( WindowProperties properties) [virtual]

Applies the requested set of properties to the window, if possible, for instance to request a change in size or minimization status.

The window properties are applied immediately, rather than waiting until the next frame. This implies that this method may *only* be called from within the window thread.

The properties that have been applied are cleared from the structure by this function; so on return, whatever remains in the properties structure are those that were unchanged for some reason (probably because the underlying interface does not support changing that property on an open window).

Reimplemented in eglGraphicsWindow, IPhoneGraphicsWindow, osxGraphicsWindow, WinGraphicsWindow, and x11GraphicsWindow.

Definition at line 628 of file graphicsWindow.cxx.

References WindowProperties::add_properties(), WindowProperties::clear(), WindowProperties::clear_fullscreen(), WindowProperties::clear_mouse_mode(), WindowProperties::clear_open(), WindowProperties::clear_origin(), WindowProperties::clear_size(), close_window(), do_reshape_request(), WindowProperties::get_fullscreen(), WindowProperties::get_mouse_mode(), WindowProperties::get_open(), WindowProperties::get_x_origin(), WindowProperties::get_x_size(), WindowProperties::get_y_origin(), WindowProperties::get_y_size(), WindowProperties::has_fullscreen(), WindowProperties::has_open(), WindowProperties::has_origin(), WindowProperties::has_size(), is_fullscreen(), mouse_mode_absolute(), mouse_mode_relative(), open_window(), WindowProperties::set_mouse_mode(), WindowProperties::set_open(), WindowProperties::set_origin(), WindowProperties::set_size(), and GraphicsOutput::set_size_and_recalc().

Referenced by process_events(), and set_close_now().

void GraphicsWindow::set_window_event ( const string &  window_event)

Changes the name of the event that is generated when this window is modified externally, e.g.

to be resized or closed by the user.

By default, all windows have the same window event unless they are explicitly changed. When the event is generated, it includes one parameter: the window itself.

Definition at line 199 of file graphicsWindow.cxx.

void GraphicsWindow::system_changed_properties ( const WindowProperties properties) [protected]

Should be called (from within the window thread) when process_events() detects an external change in some important window property; for instance, when the user resizes the window.

Definition at line 812 of file graphicsWindow.cxx.

References WindowProperties::add_properties(), WindowProperties::get_x_size(), WindowProperties::get_y_size(), WindowProperties::has_size(), and system_changed_size().

Referenced by WinGraphicsWindow::handle_reshape(), x11GraphicsWindow::process_events(), eglGraphicsWindow::process_events(), and WinGraphicsWindow::window_proc().

void GraphicsWindow::system_changed_size ( int  x_size,
int  y_size 
) [protected]

An internal function to update all the DisplayRegions with the new size of the window.

This should always be called before changing the _size members of the _properties structure.

Definition at line 840 of file graphicsWindow.cxx.

References WindowProperties::get_x_size(), WindowProperties::get_y_size(), WindowProperties::has_size(), and GraphicsOutput::set_size_and_recalc().

Referenced by system_changed_properties().

int GraphicsWindow::verify_window_sizes ( int  numsizes,
int *  dimen 
) [virtual]

Determines which of the indicated window sizes are supported by available hardware (e.g.

in fullscreen mode).

On entry, dimen is an array containing contiguous x,y pairs specifying possible display sizes; it is numsizes*2 words long. The function will zero out any invalid x,y size pairs. The return value is the number of valid sizes that were found.

Note this doesn't guarantee a resize attempt will work; you still need to check the return value.

(It might be better to implement some sort of query interface that returns an array of supported sizes, but this way is somewhat simpler and will do the job on most cards, assuming they handle the std sizes the app knows about.)

Reimplemented in wdxGraphicsWindow8, and wdxGraphicsWindow9.

Definition at line 526 of file graphicsWindow.cxx.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations