mirror of
https://github.com/debauchee/barrier.git
synced 2025-07-14 15:17:49 +02:00
Changes from mercurial repository.
This commit is contained in:
parent
44bb32f476
commit
98c68897d8
135 changed files with 2686 additions and 26965 deletions
|
@ -21,6 +21,7 @@
|
|||
#include "CClipboard.h"
|
||||
#include "CKeyMap.h"
|
||||
#include "XScreen.h"
|
||||
#include "XArch.h"
|
||||
#include "CLog.h"
|
||||
#include "CStopwatch.h"
|
||||
#include "CStringUtil.h"
|
||||
|
@ -36,9 +37,11 @@
|
|||
# define XK_MISCELLANY
|
||||
# define XK_XKB_KEYS
|
||||
# include <X11/keysymdef.h>
|
||||
extern "C" {
|
||||
# include <X11/extensions/dpms.h>
|
||||
}
|
||||
# if HAVE_X11_EXTENSIONS_DPMS_H
|
||||
extern "C" {
|
||||
# include <X11/extensions/dpms.h>
|
||||
}
|
||||
# endif
|
||||
# if HAVE_X11_EXTENSIONS_XTEST_H
|
||||
# include <X11/extensions/XTest.h>
|
||||
# else
|
||||
|
@ -74,8 +77,9 @@
|
|||
|
||||
CXWindowsScreen* CXWindowsScreen::s_screen = NULL;
|
||||
|
||||
CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary) :
|
||||
CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary, int mouseScrollDelta) :
|
||||
m_isPrimary(isPrimary),
|
||||
m_mouseScrollDelta(mouseScrollDelta),
|
||||
m_display(NULL),
|
||||
m_root(None),
|
||||
m_window(None),
|
||||
|
@ -94,14 +98,20 @@ CXWindowsScreen::CXWindowsScreen(const char* displayName, bool isPrimary) :
|
|||
m_screensaver(NULL),
|
||||
m_screensaverNotify(false),
|
||||
m_xtestIsXineramaUnaware(true),
|
||||
m_preserveFocus(false),
|
||||
m_xkb(false)
|
||||
{
|
||||
assert(s_screen == NULL);
|
||||
|
||||
if (mouseScrollDelta==0) m_mouseScrollDelta=120;
|
||||
s_screen = this;
|
||||
|
||||
// initializes Xlib support for concurrent threads.
|
||||
XInitThreads();
|
||||
if (XInitThreads() == 0)
|
||||
{
|
||||
throw XArch("XInitThreads() returned zero");
|
||||
}
|
||||
|
||||
|
||||
// set the X I/O error handler so we catch the display disconnecting
|
||||
XSetIOErrorHandler(&CXWindowsScreen::ioErrorHandler);
|
||||
|
@ -217,13 +227,15 @@ CXWindowsScreen::disable()
|
|||
|
||||
// restore auto-repeat state
|
||||
if (!m_isPrimary && m_autoRepeat) {
|
||||
XAutoRepeatOn(m_display);
|
||||
//XAutoRepeatOn(m_display);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CXWindowsScreen::enter()
|
||||
{
|
||||
screensaver(false);
|
||||
|
||||
// release input context focus
|
||||
if (m_ic != NULL) {
|
||||
XUnsetICFocus(m_ic);
|
||||
|
@ -236,6 +248,7 @@ CXWindowsScreen::enter()
|
|||
XSetInputFocus(m_display, m_lastFocus, m_lastFocusRevert, CurrentTime);
|
||||
}
|
||||
|
||||
#if HAVE_X11_EXTENSIONS_DPMS_H
|
||||
// Force the DPMS to turn screen back on since we don't
|
||||
// actually cause physical hardware input to trigger it
|
||||
int dummy;
|
||||
|
@ -248,7 +261,8 @@ CXWindowsScreen::enter()
|
|||
if (enabled && powerlevel != DPMSModeOn)
|
||||
DPMSForceLevel(m_display, DPMSModeOn);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// unmap the hider/grab window. this also ungrabs the mouse and
|
||||
// keyboard if they're grabbed.
|
||||
XUnmapWindow(m_display, m_window);
|
||||
|
@ -269,7 +283,7 @@ CXWindowsScreen::enter()
|
|||
// turn off auto-repeat. we do this so fake key press events don't
|
||||
// cause the local server to generate their own auto-repeats of
|
||||
// those keys.
|
||||
XAutoRepeatOff(m_display);
|
||||
//XAutoRepeatOff(m_display);
|
||||
}
|
||||
|
||||
// now on screen
|
||||
|
@ -286,7 +300,7 @@ CXWindowsScreen::leave()
|
|||
// the X server when the auto-repeat configuration is changed so
|
||||
// we can't track the desired configuration.
|
||||
if (m_autoRepeat) {
|
||||
XAutoRepeatOn(m_display);
|
||||
//XAutoRepeatOn(m_display);
|
||||
}
|
||||
|
||||
// move hider window under the cursor center
|
||||
|
@ -306,7 +320,9 @@ CXWindowsScreen::leave()
|
|||
XGetInputFocus(m_display, &m_lastFocus, &m_lastFocusRevert);
|
||||
|
||||
// take focus
|
||||
XSetInputFocus(m_display, m_window, RevertToPointerRoot, CurrentTime);
|
||||
if (m_isPrimary || !m_preserveFocus) {
|
||||
XSetInputFocus(m_display, m_window, RevertToPointerRoot, CurrentTime);
|
||||
}
|
||||
|
||||
// now warp the mouse. we warp after showing the window so we're
|
||||
// guaranteed to get the mouse leave event and to prevent the
|
||||
|
@ -396,6 +412,7 @@ void
|
|||
CXWindowsScreen::resetOptions()
|
||||
{
|
||||
m_xtestIsXineramaUnaware = true;
|
||||
m_preserveFocus = false;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -406,6 +423,10 @@ CXWindowsScreen::setOptions(const COptionsList& options)
|
|||
m_xtestIsXineramaUnaware = (options[i + 1] != 0);
|
||||
LOG((CLOG_DEBUG1 "XTest is Xinerama unaware %s", m_xtestIsXineramaUnaware ? "true" : "false"));
|
||||
}
|
||||
else if (options[i] == kOptionScreenPreserveFocus) {
|
||||
m_preserveFocus = (options[i + 1] != 0);
|
||||
LOG((CLOG_DEBUG1 "Preserve Focus = %s", m_preserveFocus ? "true" : "false"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -837,8 +858,12 @@ CXWindowsScreen::fakeMouseWheel(SInt32, SInt32 yDelta) const
|
|||
yDelta = -yDelta;
|
||||
}
|
||||
|
||||
if (yDelta < m_mouseScrollDelta) {
|
||||
LOG((CLOG_WARN "Wheel scroll delta (%d) smaller than threshold (%d)", yDelta, m_mouseScrollDelta));
|
||||
}
|
||||
|
||||
// send as many clicks as necessary
|
||||
for (; yDelta >= 120; yDelta -= 120) {
|
||||
for (; yDelta >= m_mouseScrollDelta; yDelta -= m_mouseScrollDelta) {
|
||||
XTestFakeButtonEvent(m_display, xButton, True, CurrentTime);
|
||||
XTestFakeButtonEvent(m_display, xButton, False, CurrentTime);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue