diff --git a/common/yacreader_flow_gl.cpp b/common/yacreader_flow_gl.cpp index 5490ec10..44302e34 100644 --- a/common/yacreader_flow_gl.cpp +++ b/common/yacreader_flow_gl.cpp @@ -988,8 +988,31 @@ void YACReaderFlowGL::mousePressEvent(QMouseEvent *event) void YACReaderFlowGL::mouseDoubleClickEvent(QMouseEvent* event) { - emit selected(centerIndex()); - event->accept(); + float x,y; + x = event->x(); + y = event->y(); + GLint viewport[4]; + GLdouble modelview[16]; + GLdouble projection[16]; + GLfloat winX, winY, winZ; + GLdouble posX, posY, posZ; + + glGetDoublev( GL_MODELVIEW_MATRIX, modelview ); + glGetDoublev( GL_PROJECTION_MATRIX, projection ); + glGetIntegerv( GL_VIEWPORT, viewport ); + + winX = (float)x; + winY = (float)viewport[3] - (float)y; + glReadPixels( x, int(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ ); + + gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ); + + if(posX <= 0.5 && posX >= -0.5) + { + emit selected(centerIndex()); + event->accept(); + } + } YACReaderComicFlowGL::YACReaderComicFlowGL(QWidget *parent,struct Preset p )