Merge remote-tracking branch 'upstream/master'

This commit is contained in:
konstantin.matveyev 2017-08-15 22:15:31 +03:00
commit 237ab29ff8
18 changed files with 260 additions and 115 deletions

View File

@ -29,7 +29,7 @@ matrix:
name: "openscenegraph/OpenSceneGraph"
description: "OpenSceneGraph build"
notification_email: robert@openscenegraph.com
build_command_prepend: "cmake -DCMAKE_BUILD_TYPE=Release ."
build_command_prepend: "cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_OSG_DEPRECATED_SERIALIZERS=OFF ."
build_command: "make -j 3"
branch_pattern: coverity_scan
apt:

View File

@ -1,58 +0,0 @@
# Locate zlib
# This module defines
# ZLIB_LIBRARY
# ZLIB_FOUND, if false, do not try to link to zlib
# ZLIB_INCLUDE_DIR, where to find the headers
#
# $ZLIB_DIR is an environment variable that would
# correspond to the ./configure --prefix=$ZLIB_DIR
# used in building zlib.
#
# Created by Ulrich Hertlein.
# prefer FindZLIB from cmake distribution
if(EXISTS ${CMAKE_ROOT}/Modules/FindZLIB.cmake)
include(${CMAKE_ROOT}/Modules/FindZLIB.cmake)
if(ZLIB_FOUND)
return()
endif()
endif()
FIND_PATH(ZLIB_INCLUDE_DIR zlib.h
$ENV{ZLIB_DIR}/include
$ENV{ZLIB_DIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/include
/usr/include
/sw/include # Fink
/opt/local/include # DarwinPorts
/opt/csw/include # Blastwave
/opt/include
/usr/freeware/include
)
FIND_LIBRARY(ZLIB_LIBRARY
NAMES z libz zlib
PATHS
$ENV{ZLIB_DIR}/lib
$ENV{ZLIB_DIR}
~/Library/Frameworks
/Library/Frameworks
/usr/local/lib
/usr/lib
/sw/lib
/opt/local/lib
/opt/csw/lib
/opt/lib
/usr/freeware/lib64
)
SET(ZLIB_FOUND "NO")
IF(ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR)
SET(ZLIB_FOUND "YES")
ENDIF(ZLIB_LIBRARY AND ZLIB_INCLUDE_DIR)

View File

@ -1,6 +1,7 @@
[![Build Status](https://travis-ci.org/openscenegraph/OpenSceneGraph.svg?branch=master)](https://travis-ci.org/openscenegraph/OpenSceneGraph)
[![Coverity Status](https://scan.coverity.com/projects/9159/badge.svg)](https://scan.coverity.com/projects/openscenegraph-openscenegraph)
[![Documentation](https://codedocs.xyz/openscenegraph/OpenSceneGraph.svg)](https://codedocs.xyz/openscenegraph/OpenSceneGraph/)
[ABI Tracker](https://abi-laboratory.pro/tracker/timeline/openscenegraph/ "ABI Tracker")
# Introduction

View File

@ -43,7 +43,7 @@ public:
{
}
virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter&)
{
if (ea.getEventType() == osgGA::GUIEventAdapter::KEYUP)
{

View File

@ -162,7 +162,7 @@ ENDIF()
IF( ZLIB_FOUND )
ADD_DEFINITIONS( -DUSE_ZLIB )
INCLUDE_DIRECTORIES( ${ZLIB_INCLUDE_DIR} )
SET(COMPRESSION_LIBRARIES ZLIB_LIBRARY)
SET(COMPRESSION_LIBRARIES ZLIB_LIBRARIES)
ENDIF()
################################################################################

View File

@ -24,7 +24,7 @@ SET(TARGET_H
IF(ZLIB_FOUND)
SET(TARGET_LIBRARIES_VARS
CURL_LIBRARY
ZLIB_LIBRARY)
ZLIB_LIBRARIES)
ELSE()
SET(TARGET_LIBRARIES_VARS
CURL_LIBRARY)

View File

@ -5,7 +5,7 @@ IF (DCMTK_FOUND)
SET(TARGET_SRC ReaderWriterDICOM.cpp )
LINK_LIBRARIES(${DCMTK_LIBRARIES} ${ZLIB_LIBRARY})
LINK_LIBRARIES(${DCMTK_LIBRARIES} ${ZLIB_LIBRARIES})
ADD_DEFINITIONS(-DUSE_DCMTK)

View File

@ -2,7 +2,7 @@ INCLUDE_DIRECTORIES( ${OPENEXR_INCLUDE_DIR}/OpenEXR )
SET(TARGET_SRC ReaderWriterEXR.cpp )
SET(TARGET_LIBRARIES_VARS ${OPENEXR_LIBRARIES_VARS} ZLIB_LIBRARY)
SET(TARGET_LIBRARIES_VARS ${OPENEXR_LIBRARIES_VARS} ZLIB_LIBRARIES)
IF(CMAKE_COMPILER_IS_GNUCXX)
# Remove -Wshadow flag as it barfs on ffmoeg headers

View File

@ -4,7 +4,7 @@ SET(TARGET_SRC
ReaderWriterGZ.cpp
)
SET(TARGET_LIBRARIES_VARS ZLIB_LIBRARY )
SET(TARGET_LIBRARIES_VARS ZLIB_LIBRARIES )
#### end var setup ###

View File

@ -269,7 +269,7 @@ SET(TARGET_H
SET(TARGET_ADDED_LIBRARIES osgSim osgFX osgText osgTerrain osgVolume)
IF(ZLIB_FOUND)
SET(TARGET_LIBRARIES_VARS ZLIB_LIBRARY)
SET(TARGET_LIBRARIES_VARS ZLIB_LIBRARIES)
ENDIF()
#### end var setup ###

View File

@ -18,6 +18,10 @@
#include <osg/Geode>
#include <osg/io_utils>
#include <osgUtil/SmoothingVisitor>
#include <osg/TexEnv>
#include <osgDB/ReaderWriter>
#include <osgDB/ReadFile>
#include <osg/Texture2D>
using namespace std;
using namespace ply;
@ -35,6 +39,7 @@ VertexData::VertexData()
_diffuse = NULL;
_ambient = NULL;
_specular = NULL;
_texcoord = NULL;
}
@ -66,6 +71,8 @@ void VertexData::readVertices( PlyFile* file, const int nVertices,
unsigned char specular_blue;
float specular_coeff;
float specular_power;
float texture_u;
float texture_v;
} vertex;
PlyProperty vertexProps[] =
@ -74,8 +81,8 @@ void VertexData::readVertices( PlyFile* file, const int nVertices,
{ "y", PLY_FLOAT, PLY_FLOAT, offsetof( _Vertex, y ), 0, 0, 0, 0 },
{ "z", PLY_FLOAT, PLY_FLOAT, offsetof( _Vertex, z ), 0, 0, 0, 0 },
{ "nx", PLY_FLOAT, PLY_FLOAT, offsetof( _Vertex, nx ), 0, 0, 0, 0 },
{ "ny", PLY_FLOAT, PLY_FLOAT, offsetof( _Vertex, ny ), 0, 0, 0, 0 },
{ "nz", PLY_FLOAT, PLY_FLOAT, offsetof( _Vertex, nz ), 0, 0, 0, 0 },
{ "ny", PLY_FLOAT, PLY_FLOAT, offsetof(_Vertex, ny), 0, 0, 0, 0 },
{ "nz", PLY_FLOAT, PLY_FLOAT, offsetof(_Vertex, nz), 0, 0, 0, 0 },
{ "red", PLY_UCHAR, PLY_UCHAR, offsetof( _Vertex, red ), 0, 0, 0, 0 },
{ "green", PLY_UCHAR, PLY_UCHAR, offsetof( _Vertex, green ), 0, 0, 0, 0 },
{ "blue", PLY_UCHAR, PLY_UCHAR, offsetof( _Vertex, blue ), 0, 0, 0, 0 },
@ -91,6 +98,8 @@ void VertexData::readVertices( PlyFile* file, const int nVertices,
{ "specular_blue", PLY_UCHAR, PLY_UCHAR, offsetof( _Vertex, specular_blue ), 0, 0, 0, 0 },
{ "specular_coeff", PLY_FLOAT, PLY_FLOAT, offsetof( _Vertex, specular_coeff ), 0, 0, 0, 0 },
{ "specular_power", PLY_FLOAT, PLY_FLOAT, offsetof( _Vertex, specular_power ), 0, 0, 0, 0 },
{ "texture_u", PLY_FLOAT, PLY_FLOAT, offsetof(_Vertex, texture_u), 0, 0, 0, 0 },
{ "texture_v", PLY_FLOAT, PLY_FLOAT, offsetof(_Vertex, texture_v), 0, 0, 0, 0 },
};
// use all 6 properties when reading colors, only the first 3 otherwise
@ -120,6 +129,10 @@ void VertexData::readVertices( PlyFile* file, const int nVertices,
for( int i = 16; i < 21; ++i )
ply_get_property( file, "vertex", &vertexProps[i] );
if (fields & TEXCOORD)
for (int i = 21; i < 23; ++i)
ply_get_property(file, "vertex", &vertexProps[i]);
// check whether array is valid otherwise allocate the space
if(!_vertices.valid())
_vertices = new osg::Vec3Array;
@ -154,6 +167,11 @@ void VertexData::readVertices( PlyFile* file, const int nVertices,
if(!_specular.valid())
_specular = new osg::Vec4Array;
}
if (fields & TEXCOORD)
{
if (!_texcoord.valid())
_texcoord = new osg::Vec2Array;
}
// read in the vertices
for( int i = 0; i < nVertices; ++i )
@ -186,6 +204,8 @@ void VertexData::readVertices( PlyFile* file, const int nVertices,
_specular->push_back( osg::Vec4( (unsigned int) vertex.specular_red / 255.0,
(unsigned int) vertex.specular_green / 255.0 ,
(unsigned int) vertex.specular_blue / 255.0, 1.0 ) );
if (fields & TEXCOORD)
_texcoord->push_back(osg::Vec2(vertex.texture_u,vertex.texture_v));
}
}
@ -291,13 +311,47 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
MESHINFO << filename << ": " << nPlyElems << " elements, file type = "
<< fileType << ", version = " << version << endl;
#endif
char *textureFile = NULL;
for( int i = 0; i < nComments; i++ )
{
if( equal_strings( comments[i], "modified by flipply" ) )
{
_invertFaces = true;
}
if (strncmp(comments[i], "TextureFile",11)==0)
{
textureFile = comments[i]+12;
char * path = new char[strlen(const_cast<char*>(filename)) + 1 + strlen(comments[i])];
if (textureFile[0] == '\\' || textureFile[0] == '/' || textureFile[1] == ':')
{
// texture filename is absolute
strcpy(path, textureFile);
}
else
{
// texture filename is relative
// add directory of ply file
strcpy(path, const_cast<char*>(filename));
char *pp = path + strlen(path);
while (pp >= path)
{
if (*pp == '\\' || *pp == '/')
{
pp++;
*pp = '\0';
break;
}
pp--;
}
if (pp == path - 1)
{
pp++;
*pp = '\0';
}
strcat(path, textureFile);
}
textureFile = path;
}
}
for( int i = 0; i < nPlyElems; ++i )
@ -330,10 +384,10 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
// if the string is vertex means vertex data is started
if( equal_strings( elemNames[i], "vertex" ) )
{
int fields = NONE;
int fields = NONE;
// determine if the file stores vertex colors
for( int j = 0; j < nProps; ++j )
{
{
// if the string have the red means color info is there
if( equal_strings( props[j]->name, "x" ) )
fields |= XYZ;
@ -347,15 +401,19 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
fields |= AMBIENT;
if( equal_strings( props[j]->name, "diffuse_red" ) )
fields |= DIFFUSE;
if( equal_strings( props[j]->name, "specular_red" ) )
if (equal_strings(props[j]->name, "specular_red"))
fields |= SPECULAR;
}
if (equal_strings(props[j]->name, "texture_u"))
fields |= TEXCOORD;
if (equal_strings(props[j]->name, "texture_v"))
fields |= TEXCOORD;
}
if( ignoreColors )
{
fields &= ~(XYZ | NORMALS);
MESHINFO << "Colors in PLY file ignored per request." << endl;
}
{
fields &= ~(XYZ | NORMALS);
MESHINFO << "Colors in PLY file ignored per request." << endl;
}
try {
// Read vertices and store in a std::vector array
@ -363,7 +421,7 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
// Check whether all vertices are loaded or not
MESHASSERT( _vertices->size() == static_cast< size_t >( nElems ) );
// Check if all the optional elements were read or not
// Check if all the optional elements were read or not
if( fields & NORMALS )
{
MESHASSERT( _normals->size() == static_cast< size_t >( nElems ) );
@ -380,9 +438,13 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
{
MESHASSERT( _diffuse->size() == static_cast< size_t >( nElems ) );
}
if( fields & SPECULAR )
if (fields & SPECULAR)
{
MESHASSERT( _specular->size() == static_cast< size_t >( nElems ) );
MESHASSERT(_specular->size() == static_cast< size_t >(nElems));
}
if (fields & TEXCOORD)
{
MESHASSERT(_texcoord->size() == static_cast< size_t >(nElems));
}
result = true;
@ -462,9 +524,9 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
geom->addPrimitiveSet(new osg::DrawArrays(GL_POINTS, 0, _vertices->size()));
// Apply the colours to the model; at the moment this is a
// kludge because we only use one kind and apply them all the
// same way. Also, the priority order is completely arbitrary
// Apply the colours to the model; at the moment this is a
// kludge because we only use one kind and apply them all the
// same way. Also, the priority order is completely arbitrary
if(_colors.valid())
{
@ -478,10 +540,14 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
{
geom->setColorArray(_diffuse.get(), osg::Array::BIND_PER_VERTEX );
}
else if(_specular.valid())
else if(_specular.valid())
{
geom->setColorArray(_specular.get(), osg::Array::BIND_PER_VERTEX );
}
else if (_texcoord.valid())
{
geom->setTexCoordArray(0, _texcoord);
}
// If the model has normals, add them to the geometry
if(_normals.valid())
@ -497,11 +563,26 @@ osg::Node* VertexData::readPlyFile( const char* filename, const bool ignoreColor
// set flage true to activate the vertex buffer object of drawable
geom->setUseVertexBufferObjects(true);
osg::Image *image = NULL;
if (textureFile && (image = osgDB::readImageFile(textureFile)) != NULL)
{
osg::Texture2D *texture = new osg::Texture2D;
texture->setImage(image);
texture->setResizeNonPowerOfTwoHint(false);
osg::TexEnv *texenv = new osg::TexEnv;
texenv->setMode(osg::TexEnv::REPLACE);
osg::StateSet *stateset = geom->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
stateset->setTextureAttribute(0, texenv);
delete[] textureFile;
}
osg::Geode* geode = new osg::Geode;
geode->addDrawable(geom);
return geode;
}
}
return NULL;
}

View File

@ -55,7 +55,8 @@ namespace ply
AMBIENT = 8,
DIFFUSE = 16,
SPECULAR = 32,
RGBA = 64
RGBA = 64,
TEXCOORD = 128
};
// Function which reads all the vertices and colors if color info is
@ -75,6 +76,7 @@ namespace ply
osg::ref_ptr<osg::Vec4Array> _ambient;
osg::ref_ptr<osg::Vec4Array> _diffuse;
osg::ref_ptr<osg::Vec4Array> _specular;
osg::ref_ptr<osg::Vec2Array> _texcoord;
// Normals in osg format
osg::ref_ptr<osg::Vec3Array> _normals;

View File

@ -5,7 +5,7 @@ IF(OSG_CPP_EXCEPTIONS_AVAILABLE)
ENDIF()
SET(TARGET_SRC ReaderWriterPNG.cpp )
SET(TARGET_LIBRARIES_VARS PNG_LIBRARY ZLIB_LIBRARY )
SET(TARGET_LIBRARIES_VARS PNG_LIBRARY ZLIB_LIBRARIES )
#### end var setup ###

View File

@ -4,7 +4,7 @@ INCLUDE_DIRECTORIES(${LIBVNCSERVER_INCLUDE_DIR})
SET(TARGET_EXTERNAL_LIBRARIES
${LIBVNCCLIENT_LIBRARY}
${ZLIB_LIBRARY}
${ZLIB_LIBRARIES}
${JPEG_LIBRARY} )
SET(TARGET_ADDED_LIBRARIES osgWidget )

View File

@ -25,7 +25,7 @@ IF (WIN32)
OPENVRML_LIBRARY
JPEG_LIBRARY
PNG_LIBRARY
ZLIB_LIBRARY)
ZLIB_LIBRARIES)
SET(TARGET_EXTERNAL_LIBRARIES
Ws2_32.lib)
ELSE()

View File

@ -173,14 +173,23 @@ ELSE()
# X11 for everybody else
INCLUDE(FindPkgConfig OPTIONAL)
IF(PKG_CONFIG_FOUND)
PKG_CHECK_MODULES(XRANDR xrandr)
IF(XRANDR_FOUND)
OPTION(OSGVIEWER_USE_XRANDR "Set to ON to enable Xrandr support for GraphicsWindowX11." ON)
ELSE()
SET(OSGVIEWER_USE_XRANDR OFF)
ENDIF()
PKG_CHECK_MODULES(XINERAMA xinerama)
IF(XINERAMA_FOUND)
SET(OSGVIEWER_USE_XINERAMA ON)
ELSE()
SET(OSGVIEWER_USE_XINERAMA OFF)
ENDIF()
ELSE()
SET(OSGVIEWER_USE_XRANDR OFF)
SET(OSGVIEWER_USE_XINERAMA OFF)
ENDIF()
SET(TARGET_H_NO_MODULE_INSTALL
@ -205,6 +214,13 @@ ELSE()
ENDIF()
ENDIF()
IF(OSGVIEWER_USE_XINERAMA)
ADD_DEFINITIONS(-DOSGVIEWER_USE_XINERAMA)
SET(LIB_PRIVATE_HEADERS ${LIB_PRIVATE_HEADERS} ${XINERAMA_INCLUDE_DIRS} )
SET(LIB_EXTRA_LIBS -lXinerama ${LIB_EXTRA_LIBS})
ENDIF()
# X11 on Apple requires X11 library plus OpenGL linking hack on Leopard
IF(APPLE)
# hack for finding the iphone opengl es lib
IF(OSG_BUILD_PLATFORM_IPHONE OR OSG_BUILD_PLATFORM_IPHONE_SIMULATOR)

View File

@ -2556,12 +2556,37 @@ void GraphicsWindowWin32::transformMouseXY( float& x, float& y )
LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
if ((GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH) return TRUE;
//!@todo adapt windows event time to osgGA event queue time for better resolution
double eventTime = getEventQueue()->getTime();
_timeOfLastCheckEvents = eventTime;
if ((GetMessageExtraInfo() & MOUSEEVENTF_FROMTOUCH) == MOUSEEVENTF_FROMTOUCH)
{
switch(uMsg)
{
/////////////////
case WM_SYSCOMMAND:
/////////////////
{
UINT cmd = LOWORD(wParam);
if (cmd == SC_CLOSE)
getEventQueue()->closeWindow(eventTime);
break;
}
/////////////////
case WM_NCLBUTTONUP:
/////////////////
{
UINT cmd = LOWORD(wParam);
if (cmd == HTCLOSE)
getEventQueue()->closeWindow(eventTime);
break;
}
default: break;
}
return TRUE;
}
switch(uMsg)
{
// Wojtek Lewandowski 2010-09-28:
@ -2904,14 +2929,6 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
osg_event->addTouchPoint( ti[i].dwID, osgGA::GUIEventAdapter::TOUCH_BEGAN, pt.x, pt.y);
}
}
else if(ti[i].dwFlags & TOUCHEVENTF_MOVE)
{
if (!osg_event) {
osg_event = getEventQueue()->touchMoved( ti[i].dwID, osgGA::GUIEventAdapter::TOUCH_MOVED, pt.x, pt.y);
} else {
osg_event->addTouchPoint( ti[i].dwID, osgGA::GUIEventAdapter::TOUCH_MOVED, pt.x, pt.y);
}
}
else if(ti[i].dwFlags & TOUCHEVENTF_UP)
{
// No double tap detection with RAW TOUCH Events, sorry.
@ -2921,6 +2938,14 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
osg_event->addTouchPoint( ti[i].dwID, osgGA::GUIEventAdapter::TOUCH_ENDED, pt.x, pt.y);
}
}
else if(ti[i].dwFlags & TOUCHEVENTF_MOVE)
{
if (!osg_event) {
osg_event = getEventQueue()->touchMoved( ti[i].dwID, osgGA::GUIEventAdapter::TOUCH_MOVED, pt.x, pt.y);
} else {
osg_event->addTouchPoint( ti[i].dwID, osgGA::GUIEventAdapter::TOUCH_MOVED, pt.x, pt.y);
}
}
}
}
if (closeTouchInputHandleFunc)
@ -2934,7 +2959,7 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
/* TOUCH inputs for Win8 and later */
/************************************************************************/
// Note by Riccardo Corsi, 2017-03-16
// Currently only handle the PEN input which is not handled nicely by the
// Currently only handle the PEN input which is not handled nicely by the
// WM_TOUCH framework.
// At the moment the PEN is mapped to the mouse, emulating LEFT button click.
// WM_POINTER* messages could entirely replace the WM_TOUCH framework,
@ -2946,7 +2971,7 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
case WM_POINTERDOWN:
/////
{
UINT32 pointerId = GET_POINTERID_WPARAM(wParam);
UINT32 pointerId = GET_POINTERID_WPARAM(wParam);
POINTER_INPUT_TYPE pointerType = PT_POINTER;
// check pointer type
@ -2960,13 +2985,13 @@ LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, UINT uMsg, W
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
ScreenToClient(hwnd, &pt);
getEventQueue()->mouseButtonPress(pt.x, pt.y, osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON);
}
// call default implementation to fallback on WM_TOUCH
else
{
if (_ownsWindow)
if (_ownsWindow)
return ::DefWindowProc(hwnd, uMsg, wParam, lParam);
}
}

View File

@ -38,6 +38,10 @@
#include <X11/extensions/Xrandr.h>
#endif
#ifdef OSGVIEWER_USE_XINERAMA
#include <X11/extensions/Xinerama.h>
#endif
#include <unistd.h>
using namespace osgViewer;
@ -382,23 +386,95 @@ bool GraphicsWindowX11::checkAndSendEventFullScreenIfNeeded(Display* display, in
Atom netWMStateAtom = XInternAtom(display, "_NET_WM_STATE", True);
Atom netWMStateFullscreenAtom = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", True);
OSG_NOTICE<<"GraphicsWindowX11::checkAndSendEventFullScreenIfNeeded()"<<std::endl;
if (netWMStateAtom != None && netWMStateFullscreenAtom != None)
{
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
xev.xclient.send_event = True;
xev.xclient.window = _window;
xev.xclient.message_type = netWMStateAtom;
xev.xclient.format = 32;
xev.xclient.data.l[0] = isFullScreen ? 1 : 0;
xev.xclient.data.l[1] = netWMStateFullscreenAtom;
xev.xclient.data.l[2] = 0;
// set up full screen
{
XEvent xev;
xev.xclient.type = ClientMessage;
xev.xclient.serial = 0;
xev.xclient.send_event = True;
xev.xclient.window = _window;
xev.xclient.message_type = netWMStateAtom;
xev.xclient.format = 32;
xev.xclient.data.l[0] = isFullScreen ? 1 : 0;
xev.xclient.data.l[1] = netWMStateFullscreenAtom;
xev.xclient.data.l[2] = 0;
XSendEvent(display, RootWindow(display, DefaultScreen(display)),
False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
XSendEvent(display, RootWindow(display, DefaultScreen(display)),
False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}
#ifdef OSGVIEWER_USE_XINERAMA
// Span all monitors
if( isFullScreen && XineramaIsActive( display ) )
{
int numMonitors;
XineramaScreenInfo* xi = XineramaQueryScreens( display, &numMonitors );
enum {
TopMost,
BottomMost,
LeftMost,
RightMost
};
uint32_t span[4] = { 0, 0, 0, 0 };
int32_t minx = 2147483647; // INT_MAX
int32_t maxx = -2147483648; // INT_MIN
int32_t miny = 2147483647; // INT_MAX
int32_t maxy = -2147483648; // INT_MIN
for( int i = 0; i < numMonitors; i++ )
{
if( xi[i].x_org < minx )
{
span[LeftMost] = xi[i].screen_number;
minx = xi[i].x_org;
}
if( xi[i].x_org > maxx )
{
span[RightMost] = xi[i].screen_number;
maxx = xi[i].x_org;
}
if( xi[i].y_org < miny )
{
span[TopMost] = xi[i].screen_number;
miny = xi[i].y_org;
}
if( xi[i].y_org > maxy )
{
span[BottomMost] = xi[i].screen_number;
maxy = xi[i].y_org;
}
}
XFree(xi);
Atom fullmons = XInternAtom(display, "_NET_WM_FULLSCREEN_MONITORS", True);
if( fullmons != None )
{
XEvent xev;
xev.type = ClientMessage;
xev.xclient.window = _window;
xev.xclient.message_type = fullmons;
xev.xclient.format = 32;
xev.xclient.data.l[0] = span[TopMost];
xev.xclient.data.l[1] = span[BottomMost];
xev.xclient.data.l[2] = span[LeftMost];
xev.xclient.data.l[3] = span[RightMost];
xev.xclient.data.l[4] = 0;
XSendEvent( display, DefaultRootWindow(display), False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
}
}
#endif
return true;
}
return false;
}
@ -1328,6 +1404,7 @@ bool GraphicsWindowX11::checkEvents()
bool isModifier = keyMapGetKey(modMap, key);
if (!isModifier) forceKey(key, eventTime, false);
}
needNewWindowSize = true;
// release modifier keys
for (unsigned int key = 8; key < 256; key++)
@ -1367,6 +1444,7 @@ bool GraphicsWindowX11::checkEvents()
bool isPressed = keyMapGetKey(keyMap, key);
if (!isPressed) forceKey(key, eventTime, false);
}
needNewWindowSize = true;
// press/release modifier keys
for (unsigned int key = 8; key < 256; key++)