better WindowHandle stuff

This commit is contained in:
David Rose 2009-10-01 00:23:12 +00:00
parent 9ea14818de
commit 7857e5fa9b
25 changed files with 594 additions and 389 deletions

View File

@ -31,6 +31,7 @@
graphicsWindowInputDevice.h \
graphicsDevice.h graphicsDevice.I \
lru.h \
nativeWindowHandle.I nativeWindowHandle.h \
parasiteBuffer.I parasiteBuffer.h \
windowHandle.I windowHandle.h \
windowProperties.I windowProperties.h \
@ -59,6 +60,7 @@
graphicsThreadingModel.cxx \
graphicsWindow.cxx graphicsWindowInputDevice.cxx \
graphicsDevice.cxx \
nativeWindowHandle.cxx \
parasiteBuffer.cxx \
windowHandle.cxx \
windowProperties.cxx \
@ -89,6 +91,7 @@
graphicsWindowInputDevice.I graphicsWindowInputDevice.h \
graphicsDevice.I graphicsDevice.h \
lru.h \
nativeWindowHandle.I nativeWindowHandle.h \
parasiteBuffer.I parasiteBuffer.h \
windowHandle.I windowHandle.h \
windowProperties.I windowProperties.h \

View File

@ -23,6 +23,7 @@
#include "graphicsBuffer.h"
#include "graphicsWindow.h"
#include "graphicsDevice.h"
#include "nativeWindowHandle.h"
#include "parasiteBuffer.h"
#include "pandaSystem.h"
#include "stereoDisplayRegion.h"
@ -416,6 +417,7 @@ init_libdisplay() {
GraphicsPipe::init_type();
GraphicsStateGuardian::init_type();
GraphicsWindow::init_type();
NativeWindowHandle::init_type();
ParasiteBuffer::init_type();
StandardMunger::init_type();
StereoDisplayRegion::init_type();
@ -424,7 +426,6 @@ init_libdisplay() {
#endif
WindowHandle::init_type();
WindowHandle::OSHandle::init_type();
WindowHandle::IntHandle::init_type();
#if defined(HAVE_THREADS) && defined(DO_PIPELINING)
PandaSystem *ps = PandaSystem::get_global_ptr();

View File

@ -4,6 +4,7 @@
#include "graphicsWindow.cxx"
#include "graphicsWindowInputDevice.cxx"
#include "lru.cxx"
#include "nativeWindowHandle.cxx"
#include "parasiteBuffer.cxx"
#include "standardMunger.cxx"
#include "stencilRenderStates.cxx"

View File

@ -148,28 +148,6 @@ get_display_information() {
return _display_information;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::make_int_window_handle
// Access: Published
// Description: Creates a WindowHandle by interpreting the indicated
// integer value as an OS-specific pointer, e.g. to a
// HWND or a Window object, if this makes sense for the
// current OS. Returns the WindowHandle if successful,
// or NULL if not.
//
// This method exists primarily for the benefit of
// Python, which likes to pass around pointers as
// integers. For other languages, see the OS-specific
// make_window_handle() method, which is defined for
// each particular OS-specific GraphicsPipe type. It is
// preferable to use make_window_handle() instead of
// make_int_window_handle().
////////////////////////////////////////////////////////////////////
WindowHandle *GraphicsPipe::
make_int_window_handle(size_t window) {
return NULL;
}
////////////////////////////////////////////////////////////////////
// Function: GraphicsPipe::lookup_cpu_data
// Access: Public, Virtual

View File

@ -101,7 +101,6 @@ PUBLISHED:
virtual void lookup_cpu_data();
virtual string get_interface_name() const=0;
virtual WindowHandle *make_int_window_handle(size_t window);
public:
enum PreferredWindowThread {

View File

@ -0,0 +1,98 @@
// Filename: nativeWindowHandle.I
// Created by: drose (30Sep09)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::IntHandle::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE NativeWindowHandle::IntHandle::
IntHandle(size_t handle) : _handle(handle) {
}
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::IntHandle::get_handle
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE size_t NativeWindowHandle::IntHandle::
get_handle() const {
return _handle;
}
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::SubprocessHandle::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE NativeWindowHandle::SubprocessHandle::
SubprocessHandle(const Filename &filename) : _filename(filename) {
}
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::SubprocessHandle::get_filename
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE const Filename &NativeWindowHandle::SubprocessHandle::
get_filename() const {
return _filename;
}
#if defined(HAVE_X11) && !defined(CPPPARSER)
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::X11Handle::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE NativeWindowHandle::X11Handle::
X11Handle(Window handle) : _handle(handle) {
}
#endif // HAVE_X11
#if defined(HAVE_X11) && !defined(CPPPARSER)
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::X11Handle::get_handle
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE Window NativeWindowHandle::X11Handle::
get_handle() const {
return _handle;
}
#endif // HAVE_X11
#ifdef WIN32
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::WinHandle::Constructor
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE NativeWindowHandle::WinHandle::
WinHandle(HWND handle) : _handle(handle) {
}
#endif // WIN32
#ifdef WIN32
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::WinHandle::get_handle
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
INLINE HWND NativeWindowHandle::WinHandle::
get_handle() const {
return _handle;
}
#endif // WIN32

View File

@ -0,0 +1,167 @@
// Filename: nativeWindowHandle.cxx
// Created by: drose (30Sep09)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#include "nativeWindowHandle.h"
TypeHandle NativeWindowHandle::IntHandle::_type_handle;
TypeHandle NativeWindowHandle::SubprocessHandle::_type_handle;
#if defined(HAVE_X11) && !defined(CPPPARSER)
TypeHandle NativeWindowHandle::X11Handle::_type_handle;
#endif
#ifdef WIN32
TypeHandle NativeWindowHandle::WinHandle::_type_handle;
#endif
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::make_int
// Access: Published, Static
// Description: Constructs a new WindowHandle with an int value,
// which is understood to be either an HWND or a Window,
// cast to int. This method exists for the convenience
// of Python, which likes to deal with ints; C++ code
// should use one of the more specific make_x11() or
// make_win32() methods instead.
////////////////////////////////////////////////////////////////////
PT(WindowHandle) NativeWindowHandle::
make_int(size_t window) {
return new WindowHandle(new IntHandle(window));
}
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::make_subprocess
// Access: Published, Static
// Description: Constructs a new WindowHandle that references a
// SubprocessWindowBuffer read in another process, with
// the named pipe filename that it uses for
// communication.
//
// This is (at present, and maybe always) useful only on
// the OS X platform, where parenting child windows is
// particularly problematic.
////////////////////////////////////////////////////////////////////
PT(WindowHandle) NativeWindowHandle::
make_subprocess(const Filename &filename) {
return new WindowHandle(new SubprocessHandle(filename));
}
#if defined(HAVE_X11) && !defined(CPPPARSER)
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::make_x11
// Access: Published, Static
// Description: Constructs a new WindowHandle that references an
// X11 window.
////////////////////////////////////////////////////////////////////
PT(WindowHandle) NativeWindowHandle::
make_x11(Window window) {
return new WindowHandle(new X11Handle(window));
}
#endif // HAVE_X11
#ifdef WIN32
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::make_win
// Access: Published, Static
// Description: Constructs a new WindowHandle that references a
// window on Windows.
////////////////////////////////////////////////////////////////////
PT(WindowHandle) NativeWindowHandle::
make_win(HWND window) {
return new WindowHandle(new WinHandle(window));
}
#endif // WIN32
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::IntHandle::get_int_handle
// Access: Public, Virtual
// Description: Returns the OS-specific handle converted to an
// integer, if this is possible for the particular
// representation. Returns 0 if it is not.
////////////////////////////////////////////////////////////////////
size_t NativeWindowHandle::IntHandle::
get_int_handle() const {
return _handle;
}
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::IntHandle::output
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
void NativeWindowHandle::IntHandle::
output(ostream &out) const {
out << _handle;
}
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::SubprocessHandle::output
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
void NativeWindowHandle::SubprocessHandle::
output(ostream &out) const {
out << _filename;
}
#if defined(HAVE_X11) && !defined(CPPPARSER)
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::X11Handle::get_int_handle
// Access: Public, Virtual
// Description: Returns the OS-specific handle converted to an
// integer, if this is possible for the particular
// representation. Returns 0 if it is not.
////////////////////////////////////////////////////////////////////
size_t NativeWindowHandle::X11Handle::
get_int_handle() const {
return (size_t)_handle;
}
#endif // HAVE_X11
#if defined(HAVE_X11) && !defined(CPPPARSER)
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::X11Handle::output
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
void NativeWindowHandle::X11Handle::
output(ostream &out) const {
out << _handle;
}
#endif // HAVE_X11
#ifdef WIN32
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::WinHandle::get_int_handle
// Access: Public, Virtual
// Description: Returns the OS-specific handle converted to an
// integer, if this is possible for the particular
// representation. Returns 0 if it is not.
////////////////////////////////////////////////////////////////////
size_t NativeWindowHandle::WinHandle::
get_int_handle() const {
return (size_t)_handle;
}
#endif // WIN32
#ifdef WIN32
////////////////////////////////////////////////////////////////////
// Function: NativeWindowHandle::WinHandle::output
// Access: Public
// Description:
////////////////////////////////////////////////////////////////////
void NativeWindowHandle::WinHandle::
output(ostream &out) const {
out << _handle;
}
#endif // WIN32

View File

@ -0,0 +1,199 @@
// Filename: nativeWindowHandle.h
// Created by: drose (30Sep09)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) Carnegie Mellon University. All rights reserved.
//
// All use of this software is subject to the terms of the revised BSD
// license. You should have received a copy of this license along
// with this source code in a file named "LICENSE."
//
////////////////////////////////////////////////////////////////////
#ifndef NATIVEWINDOWHANDLE_H
#define NATIVEWINDOWHANDLE_H
#include "pandabase.h"
#include "typedReferenceCount.h"
#include "pointerTo.h"
#ifdef HAVE_X11
#include <X11/Xlib.h>
#endif
#ifdef WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
#endif
////////////////////////////////////////////////////////////////////
// Class : NativeWindowHandle
// Description : This subclass of WindowHandle exists to allow simple
// creation of a WindowHandle of the appropriate type to
// the current OS.
//
// This class exists for name scoping only. Don't use
// the constructor directly; use one of the make_*
// methods.
////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_DISPLAY NativeWindowHandle : public WindowHandle {
private:
INLINE NativeWindowHandle();
INLINE NativeWindowHandle(const NativeWindowHandle &copy);
PUBLISHED:
static PT(WindowHandle) make_int(size_t window);
static PT(WindowHandle) make_subprocess(const Filename &filename);
public:
#if defined(HAVE_X11) && !defined(CPPPARSER)
static PT(WindowHandle) make_x11(Window window);
#endif // HAVE_X11
#ifdef WIN32
static PT(WindowHandle) make_win32(HWND window);
#endif // WIN32
public:
class IntHandle : public OSHandle {
public:
INLINE IntHandle(size_t handle);
virtual size_t get_int_handle() const;
virtual void output(ostream &out) const;
INLINE size_t get_handle() const;
private:
size_t _handle;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
OSHandle::init_type();
register_type(_type_handle, "NativeWindowHandle::IntHandle",
OSHandle::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
class SubprocessHandle : public OSHandle {
public:
INLINE SubprocessHandle(const Filename &filename);
virtual void output(ostream &out) const;
INLINE const Filename &get_filename() const;
private:
Filename _filename;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
OSHandle::init_type();
register_type(_type_handle, "NativeWindowHandle::SubprocessHandle",
OSHandle::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
#if defined(HAVE_X11) && !defined(CPPPARSER)
class X11Handle : public OSHandle {
public:
INLINE X11Handle(Window handle);
virtual size_t get_int_handle() const;
virtual void output(ostream &out) const;
INLINE Window get_handle() const;
private:
Window _handle;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
OSHandle::init_type();
register_type(_type_handle, "NativeWindowHandle::X11Handle",
OSHandle::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
#endif // HAVE_X11
#ifdef WIN32
class EXPCL_PANDA_DISPLAY WinHandle : public OSHandle {
public:
INLINE WinHandle(HWND handle);
virtual size_t get_int_handle() const;
virtual void output(ostream &out) const;
INLINE HWND get_handle() const;
private:
HWND _handle;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
OSHandle::init_type();
register_type(_type_handle, "NativeWindowHandle::WinHandle",
OSHandle::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
#endif // WIN32
public:
static void init_type() {
IntHandle::init_type();
SubprocessHandle::init_type();
#if defined(HAVE_X11) && !defined(CPPPARSER)
X11Handle::init_type();
#endif
#ifdef WIN32
WinHandle::init_type();
#endif
}
};
#include "nativeWindowHandle.I"
#endif

View File

@ -65,23 +65,3 @@ set_os_handle(OSHandle *os_handle) {
INLINE WindowHandle::OSHandle::
OSHandle() {
}
////////////////////////////////////////////////////////////////////
// Function: WindowHandle::IntHandle::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE WindowHandle::IntHandle::
IntHandle(size_t handle) : _handle(handle) {
}
////////////////////////////////////////////////////////////////////
// Function: WindowHandle::IntHandle::get_handle
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE size_t WindowHandle::IntHandle::
get_handle() const {
return _handle;
}

View File

@ -16,7 +16,6 @@
TypeHandle WindowHandle::_type_handle;
TypeHandle WindowHandle::OSHandle::_type_handle;
TypeHandle WindowHandle::IntHandle::_type_handle;
////////////////////////////////////////////////////////////////////
// Function: WindowHandle::Destructor
@ -28,20 +27,18 @@ WindowHandle::
}
////////////////////////////////////////////////////////////////////
// Function: WindowHandle::get_string_handle
// Function: WindowHandle::get_int_handle
// Access: Published
// Description: Returns the OS-specific handle in a string
// representation, whatever that means for a particular
// OS. Typically this is a pointer value, represented
// as a decimal integer.
// Description: Returns the OS-specific handle converted to an
// integer, if this is possible for the particular
// representation. Returns 0 if it is not.
////////////////////////////////////////////////////////////////////
string WindowHandle::
get_string_handle() const {
ostringstream strm;
size_t WindowHandle::
get_int_handle() const {
if (_os_handle != NULL) {
_os_handle->format_string_handle(strm);
return _os_handle->get_int_handle();
}
return strm.str();
return 0;
}
////////////////////////////////////////////////////////////////////
@ -100,15 +97,15 @@ WindowHandle::OSHandle::
}
////////////////////////////////////////////////////////////////////
// Function: WindowHandle::OSHandle::format_string_handle
// Function: WindowHandle::OSHandle::get_int_handle
// Access: Published, Virtual
// Description: Writes the OS-specific value to the indicated stream
// in whatever representation makes sense, but it should
// format it as a decimal integer if possible, for
// consistency between platforms.
// Description: Returns the OS-specific handle converted to an
// integer, if this is possible for the particular
// representation. Returns 0 if it is not.
////////////////////////////////////////////////////////////////////
void WindowHandle::OSHandle::
format_string_handle(ostream &out) const {
size_t WindowHandle::OSHandle::
get_int_handle() const {
return 0;
}
////////////////////////////////////////////////////////////////////
@ -120,26 +117,3 @@ void WindowHandle::OSHandle::
output(ostream &out) const {
out << "(no type)";
}
////////////////////////////////////////////////////////////////////
// Function: WindowHandle::IntHandle::format_string_handle
// Access: Published, Virtual
// Description: Writes the OS-specific value to the indicated stream
// in whatever representation makes sense, but it should
// format it as a decimal integer if possible, for
// consistency between platforms.
////////////////////////////////////////////////////////////////////
void WindowHandle::IntHandle::
format_string_handle(ostream &out) const {
out << _handle;
}
////////////////////////////////////////////////////////////////////
// Function: WindowHandle::IntHandle::output
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
void WindowHandle::IntHandle::
output(ostream &out) const {
out << _handle;
}

View File

@ -51,7 +51,7 @@ PUBLISHED:
INLINE OSHandle *get_os_handle() const;
INLINE void set_os_handle(OSHandle *os_handle);
string get_string_handle() const;
size_t get_int_handle() const;
void output(ostream &out) const;
@ -64,7 +64,7 @@ PUBLISHED:
PUBLISHED:
virtual ~OSHandle();
virtual void format_string_handle(ostream &out) const;
virtual size_t get_int_handle() const;
virtual void output(ostream &out) const;
public:
@ -85,41 +85,6 @@ PUBLISHED:
static TypeHandle _type_handle;
};
// This class only exists for backward compatibility; it stores the
// OS handle as a size_t object, as the WindowProperties object did
// historically. New code should use
// GraphicsPipe::make_window_handle() instead of this.
class EXPCL_PANDA_DISPLAY IntHandle : public OSHandle {
PUBLISHED:
INLINE IntHandle(size_t handle);
virtual void format_string_handle(ostream &out) const;
virtual void output(ostream &out) const;
INLINE size_t get_handle() const;
private:
size_t _handle;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
OSHandle::init_type();
register_type(_type_handle, "WindowHandle::IntHandle",
OSHandle::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
protected:
// Callbacks for communication with the parent window.
virtual void attach_child(WindowHandle *child);

View File

@ -799,32 +799,6 @@ clear_mouse_mode() {
_mouse_mode = M_absolute;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_parent_window
// Access: Published
// Description: Specifies the window that this window should be
// attached to.
//
// This is a deprecated variant on this method, and
// exists only for backward compatibility. Future code
// should use the version of set_parent_window() below
// that receives a WindowHandle object; that interface
// is much more robust.
//
// In this deprecated variant, the actual value for
// "parent" is platform-specific. On Windows, it is the
// HWND of the parent window, cast to an unsigned
// integer. On X11, it is the Window pointer of the
// parent window, similarly cast. On OSX, this is the
// NSWindow pointer, which doesn't appear to work at
// all.
////////////////////////////////////////////////////////////////////
INLINE void WindowProperties::
set_parent_window(size_t parent) {
PT(WindowHandle) handle = new WindowHandle(new WindowHandle::IntHandle(parent));
set_parent_window(handle);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_parent_window
// Access: Published

View File

@ -14,7 +14,9 @@
#include "windowProperties.h"
#include "config_display.h"
#include "nativeWindowHandle.h"
WindowProperties *WindowProperties::_default_properties = NULL;
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::Constructor
@ -49,14 +51,14 @@ operator = (const WindowProperties &copy) {
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::get_default
// Function: WindowProperties::get_config_properties
// Access: Published, Static
// Description: Returns a WindowProperties structure with all of the
// default values filled in according to the user's
// config file.
////////////////////////////////////////////////////////////////////
WindowProperties WindowProperties::
get_default() {
get_config_properties() {
WindowProperties props;
props.set_open(true);
@ -95,6 +97,56 @@ get_default() {
return props;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::get_default
// Access: Published, Static
// Description: Returns the "default" WindowProperties. If
// set_default() has been called, this returns that
// WindowProperties structure; otherwise, this returns
// get_config_properties().
////////////////////////////////////////////////////////////////////
WindowProperties WindowProperties::
get_default() {
if (_default_properties != NULL) {
return *_default_properties;
} else {
return get_config_properties();
}
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_default
// Access: Published, Static
// Description: Replaces the "default" WindowProperties with the
// specified structure. The specified WindowProperties
// will be returned by future calls to get_default(),
// until clear_default() is called.
//
// Note that this completely replaces the default
// properties; it is not additive.
////////////////////////////////////////////////////////////////////
void WindowProperties::
set_default(const WindowProperties &default_properties) {
if (_default_properties == NULL) {
_default_properties = new WindowProperties;
}
(*_default_properties) = default_properties;
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::clear_default
// Access: Published, Static
// Description: Returns the "default" WindowProperties to whatever
// is specified in the user's config file.
////////////////////////////////////////////////////////////////////
void WindowProperties::
clear_default() {
if (_default_properties != NULL) {
delete _default_properties;
_default_properties = NULL;
}
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::size
// Access: Published, Static
@ -155,6 +207,32 @@ clear() {
_subprocess_window = Filename();
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::set_parent_window
// Access: Published
// Description: Specifies the window that this window should be
// attached to.
//
// This is a deprecated variant on this method, and
// exists only for backward compatibility. Future code
// should use the version of set_parent_window() below
// that receives a WindowHandle object; that interface
// is much more robust.
//
// In this deprecated variant, the actual value for
// "parent" is platform-specific. On Windows, it is the
// HWND of the parent window, cast to an unsigned
// integer. On X11, it is the Window pointer of the
// parent window, similarly cast. On OSX, this is the
// NSWindow pointer, which doesn't appear to work at
// all.
////////////////////////////////////////////////////////////////////
void WindowProperties::
set_parent_window(size_t parent) {
PT(WindowHandle) handle = NativeWindowHandle::make_int(parent);
set_parent_window(handle);
}
////////////////////////////////////////////////////////////////////
// Function: WindowProperties::add_properties
// Access: Published

View File

@ -45,7 +45,11 @@ PUBLISHED:
void operator = (const WindowProperties &copy);
INLINE ~WindowProperties();
static WindowProperties get_config_properties();
static WindowProperties get_default();
static void set_default(const WindowProperties &default_properties);
static void clear_default();
static WindowProperties size(int x_size, int y_size);
bool operator == (const WindowProperties &other) const;
@ -131,7 +135,7 @@ PUBLISHED:
INLINE bool has_z_order() const;
INLINE void clear_z_order();
INLINE void set_parent_window(size_t parent);
void set_parent_window(size_t parent);
INLINE void set_parent_window(WindowHandle *parent_window);
INLINE WindowHandle *get_parent_window() const;
INLINE bool has_parent_window() const;
@ -197,6 +201,8 @@ private:
unsigned int _flags;
PT(WindowHandle) _parent_window;
Filename _subprocess_window;
static WindowProperties *_default_properties;
};
EXPCL_PANDA_DISPLAY ostream &

View File

@ -25,7 +25,7 @@
#include "textEncoder.h"
#include "throw_event.h"
#include "lightReMutexHolder.h"
#include "x11GraphicsPipe.h"
#include "nativeWindowHandle.h"
#include <errno.h>
#include <sys/time.h>
@ -676,11 +676,11 @@ open_window() {
egldisplay_cat.info()
<< "os_handle type " << os_handle->get_type() << "\n";
if (os_handle->is_of_type(x11GraphicsPipe::x11Handle::get_class_type())) {
x11GraphicsPipe::x11Handle *x11_handle = DCAST(x11GraphicsPipe::x11Handle, os_handle);
if (os_handle->is_of_type(NativeWindowHandle::X11Handle::get_class_type())) {
NativeWindowHandle::X11Handle *x11_handle = DCAST(NativeWindowHandle::X11Handle, os_handle);
parent_window = x11_handle->get_handle();
} else if (os_handle->is_of_type(WindowHandle::IntHandle::get_class_type())) {
WindowHandle::IntHandle *int_handle = DCAST(WindowHandle::IntHandle, os_handle);
} else if (os_handle->is_of_type(NativeWindowHandle::IntHandle::get_class_type())) {
NativeWindowHandle::IntHandle *int_handle = DCAST(NativeWindowHandle::IntHandle, os_handle);
parent_window = (Window)int_handle->get_handle();
}
}

View File

@ -26,6 +26,7 @@
#include "textEncoder.h"
#include "throw_event.h"
#include "lightReMutexHolder.h"
#include "nativeWindowHandle.h"
#include <errno.h>
#include <sys/time.h>
@ -206,11 +207,11 @@ open_window() {
glxdisplay_cat.info()
<< "os_handle type " << os_handle->get_type() << "\n";
if (os_handle->is_of_type(x11GraphicsPipe::x11Handle::get_class_type())) {
x11GraphicsPipe::x11Handle *x11_handle = DCAST(x11GraphicsPipe::x11Handle, os_handle);
if (os_handle->is_of_type(NativeWindowHandle::X11Handle::get_class_type())) {
NativeWindowHandle::X11Handle *x11_handle = DCAST(NativeWindowHandle::X11Handle, os_handle);
parent_window = x11_handle->get_handle();
} else if (os_handle->is_of_type(WindowHandle::IntHandle::get_class_type())) {
WindowHandle::IntHandle *int_handle = DCAST(WindowHandle::IntHandle, os_handle);
} else if (os_handle->is_of_type(NativeWindowHandle::IntHandle::get_class_type())) {
NativeWindowHandle::IntHandle *int_handle = DCAST(NativeWindowHandle::IntHandle, os_handle);
parent_window = (Window)int_handle->get_handle();
}
}

View File

@ -29,6 +29,7 @@
#include "textEncoder.h"
#include "throw_event.h"
#include "lightReMutexHolder.h"
#include "nativeWindowHandle.h"
TypeHandle TinyXGraphicsWindow::_type_handle;
@ -521,11 +522,11 @@ open_window() {
tinydisplay_cat.info()
<< "os_handle type " << os_handle->get_type() << "\n";
if (os_handle->is_of_type(x11GraphicsPipe::x11Handle::get_class_type())) {
x11GraphicsPipe::x11Handle *x11_handle = DCAST(x11GraphicsPipe::x11Handle, os_handle);
if (os_handle->is_of_type(NativeWindowHandle::X11Handle::get_class_type())) {
NativeWindowHandle::X11Handle *x11_handle = DCAST(NativeWindowHandle::X11Handle, os_handle);
parent_window = x11_handle->get_handle();
} else if (os_handle->is_of_type(WindowHandle::IntHandle::get_class_type())) {
WindowHandle::IntHandle *int_handle = DCAST(WindowHandle::IntHandle, os_handle);
} else if (os_handle->is_of_type(NativeWindowHandle::IntHandle::get_class_type())) {
NativeWindowHandle::IntHandle *int_handle = DCAST(NativeWindowHandle::IntHandle, os_handle);
parent_window = (Window)int_handle->get_handle();
}
}

View File

@ -13,21 +13,3 @@
////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////
// Function: WinGraphicsPipe::WinHandle::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE WinGraphicsPipe::WinHandle::
WinHandle(HWND handle) : _handle(handle) {
}
////////////////////////////////////////////////////////////////////
// Function: WinGraphicsPipe::WinHandle::get_handle
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE HWND WinGraphicsPipe::WinHandle::
get_handle() const {
return _handle;
}

View File

@ -1022,60 +1022,3 @@ bool MyLoadLib(HINSTANCE &hDLL, const char *DLLname) {
}
return true;
}
////////////////////////////////////////////////////////////////////
// Function: WinGraphicsPipe::make_window_handle
// Access: Public
// Description: Constructs a new WindowHandle object that
// encapsulates a window with the indicated Window
// handle.
////////////////////////////////////////////////////////////////////
WindowHandle *WinGraphicsPipe::
make_window_handle(HWND window) {
return new WindowHandle(new WinHandle(window));
}
////////////////////////////////////////////////////////////////////
// Function: WinGraphicsPipe::make_int_window_handle
// Access: Public, Virtual
// Description: Creates a WindowHandle by interpreting the indicated
// integer value as an OS-specific pointer, e.g. to a
// HWND or a Window object, if this makes sense for the
// current OS. Returns the WindowHandle if successful,
// or NULL if not.
//
// This method exists primarily for the benefit of
// Python, which likes to pass around pointers as
// integers. For other languages, see the OS-specific
// make_window_handle() method, which is defined for
// each particular OS-specific GraphicsPipe type. It is
// preferable to use make_window_handle() instead of
// make_int_window_handle().
////////////////////////////////////////////////////////////////////
WindowHandle *WinGraphicsPipe::
make_int_window_handle(size_t window) {
return make_window_handle((HWND)window);
}
////////////////////////////////////////////////////////////////////
// Function: WinGraphicsPipe::WinHandle::format_string_handle
// Access: Published, Virtual
// Description: Writes the OS-specific value to the indicated stream
// in whatever representation makes sense, but it should
// format it as a decimal integer if possible, for
// consistency between platforms.
////////////////////////////////////////////////////////////////////
void WinGraphicsPipe::WinHandle::
format_string_handle(ostream &out) const {
out << (size_t)_handle;
}
////////////////////////////////////////////////////////////////////
// Function: WinGraphicsPipe::WinHandle::output
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
void WinGraphicsPipe::WinHandle::
output(ostream &out) const {
out << (void *)_handle;
}

View File

@ -39,40 +39,6 @@ public:
virtual void lookup_cpu_data();
WindowHandle *make_window_handle(HWND window);
virtual WindowHandle *make_int_window_handle(size_t window);
public:
// Wraps a WindowHandle type for Windows.
class EXPCL_PANDAWIN WinHandle : public WindowHandle::OSHandle {
PUBLISHED:
INLINE WinHandle(HWND handle);
virtual void format_string_handle(ostream &out) const;
virtual void output(ostream &out) const;
INLINE HWND get_handle() const;
private:
HWND _handle;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
OSHandle::init_type();
register_type(_type_handle, "WinGraphicsPipe::WinHandle",
OSHandle::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
private:
HINSTANCE _hUser32;
typedef BOOL (WINAPI *PFN_TRACKMOUSEEVENT)(LPTRACKMOUSEEVENT);

View File

@ -22,6 +22,7 @@
#include "clockObject.h"
#include "config_util.h"
#include "throw_event.h"
#include "nativeWindowHandle.h"
#include <tchar.h>
@ -878,11 +879,11 @@ open_regular_window() {
windisplay_cat.info()
<< "os_handle type " << os_handle->get_type() << "\n";
if (os_handle->is_of_type(WinGraphicsPipe::WinHandle::get_class_type())) {
WinGraphicsPipe::WinHandle *win_handle = DCAST(WinGraphicsPipe::WinHandle, os_handle);
if (os_handle->is_of_type(NativeWindowHandle::WinHandle::get_class_type())) {
WinGraphicsPipe::WinHandle *win_handle = DCAST(NativeWindowHandle::WinHandle, os_handle);
_hparent = win_handle->get_handle();
} else if (os_handle->is_of_type(WindowHandle::IntHandle::get_class_type())) {
WindowHandle::IntHandle *int_handle = DCAST(WindowHandle::IntHandle, os_handle);
} else if (os_handle->is_of_type(NativeWindowHandle::IntHandle::get_class_type())) {
WindowHandle::IntHandle *int_handle = DCAST(NativeWindowHandle::IntHandle, os_handle);
_hparent = (HWND)int_handle->get_handle();
}
}

View File

@ -78,6 +78,5 @@ init_libx11display() {
initialized = true;
x11GraphicsPipe::init_type();
x11GraphicsPipe::x11Handle::init_type();
x11GraphicsWindow::init_type();
}

View File

@ -70,22 +70,3 @@ get_hidden_cursor() {
}
return _hidden_cursor;
}
////////////////////////////////////////////////////////////////////
// Function: x11GraphicsPipe::x11Handle::Constructor
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE x11GraphicsPipe::x11Handle::
x11Handle(Window handle) : _handle(handle) {
}
////////////////////////////////////////////////////////////////////
// Function: x11GraphicsPipe::x11Handle::get_handle
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
INLINE Window x11GraphicsPipe::x11Handle::
get_handle() const {
return _handle;
}

View File

@ -18,7 +18,6 @@
#include "frameBufferProperties.h"
TypeHandle x11GraphicsPipe::_type_handle;
TypeHandle x11GraphicsPipe::x11Handle::_type_handle;
bool x11GraphicsPipe::_error_handlers_installed = false;
x11GraphicsPipe::ErrorHandlerFunc *x11GraphicsPipe::_prev_error_handler;
@ -132,40 +131,6 @@ x11GraphicsPipe::
}
}
////////////////////////////////////////////////////////////////////
// Function: x11GraphicsPipe::make_window_handle
// Access: Public
// Description: Constructs a new WindowHandle object that
// encapsulates a window with the indicated Window
// handle.
////////////////////////////////////////////////////////////////////
WindowHandle *x11GraphicsPipe::
make_window_handle(Window window) {
return new WindowHandle(new x11Handle(window));
}
////////////////////////////////////////////////////////////////////
// Function: x11GraphicsPipe::make_int_window_handle
// Access: Public, Virtual
// Description: Creates a WindowHandle by interpreting the indicated
// integer value as an OS-specific pointer, e.g. to a
// HWND or a Window object, if this makes sense for the
// current OS. Returns the WindowHandle if successful,
// or NULL if not.
//
// This method exists primarily for the benefit of
// Python, which likes to pass around pointers as
// integers. For other languages, see the OS-specific
// make_window_handle() method, which is defined for
// each particular OS-specific GraphicsPipe type. It is
// preferable to use make_window_handle() instead of
// make_int_window_handle().
////////////////////////////////////////////////////////////////////
WindowHandle *x11GraphicsPipe::
make_int_window_handle(size_t window) {
return make_window_handle((Window)window);
}
////////////////////////////////////////////////////////////////////
// Function: x11GraphicsPipe::get_preferred_window_thread
// Access: Public, Virtual
@ -289,26 +254,3 @@ io_error_handler(Display *display) {
// anyway. Sigh. Very poor design on X's part.
return 0;
}
////////////////////////////////////////////////////////////////////
// Function: x11GraphicsPipe::x11Handle::format_string_handle
// Access: Published, Virtual
// Description: Writes the OS-specific value to the indicated stream
// in whatever representation makes sense, but it should
// format it as a decimal integer if possible, for
// consistency between platforms.
////////////////////////////////////////////////////////////////////
void x11GraphicsPipe::x11Handle::
format_string_handle(ostream &out) const {
out << (size_t)_handle;
}
////////////////////////////////////////////////////////////////////
// Function: x11GraphicsPipe::x11Handle::output
// Access: Published
// Description:
////////////////////////////////////////////////////////////////////
void x11GraphicsPipe::x11Handle::
output(ostream &out) const {
out << (void *)_handle;
}

View File

@ -44,40 +44,6 @@ public:
INLINE Cursor get_hidden_cursor();
WindowHandle *make_window_handle(Window window);
virtual WindowHandle *make_int_window_handle(size_t window);
public:
// Wraps a WindowHandle type for X11.
class x11Handle : public WindowHandle::OSHandle {
PUBLISHED:
INLINE x11Handle(Window handle);
virtual void format_string_handle(ostream &out) const;
virtual void output(ostream &out) const;
INLINE Window get_handle() const;
private:
Window _handle;
public:
static TypeHandle get_class_type() {
return _type_handle;
}
static void init_type() {
OSHandle::init_type();
register_type(_type_handle, "x11GraphicsPipe::x11Handle",
OSHandle::get_class_type());
}
virtual TypeHandle get_type() const {
return get_class_type();
}
virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
private:
static TypeHandle _type_handle;
};
public:
virtual PreferredWindowThread get_preferred_window_thread() const;