void CServerApp::handleClientsDisconnected(const CEvent&, void*) { EVENTQUEUE->addEvent(CEvent(CEvent::kQuit)); }
void CClientApp::handleScreenError(const CEvent&, void*) { LOG((CLOG_CRIT "error on screen")); EVENTQUEUE->addEvent(CEvent(CEvent::kQuit)); }
void CServerApp::reloadSignalHandler(CArch::ESignal, void*) { EVENTQUEUE->addEvent(CEvent(getReloadConfigEvent(), IEventQueue::getSystemTarget())); }
void CTCPSocket::sendEvent(CEvent::Type type) { m_events->addEvent(CEvent(type, getEventTarget(), NULL)); }
void CClient::sendEvent(CEvent::Type type, void* data) { m_events->addEvent(CEvent(type, getEventTarget(), data)); }
// interrupt handler. this just adds a quit event to the queue. static void interrupt(CArch::ESignal, void*) { EVENTQUEUE->addEvent(CEvent(CEvent::kQuit)); }
void CTCPSocket::sendEvent(CEvent::Type type) { EVENTQUEUE->addEvent(CEvent(type, getEventTarget(), NULL)); }
void CClient::sendEvent(CEvent::Type type, void* data) { EVENTQUEUE->addEvent(CEvent(type, getEventTarget(), data)); }
BOOL WINAPI CAppUtilWindows::consoleHandler(DWORD) { LOG((CLOG_INFO "got shutdown signal")); EVENTQUEUE->addEvent(CEvent(CEvent::kQuit)); return TRUE; }
void CMSWindowsServerTaskBarReceiver::runMenu(int x, int y) { // do popup menu. we need a window to pass to TrackPopupMenu(). // the SetForegroundWindow() and SendMessage() calls around // TrackPopupMenu() are to get the menu to be dismissed when // another window gets activated and are just one of those // win32 weirdnesses. createWindow(); SetForegroundWindow(m_window); HMENU menu = GetSubMenu(m_menu, 0); SetMenuDefaultItem(menu, IDC_TASKBAR_STATUS, FALSE); HMENU logLevelMenu = GetSubMenu(menu, 3); CheckMenuRadioItem(logLevelMenu, 0, 6, CLOG->getFilter() - CLog::kERROR, MF_BYPOSITION); int n = TrackPopupMenu(menu, TPM_NONOTIFY | TPM_RETURNCMD | TPM_LEFTBUTTON | TPM_RIGHTBUTTON, x, y, 0, m_window, NULL); SendMessage(m_window, WM_NULL, 0, 0); // perform the requested operation switch (n) { case IDC_TASKBAR_STATUS: showStatus(); break; case IDC_TASKBAR_LOG: copyLog(); break; case IDC_TASKBAR_SHOW_LOG: ARCH->showConsole(true); break; case IDC_RELOAD_CONFIG: EVENTQUEUE->addEvent(CEvent(getReloadConfigEvent(), IEventQueue::getSystemTarget())); break; case IDC_FORCE_RECONNECT: EVENTQUEUE->addEvent(CEvent(getForceReconnectEvent(), IEventQueue::getSystemTarget())); break; case IDC_TASKBAR_LOG_LEVEL_ERROR: CLOG->setFilter(CLog::kERROR); break; case IDC_TASKBAR_LOG_LEVEL_WARNING: CLOG->setFilter(CLog::kWARNING); break; case IDC_TASKBAR_LOG_LEVEL_NOTE: CLOG->setFilter(CLog::kNOTE); break; case IDC_TASKBAR_LOG_LEVEL_INFO: CLOG->setFilter(CLog::kINFO); break; case IDC_TASKBAR_LOG_LEVEL_DEBUG: CLOG->setFilter(CLog::kDEBUG); break; case IDC_TASKBAR_LOG_LEVEL_DEBUG1: CLOG->setFilter(CLog::kDEBUG1); break; case IDC_TASKBAR_LOG_LEVEL_DEBUG2: CLOG->setFilter(CLog::kDEBUG2); break; case IDC_TASKBAR_QUIT: quit(); break; } }
void COSXScreen::sendEvent(CEvent::Type type, void* data) const { EVENTQUEUE->addEvent(CEvent(type, getEventTarget(), data)); }
bool COSXScreen::onKey(EventRef event) { UInt32 eventKind = GetEventKind(event); // get the key and active modifiers UInt32 virtualKey, macMask; GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(virtualKey), NULL, &virtualKey); GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(macMask), NULL, &macMask); LOG((CLOG_DEBUG1 "event: Key event kind: %d, keycode=%d", eventKind, virtualKey)); // sadly, OS X doesn't report the virtualKey for modifier keys. // virtualKey will be zero for modifier keys. since that's not good // enough we'll have to figure out what the key was. if (virtualKey == 0 && eventKind == kEventRawKeyModifiersChanged) { // get old and new modifier state KeyModifierMask oldMask = getActiveModifiers(); KeyModifierMask newMask = m_keyState->mapModifiersFromOSX(macMask); m_keyState->handleModifierKeys(getEventTarget(), oldMask, newMask); // if the current set of modifiers exactly matches a modifiers-only // hot key then generate a hot key down event. if (m_activeModifierHotKey == 0) { if (m_modifierHotKeys.count(newMask) > 0) { m_activeModifierHotKey = m_modifierHotKeys[newMask]; m_activeModifierHotKeyMask = newMask; EVENTQUEUE->addEvent(CEvent(getHotKeyDownEvent(), getEventTarget(), CHotKeyInfo::alloc(m_activeModifierHotKey))); } } // if a modifiers-only hot key is active and should no longer be // then generate a hot key up event. else if (m_activeModifierHotKey != 0) { KeyModifierMask mask = (newMask & m_activeModifierHotKeyMask); if (mask != m_activeModifierHotKeyMask) { EVENTQUEUE->addEvent(CEvent(getHotKeyUpEvent(), getEventTarget(), CHotKeyInfo::alloc(m_activeModifierHotKey))); m_activeModifierHotKey = 0; m_activeModifierHotKeyMask = 0; } } return true; } // check for hot key. when we're on a secondary screen we disable // all hotkeys so we can capture the OS defined hot keys as regular // keystrokes but that means we don't get our own hot keys either. // so we check for a key/modifier match in our hot key map. if (!m_isOnScreen) { HotKeyToIDMap::const_iterator i = m_hotKeyToIDMap.find(CHotKeyItem(virtualKey, macMask & 0xff00u)); if (i != m_hotKeyToIDMap.end()) { UInt32 id = i->second; // determine event type CEvent::Type type; UInt32 eventKind = GetEventKind(event); if (eventKind == kEventRawKeyDown) { type = getHotKeyDownEvent(); } else if (eventKind == kEventRawKeyUp) { type = getHotKeyUpEvent(); } else { return false; } EVENTQUEUE->addEvent(CEvent(type, getEventTarget(), CHotKeyInfo::alloc(id))); return true; } } // decode event type bool down = (eventKind == kEventRawKeyDown); bool up = (eventKind == kEventRawKeyUp); bool isRepeat = (eventKind == kEventRawKeyRepeat); // map event to keys KeyModifierMask mask; COSXKeyState::CKeyIDs keys; KeyButton button = m_keyState->mapKeyFromEvent(keys, &mask, event); if (button == 0) { return false; } // check for AltGr in mask. if set we send neither the AltGr nor // the super modifiers to clients then remove AltGr before passing // the modifiers to onKey. KeyModifierMask sendMask = (mask & ~KeyModifierAltGr); if ((mask & KeyModifierAltGr) != 0) { sendMask &= ~KeyModifierSuper; } mask &= ~KeyModifierAltGr; // update button state if (down) { m_keyState->onKey(button, true, mask); } else if (up) { if (!m_keyState->isKeyDown(button)) { // up event for a dead key. throw it away. return false; } m_keyState->onKey(button, false, mask); } // send key events for (COSXKeyState::CKeyIDs::const_iterator i = keys.begin(); i != keys.end(); ++i) { m_keyState->sendKeyEvent(getEventTarget(), down, isRepeat, *i, sendMask, 1, button); } return true; }
void CServerApp::handleScreenError(const CEvent&, void*) { LOG((CLOG_CRIT "error on screen")); m_events->addEvent(CEvent(CEvent::kQuit)); }
void CServerApp::handleClientsDisconnected(const CEvent&, void*) { m_events->addEvent(CEvent(CEvent::kQuit)); }