further interface generalizations

This commit is contained in:
David Rose 2009-11-21 01:20:55 +00:00
parent ac091ce40e
commit fc10c7c5a0
11 changed files with 42 additions and 34 deletions

View File

@ -796,7 +796,7 @@ feed_url_stream(int unique_id,
// true if the event is handled, false if ignored.
////////////////////////////////////////////////////////////////////
bool P3DInstance::
handle_event(P3D_event_data event) {
handle_event(const P3D_event_data &event) {
bool retval = false;
if (_splash_window != NULL) {
if (_splash_window->handle_event(event)) {
@ -804,11 +804,9 @@ handle_event(P3D_event_data event) {
}
}
#ifdef _WIN32
// This function is not used in Win32 and does nothing.
#elif defined(__APPLE__)
EventRecord *er = event._event;
#if defined(__APPLE__)
assert(event._event_type == P3D_ET_osx_event_record);
EventRecord *er = event._event._osx_event_record._event;
// Need to ensure we have the correct port set, in order to
// convert the mouse coordinates successfully via

View File

@ -82,7 +82,7 @@ public:
const unsigned char *this_data,
size_t this_data_size);
bool handle_event(P3D_event_data event);
bool handle_event(const P3D_event_data &event);
inline int get_instance_id() const;
inline const string &get_session_key() const;

View File

@ -201,8 +201,9 @@ set_install_progress(double install_progress) {
// if ignored.
////////////////////////////////////////////////////////////////////
bool P3DOsxSplashWindow::
handle_event(P3D_event_data event) {
EventRecord *er = event._event;
handle_event(const P3D_event_data &event) {
assert(event._event_type == P3D_ET_osx_event_record);
EventRecord *er = event._event._osx_event_record._event;
// Need to ensure we have the correct port set, in order to
// convert the mouse coordinates successfully via

View File

@ -40,7 +40,7 @@ public:
virtual void set_install_label(const string &install_label);
virtual void set_install_progress(double install_progress);
virtual bool handle_event(P3D_event_data event);
virtual bool handle_event(const P3D_event_data &event);
protected:
virtual void refresh();

View File

@ -203,7 +203,7 @@ set_install_progress(double install_progress) {
// if ignored.
////////////////////////////////////////////////////////////////////
bool P3DSplashWindow::
handle_event(P3D_event_data event) {
handle_event(const P3D_event_data &event) {
return false;
}

View File

@ -60,7 +60,7 @@ public:
virtual void set_install_label(const string &install_label);
virtual void set_install_progress(double install_progress);
virtual bool handle_event(P3D_event_data event);
virtual bool handle_event(const P3D_event_data &event);
virtual void set_button_active(bool flag);
virtual void request_keyboard_focus();

View File

@ -185,10 +185,10 @@ P3D_instance_setup_window(P3D_instance *instance,
P3D_window_type window_type,
int win_x, int win_y,
int win_width, int win_height,
P3D_window_handle parent_window) {
const P3D_window_handle *parent_window) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
P3DWindowParams wparams(window_type, win_x, win_y,
win_width, win_height, parent_window);
win_width, win_height, *parent_window);
ACQUIRE_LOCK(_api_lock);
P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
@ -559,7 +559,8 @@ P3D_instance_feed_url_stream(P3D_instance *instance, int unique_id,
}
bool
P3D_instance_handle_event(P3D_instance *instance, P3D_event_data event) {
P3D_instance_handle_event(P3D_instance *instance,
const P3D_event_data *event) {
assert(P3DInstanceManager::get_global_ptr()->is_initialized());
ACQUIRE_LOCK(_api_lock);
@ -567,7 +568,7 @@ P3D_instance_handle_event(P3D_instance *instance, P3D_event_data event) {
P3DInstance *inst = inst_mgr->validate_instance(instance);
bool result = false;
if (inst != NULL) {
result = inst->handle_event(event);
result = inst->handle_event(*event);
}
RELEASE_LOCK(_api_lock);

View File

@ -79,7 +79,7 @@ extern "C" {
(below). This number will be incremented whenever there are changes
to any of the interface specifications defined in this header
file. */
#define P3D_API_VERSION 9
#define P3D_API_VERSION 10
/************************ GLOBAL FUNCTIONS **************************/
@ -376,7 +376,7 @@ P3D_instance_setup_window_func(P3D_instance *instance,
P3D_window_type window_type,
int win_x, int win_y,
int win_width, int win_height,
P3D_window_handle parent_window);
const P3D_window_handle *parent_window);
/********************** SCRIPTING SUPPORT **************************/
@ -899,30 +899,38 @@ P3D_instance_feed_url_stream_func(P3D_instance *instance, int unique_id,
const void *this_data,
size_t this_data_size);
/* This structure abstracts out the event pointer data types for the
different platforms, as passed to P3D_instance_handle_event(),
below. */
/* This enum and set of structures abstract out the event pointer data
types for the different platforms, as passed to
P3D_instance_handle_event(), below. */
typedef enum {
P3D_ET_none = 0,
P3D_ET_osx_event_record,
} P3D_event_type;
typedef struct {
#ifdef _WIN32
// Not used for Win32.
#elif defined(__APPLE__)
#if defined(__APPLE__)
EventRecord *_event;
#elif defined(HAVE_X11)
// XEvent *_event; ?
#endif
} P3D_event_osx_event_record;
typedef struct {
P3D_event_type _event_type;
union {
P3D_event_osx_event_record _osx_event_record;
} _event;
} P3D_event_data;
/* Use this function to supply a new os-specific window event to the
plugin. This is presently used only on OSX, where the window
events are needed for proper plugin handling; and possibly also on
X11. On Windows, window events are handled natively by the plugin.
events are needed for proper plugin handling. On Windows and X11,
window events are handled natively by the plugin.
The return value is true if the handler has processed the event,
false if it has been ignored. */
typedef bool
P3D_instance_handle_event_func(P3D_instance *instance, P3D_event_data event);
P3D_instance_handle_event_func(P3D_instance *instance,
const P3D_event_data *event);
#ifdef P3D_FUNCTION_PROTOTYPES

View File

@ -530,7 +530,7 @@ int PPInstance::Start( const std::string& p3dFilename )
m_p3dObject = P3D_instance_get_panda_script_object( m_p3dInstance );
P3D_OBJECT_INCREF( m_p3dObject );
P3D_instance_setup_window( m_p3dInstance, P3D_WT_embedded, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, parent_window );
P3D_instance_setup_window( m_p3dInstance, P3D_WT_embedded, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, &parent_window );
nout << "Starting new P3D instance " << p3dFilename << "\n";

View File

@ -1378,7 +1378,7 @@ send_window() {
P3D_instance_setup_window
(_p3d_inst, window_type,
x, y, _window.width, _window.height,
parent_window);
&parent_window);
}
////////////////////////////////////////////////////////////////////

View File

@ -1039,7 +1039,7 @@ create_instance(const string &p3d, bool start_instance,
}
P3D_instance_setup_window
(inst, _window_type, _win_x, _win_y, _win_width, _win_height, _parent_window);
(inst, _window_type, _win_x, _win_y, _win_width, _win_height, &_parent_window);
}
return inst;