mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
move towards explicit handle type in P3D_window_handle
This commit is contained in:
parent
3ea273ddb6
commit
21aad12650
@ -84,7 +84,7 @@ get_win_height() const {
|
|||||||
// Description: Returns the parent window handle that was passed to
|
// Description: Returns the parent window handle that was passed to
|
||||||
// the constructor.
|
// the constructor.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
inline P3D_window_handle P3DWindowParams::
|
inline const P3D_window_handle &P3DWindowParams::
|
||||||
get_parent_window() const {
|
get_parent_window() const {
|
||||||
return _parent_window;
|
return _parent_window;
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,8 @@ make_xml(P3DInstance *inst) {
|
|||||||
// stringstream to do it ourselves.
|
// stringstream to do it ourselves.
|
||||||
{
|
{
|
||||||
ostringstream strm;
|
ostringstream strm;
|
||||||
strm << _parent_window._xwindow;
|
assert(_parent_window._window_handle_type == P3D_WHT_x11_window);
|
||||||
|
strm << _parent_window._handle._x11_window._xwindow;
|
||||||
xwparams->SetAttribute("parent_xwindow", strm.str());
|
xwparams->SetAttribute("parent_xwindow", strm.str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
inline int get_win_y() const;
|
inline int get_win_y() const;
|
||||||
inline int get_win_width() const;
|
inline int get_win_width() const;
|
||||||
inline int get_win_height() const;
|
inline int get_win_height() const;
|
||||||
inline P3D_window_handle get_parent_window() const;
|
inline const P3D_window_handle &get_parent_window() const;
|
||||||
|
|
||||||
TiXmlElement *make_xml(P3DInstance *inst);
|
TiXmlElement *make_xml(P3DInstance *inst);
|
||||||
|
|
||||||
|
@ -805,7 +805,9 @@ make_window() {
|
|||||||
|
|
||||||
if (_wparams.get_window_type() == P3D_WT_embedded) {
|
if (_wparams.get_window_type() == P3D_WT_embedded) {
|
||||||
// Create an embedded window.
|
// Create an embedded window.
|
||||||
parent = _wparams.get_parent_window()._xwindow;
|
const P3D_window_handle &handle = _wparams.get_parent_window();
|
||||||
|
assert(handle._window_handle_type == P3D_WHT_x11_window);
|
||||||
|
parent = handle._handle._x11_window._xwindow;
|
||||||
} else {
|
} else {
|
||||||
// Create a toplevel window.
|
// Create a toplevel window.
|
||||||
parent = XRootWindow(_display, _screen);
|
parent = XRootWindow(_display, _screen);
|
||||||
|
@ -197,20 +197,44 @@ typedef struct {
|
|||||||
/* Additional opaque data may be stored here. */
|
/* Additional opaque data may be stored here. */
|
||||||
} P3D_instance;
|
} P3D_instance;
|
||||||
|
|
||||||
/* This structure abstracts out the various window handle types for
|
/* This enum and set of structures abstract out the various window
|
||||||
the different platforms. */
|
handle types for the different platforms. */
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
P3D_WHT_none,
|
||||||
|
P3D_WHT_win_hwnd,
|
||||||
|
P3D_WHT_osx_port,
|
||||||
|
P3D_WHT_x11_window,
|
||||||
|
} P3D_window_handle_type;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HWND _hwnd;
|
HWND _hwnd;
|
||||||
|
#endif
|
||||||
|
} P3D_window_handle_win_hwnd;
|
||||||
|
|
||||||
#elif defined(__APPLE__)
|
/* As provided by Mozilla, by default. Not compatible with Snow
|
||||||
/* As provided by Mozilla. */
|
Leopard. */
|
||||||
|
typedef struct {
|
||||||
|
#if defined(__APPLE__)
|
||||||
GrafPtr _port;
|
GrafPtr _port;
|
||||||
|
#endif
|
||||||
|
} P3D_window_handle_osx_port;
|
||||||
|
|
||||||
#elif defined(HAVE_X11)
|
typedef struct {
|
||||||
|
#if defined(HAVE_X11)
|
||||||
unsigned long _xwindow;
|
unsigned long _xwindow;
|
||||||
void *_xdisplay;
|
void *_xdisplay;
|
||||||
#endif
|
#endif
|
||||||
|
} P3D_window_handle_x11_window;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
P3D_window_handle_type _window_handle_type;
|
||||||
|
union {
|
||||||
|
P3D_window_handle_win_hwnd _win_hwnd;
|
||||||
|
P3D_window_handle_osx_port _osx_port;
|
||||||
|
P3D_window_handle_x11_window _x11_window;
|
||||||
|
} _handle;
|
||||||
} P3D_window_handle;
|
} P3D_window_handle;
|
||||||
|
|
||||||
/* This enum lists the different kinds of window types that may be
|
/* This enum lists the different kinds of window types that may be
|
||||||
|
@ -1292,6 +1292,9 @@ send_window() {
|
|||||||
int y = _window.y;
|
int y = _window.y;
|
||||||
|
|
||||||
P3D_window_handle parent_window;
|
P3D_window_handle parent_window;
|
||||||
|
memset(&parent_window, 0, sizeof(parent_window));
|
||||||
|
parent_window._window_handle_type = P3D_WHT_none;
|
||||||
|
|
||||||
if (_window.type == NPWindowTypeWindow) {
|
if (_window.type == NPWindowTypeWindow) {
|
||||||
// We have a "windowed" plugin. Parent our window to the one we
|
// We have a "windowed" plugin. Parent our window to the one we
|
||||||
// were given. In this case, we should also reset the offset to
|
// were given. In this case, we should also reset the offset to
|
||||||
@ -1314,7 +1317,8 @@ send_window() {
|
|||||||
#elif defined(HAVE_X11)
|
#elif defined(HAVE_X11)
|
||||||
// We make it an 'unsigned long' instead of 'Window'
|
// We make it an 'unsigned long' instead of 'Window'
|
||||||
// to avoid nppanda3d.so getting a dependency on X11.
|
// to avoid nppanda3d.so getting a dependency on X11.
|
||||||
parent_window._xwindow = (unsigned long)(_window.window);
|
parent_window._window_handle_type = P3D_WHT_x11_window;
|
||||||
|
parent_window._handle._x11_window._xwindow = (unsigned long)(_window.window);
|
||||||
x = 0;
|
x = 0;
|
||||||
y = 0;
|
y = 0;
|
||||||
#endif
|
#endif
|
||||||
@ -1340,22 +1344,22 @@ send_window() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#elif defined(HAVE_X11)
|
#elif defined(HAVE_X11)
|
||||||
parent_window._xwindow = 0;
|
|
||||||
unsigned long win;
|
unsigned long win;
|
||||||
if (browser->getvalue(_npp_instance, NPNVnetscapeWindow,
|
if (browser->getvalue(_npp_instance, NPNVnetscapeWindow,
|
||||||
&win) == NPERR_NO_ERROR) {
|
&win) == NPERR_NO_ERROR) {
|
||||||
parent_window._xwindow = win;
|
parent_window._window_handle_type = P3D_WHT_x11_window;
|
||||||
|
parent_window._handle._x11_window._xwindow = win;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_X11
|
#ifdef HAVE_X11
|
||||||
// In the case of X11, grab the display as well.
|
// In the case of X11, grab the display as well.
|
||||||
parent_window._xdisplay = 0;
|
parent_window._handle._x11_window._xdisplay = 0;
|
||||||
void* disp;
|
void *disp;
|
||||||
if (browser->getvalue(_npp_instance, NPNVxDisplay,
|
if (browser->getvalue(_npp_instance, NPNVxDisplay,
|
||||||
&disp) == NPERR_NO_ERROR) {
|
&disp) == NPERR_NO_ERROR) {
|
||||||
parent_window._xdisplay = disp;
|
parent_window._handle._x11_window._xdisplay = disp;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user