1 /** @file untrapper.cpp Mouse untrapping utility. 2 * 3 * @authors Copyright (c) 2014-2017 Jaakko Keränen <jaakko.keranen@iki.fi> 4 * 5 * @par License 6 * LGPL: http://www.gnu.org/licenses/lgpl.html 7 * 8 * <small>This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU Lesser General Public License as published by 10 * the Free Software Foundation; either version 3 of the License, or (at your 11 * option) any later version. This program is distributed in the hope that it 12 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 14 * General Public License for more details. You should have received a copy of 15 * the GNU Lesser General Public License along with this program; if not, see: 16 * http://www.gnu.org/licenses</small> 17 */ 18 19 #include "de/Untrapper" 20 21 namespace de { 22 DENG2_PIMPL(Untrapper)23DENG2_PIMPL(Untrapper) 24 { 25 GLWindow &window; 26 bool wasTrapped; 27 28 Impl(Public *i, GLWindow &w) : Base(i), window(w) 29 { 30 wasTrapped = window.eventHandler().isMouseTrapped(); 31 if (wasTrapped) 32 { 33 window.eventHandler().trapMouse(false); 34 } 35 } 36 37 ~Impl() 38 { 39 if (wasTrapped) 40 { 41 window.eventHandler().trapMouse(); 42 } 43 } 44 }; 45 Untrapper(GLWindow & window)46Untrapper::Untrapper(GLWindow &window) : d(new Impl(this, window)) 47 {} 48 49 } // namespace de 50