void ObjectView::MouseUp(BPoint point) { if (fTrackingInfo.isTracking) { //spin the teapot on release, TODO: use a marching sum and divide by time if (fTrackingInfo.buttons == B_PRIMARY_MOUSE_BUTTON && fTrackingInfo.pickedObject != NULL && (fabs(fTrackingInfo.lastDx) > 1.0f || fabs(fTrackingInfo.lastDy) > 1.0f) ) { fTrackingInfo.pickedObject->Spin(0.5f * fTrackingInfo.lastDy, 0.5f * fTrackingInfo.lastDx); setEvent(drawEvent); } //stop tracking fTrackingInfo.isTracking = false; fTrackingInfo.buttons = 0; fTrackingInfo.pickedObject = NULL; fTrackingInfo.lastX = 0.0f; fTrackingInfo.lastY = 0.0f; fTrackingInfo.lastDx = 0.0f; fTrackingInfo.lastDy = 0.0f; BCursor grabCursor(B_CURSOR_ID_GRAB); SetViewCursor(&grabCursor); } }
void Core::getActiveWindow() { const QList<QScreen *> screens = qApp->screens(); const QDesktopWidget *desktop = QApplication::desktop(); const int screenNum = desktop->screenNumber(QCursor::pos()); WId wnd = KWindowSystem::activeWindow(); if (!wnd) { *_pixelMap = screens[screenNum]->grabWindow(desktop->winId()); exit(1); } // no decorations option is selected if (_conf->getNoDecoration()) { *_pixelMap = screens[screenNum]->grabWindow(wnd); return; } KWindowInfo info(wnd, NET::XAWMState | NET::WMFrameExtents); if (info.mappingState() != NET::Visible) qWarning() << "Window not visible"; QRect geometry = info.frameGeometry(); *_pixelMap = screens[screenNum]->grabWindow(QApplication::desktop()->winId(), geometry.x(), geometry.y(), geometry.width(), geometry.height()); grabCursor(geometry.x(), geometry.y()); }
// get screenshot void Core::screenShot(bool first) { sleep(400); // delay for hide "fade effect" bug in the KWin with compositing _firstScreen = first; // Update date last crenshot, if it is a first screen if (_firstScreen) _conf->updateLastSaveDate(); switch(_conf->getTypeScreen()) { case 0: { const QList<QScreen *> screens = qApp->screens(); const QDesktopWidget *desktop = QApplication::desktop(); const int screenNum = desktop->screenNumber(QCursor::pos()); *_pixelMap = screens[screenNum]->grabWindow(desktop->winId()); grabCursor(0, 0); checkAutoSave(first); _wnd->updatePixmap(_pixelMap); break; } case 1: { getActiveWindow(); checkAutoSave(first); _wnd->updatePixmap(_pixelMap); break; } case 2: { _selector = new RegionSelect(_conf); connect(_selector, &RegionSelect::processDone, this, &Core::regionGrabbed); break; } case 3: { _selector = new RegionSelect(_conf, _lastSelectedArea); connect(_selector, &RegionSelect::processDone, this, &Core::regionGrabbed); break; } default: *_pixelMap = QPixmap::grabWindow(QApplication::desktop()->winId()); break; } _wnd->updatePixmap(_pixelMap); _wnd->restoreFromShot(); }
void DestroyKeyboard() { XkbSetDetectableAutoRepeat(g.Disp, 0, NULL); // Enable cursor and revert grab cursor if mouse if (g.cfg.PadDef[0].Type == PSE_PAD_TYPE_MOUSE || g.cfg.PadDef[1].Type == PSE_PAD_TYPE_MOUSE) { grabCursor(g.Disp, window, 0); showCursor(g.Disp, window, 1); } else if (g.cfg.HideCursor) { showCursor(g.Disp, window, 1); } // Enable screensaver if it was disabled - this could be in different place if (resumeScrSaver) { char buf[64]; printf("Resuming Window ID 0x%x to activate screensaver.\n", window); snprintf(buf, 64, "xdg-screensaver resume 0x%x", window); FILE *phandle = popen(buf, "r"); pclose(phandle); } }
void BitBltGrabber::grab(const Rect& rect, Buffer* destination) { resizeBitmapIfNecessary(rect.w, rect.h); SelectObject(_hdcCapture, _hBitmap); BOOL result = BitBlt(_hdcCapture, 0, 0, rect.w, rect.h, _hdcDesktop, rect.x, rect.y, SRCCOPY | CAPTUREBLT); if (result == FALSE) throw exception(strstream() << "Failed to BitBlt with error code " << GetLastError()); // draw mouse cursor into buffer if (_grabMouseCursor) { grabCursor(rect, _hdcCapture); } int lines = GetDIBits(_hdcDesktop, _hBitmap, 0, _captureSize.height, _bmpBuffer, &_bmpInfo, DIB_RGB_COLORS); if (lines == 0) throw exception(strstream() << "Failed to GetDIBits with return " << lines << " and with error code " << GetLastError()); copyBitmapToBuffer(_bmpBuffer, rect.w * 4, lines, destination); }
void InitKeyboard() { int revert_to; wmprotocols = XInternAtom(g.Disp, "WM_PROTOCOLS", 0); wmdelwindow = XInternAtom(g.Disp, "WM_DELETE_WINDOW", 0); // Hide cursor and lock cursor to window if type is mouse XkbSetDetectableAutoRepeat(g.Disp, 1, NULL); XGetInputFocus(g.Disp, &window, &revert_to); if (g.cfg.PadDef[0].Type == PSE_PAD_TYPE_MOUSE || g.cfg.PadDef[1].Type == PSE_PAD_TYPE_MOUSE) { grabCursor(g.Disp, window, 1); showCursor(g.Disp, window, 0); } else if (g.cfg.HideCursor) { showCursor(g.Disp, window, 0); } // Disable screensaver - this could be in different place resumeScrSaver = 0; if (g.cfg.PreventScrSaver) { char buf[64]; snprintf(buf, 64, "xdg-screensaver suspend 0x%x > /dev/null 2>&1", window); if (pclose(popen(buf, "r")) == 0) { resumeScrSaver = 1; printf("Suspending Window ID 0x%x of activating screensaver.\n", window); } else { //resumeScrSaver = 0; fprintf(stderr, "Failed to execute xdg-screensaver (maybe not installed?)\n"); } } g_currentMouse_X = 0; g_currentMouse_Y = 0; g.PadState[0].KeyStatus = 0xFFFF; g.PadState[1].KeyStatus = 0xFFFF; }
const Cursor& Cursor::fromType(Cursor::Type type) { switch (type) { case Cursor::Pointer: return pointerCursor(); case Cursor::Cross: return crossCursor(); case Cursor::Hand: return handCursor(); case Cursor::IBeam: return iBeamCursor(); case Cursor::Wait: return waitCursor(); case Cursor::Help: return helpCursor(); case Cursor::EastResize: return eastResizeCursor(); case Cursor::NorthResize: return northResizeCursor(); case Cursor::NorthEastResize: return northEastResizeCursor(); case Cursor::NorthWestResize: return northWestResizeCursor(); case Cursor::SouthResize: return southResizeCursor(); case Cursor::SouthEastResize: return southEastResizeCursor(); case Cursor::SouthWestResize: return southWestResizeCursor(); case Cursor::WestResize: return westResizeCursor(); case Cursor::NorthSouthResize: return northSouthResizeCursor(); case Cursor::EastWestResize: return eastWestResizeCursor(); case Cursor::NorthEastSouthWestResize: return northEastSouthWestResizeCursor(); case Cursor::NorthWestSouthEastResize: return northWestSouthEastResizeCursor(); case Cursor::ColumnResize: return columnResizeCursor(); case Cursor::RowResize: return rowResizeCursor(); case Cursor::MiddlePanning: return middlePanningCursor(); case Cursor::EastPanning: return eastPanningCursor(); case Cursor::NorthPanning: return northPanningCursor(); case Cursor::NorthEastPanning: return northEastPanningCursor(); case Cursor::NorthWestPanning: return northWestPanningCursor(); case Cursor::SouthPanning: return southPanningCursor(); case Cursor::SouthEastPanning: return southEastPanningCursor(); case Cursor::SouthWestPanning: return southWestPanningCursor(); case Cursor::WestPanning: return westPanningCursor(); case Cursor::Move: return moveCursor(); case Cursor::VerticalText: return verticalTextCursor(); case Cursor::Cell: return cellCursor(); case Cursor::ContextMenu: return contextMenuCursor(); case Cursor::Alias: return aliasCursor(); case Cursor::Progress: return progressCursor(); case Cursor::NoDrop: return noDropCursor(); case Cursor::Copy: return copyCursor(); case Cursor::None: return noneCursor(); case Cursor::NotAllowed: return notAllowedCursor(); case Cursor::ZoomIn: return zoomInCursor(); case Cursor::ZoomOut: return zoomOutCursor(); case Cursor::Grab: return grabCursor(); case Cursor::Grabbing: return grabbingCursor(); case Cursor::Custom: ASSERT_NOT_REACHED(); } return pointerCursor(); }