~lubuntu-dev/lxde/lxqt-globalkeys

« back to all changes in this revision

Viewing changes to daemon/core.cpp

  • Committer: Alf Gaida
  • Author(s): ska67
  • Date: 2018-01-16 18:41:36 UTC
  • Revision ID: git-v1:e8a2a75b432511b13aa4cdb03f15aeec34b139a6
Daemon triggers on KeyRelease

The event loop responds to KeyPress and KeyRelease events.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1121
1121
 
1122
1122
    Window rootWindow = DefaultRootWindow(mDisplay);
1123
1123
 
1124
 
    XSelectInput(mDisplay, rootWindow, KeyPressMask);
 
1124
    XSelectInput(mDisplay, rootWindow, KeyPressMask | KeyReleaseMask);
1125
1125
 
1126
1126
    mInterClientCommunicationWindow = XCreateSimpleWindow(mDisplay, rootWindow, 0, 0, 1, 1, 0, 0, 0);
1127
1127
 
1145
1145
    char signal = 0;
1146
1146
    if (write(mX11ResponsePipe[STDOUT_FILENO], &signal, sizeof(signal)) == sizeof(signal))
1147
1147
    {
 
1148
        bool keyReleaseExpected = false;
 
1149
 
1148
1150
        XEvent event;
1149
1151
        while (mX11EventLoopActive)
1150
1152
        {
1154
1156
                break;
1155
1157
            }
1156
1158
 
1157
 
            if (event.type == KeyPress && mDataMutex.tryLock(0))
 
1159
            if ((event.type == KeyRelease) && !keyReleaseExpected)
 
1160
            {
 
1161
                // pop event from the x11 queue and do nothing
 
1162
                XNextEvent(mDisplay, &event);
 
1163
                continue;
 
1164
            }
 
1165
 
 
1166
            if (((event.type == KeyPress) || (event.type == KeyRelease)) && mDataMutex.tryLock(0))
1158
1167
            {
1159
1168
                std::unique_lock<QMutex> unlocker(mDataMutex, std::adopt_lock);
1160
1169
 
1388
1397
            else
1389
1398
            // check for pending pipe requests from other thread
1390
1399
            {
1391
 
                if (event.type != KeyPress) {
 
1400
                if ((event.type != KeyPress) && (event.type != KeyRelease)) {
1392
1401
                    XNextEvent(mDisplay, &event);
1393
1402
                }
1394
1403