📄 paraboliczoomstate.cpp~
字号:
y = m_h - m_itemSpacing / 2 - h; } } else if (m_dock->m_position == LEFT) { x = m_itemSpacing / 2; if (m_isMinimised) { // Minimised case y = m_itemsCenterMin[itemIndex] - item->getMinHeight() / 2; bitBlt(m_buffer.get(), x, y, m_background.get(), x, y + (dh - m_h) / 2, w, h); } else { // Zoomed case y = m_itemsCenter[itemIndex] - item->getHeight(m_itemsSize[itemIndex]) / 2; } } else if (m_dock->m_position == RIGHT) { if (m_isMinimised) { // Minimised case y = m_itemsCenterMin[itemIndex] - item->getMinHeight() / 2; x = m_w - m_itemSpacing / 2 - item->getMinWidth(); bitBlt(m_buffer.get(), x, y, m_background.get(), x - m_w + m_minW, y + (dh - m_h) / 2, w, h); std::cout << (x - m_w + m_minW) << " " << (y + (dh - m_h) / 2) << " " << w << " " << h << " " << dh << std::endl; } else { // Zoomed case y = m_itemsCenter[itemIndex] - item->getHeight(m_itemsSize[itemIndex]) / 2; x = m_w - m_itemSpacing / 2 - item->getWidth(m_itemsSize[itemIndex]); } } item->draw(*m_buffer, x, y, m_itemsSize[itemIndex]); bitBlt(m_dock, x, y, m_buffer.get(), x, y, w, h); */ // for now use this inefficient method m_dock->repaint();}/** * Update the dock when the active window has been changed */void ParabolicZoomState::activeWindowChanged(WId id) { if ( (id == m_dock->winId()) || (id == 0) || ShowDesktop::the()->desktopShowing() ) return; if (!m_isMinimised) { // zoom mode KWin::WindowInfo info(id, 0, 0); QRect windowFrameGeometry = info.frameGeometry(); int x = (QApplication::desktop()->width() - m_w) / 2; int y = (QApplication::desktop()->height() - m_h) / 2; QRect rect = m_dock->frameGeometry(); NET::WindowType type = info.windowType(0xffff); NET::MappingState mapping_state = info.mappingState(); if ((mapping_state == NET::Visible) && (type == NET::Normal || type == NET::Dialog || type == NET::Unknown || type == NET::Override) && rect.intersects(windowFrameGeometry)) { m_dock->setDockBelow(); QRect intersection = rect & windowFrameGeometry; pauseExecution(); QPixmap intersection_pix = QPixmap::grabWindow(qt_xrootwin(), intersection.x(), intersection.y(), intersection.width(), intersection.height()); QPoint pos = m_dock->mapFromGlobal(intersection.topLeft()); switch(m_dock->m_position) { case TOP: bitBlt(&m_snapshot, pos.x() + x, pos.y() - m_minH, &intersection_pix, 0, 0, intersection.width(), intersection.height()); break; case BOTTOM: bitBlt(&m_snapshot, pos.x() + x, pos.y(), &intersection_pix, 0, 0, intersection.width(), intersection.height()); break; case LEFT: bitBlt(&m_snapshot, pos.x() - m_minW, pos.y() + y, &intersection_pix, 0, 0, intersection.width(), intersection.height()); break; case RIGHT: bitBlt(&m_snapshot, pos.x(), pos.y() + y, &intersection_pix, 0, 0, intersection.width(), intersection.height()); break; default: break; } if (m_dock->m_isAutohide) { fadeSnapshot(); } m_dock->setDockAbove(); m_dock->repaint(); } }}/** * Update autohide mode */void ParabolicZoomState::updateAutohideMode() { updateLayout();}/** * Zoom timer event handler */void ParabolicZoomState::updateZoom() { int i; for (i = 0; i < (int) m_dock->m_items.size(); i++) { m_itemsSize[i] = m_itemsStartSize[i] + (m_itemsEndSize[i] - m_itemsStartSize[i]) * m_animationCurrentStep / m_animationNumSteps; m_itemsCenter[i] = m_itemsStartCenter[i] + (m_itemsEndCenter[i] - m_itemsStartCenter[i]) * m_animationCurrentStep / m_animationNumSteps; } m_dock->repaint(); m_animationCurrentStep++; if (m_animationCurrentStep == 1 && !m_isMinimised) m_dock->setDockAbove(); if (m_animationCurrentStep >= m_animationNumSteps) { m_timer->stop(); m_inAnimation = false; if (m_justLeft) { if (!m_isMinimised) { m_isMinimised = true; } if (m_dock->m_tooltip.isShown()) m_dock->m_tooltip.hide(); m_justLeft = false; m_dock->repaint(); m_dock->setDockBelow(); } }}/** * Stop launcher acknowledgement */void ParabolicZoomState::stopLauncherAcknowledgement() { m_clickedLauncherIndex = -1; m_dock->repaint();}/// PRIVATE ////** * Update the background image */void ParabolicZoomState::updateBackgroundImage() { int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); // copy from the wallpaper switch(m_dock->m_position) { case LEFT: bitBlt(m_originalBackground.get(), 0, 0, &m_dock->m_wallpaperManager->getWallpaper(KWin::currentDesktop()), 0, 0, m_w, dh); bitBlt(m_background.get(), 0, 0, &m_dock->m_wallpaperManager->getWallpaper(KWin::currentDesktop()), 0, 0, m_minW, dh); break; case RIGHT: bitBlt(m_originalBackground.get(), 0, 0, &m_dock->m_wallpaperManager->getWallpaper(KWin::currentDesktop()), dw - m_w, 0, m_w, dh); bitBlt(m_background.get(), 0, 0, &m_dock->m_wallpaperManager->getWallpaper(KWin::currentDesktop()), dw - m_minW, 0, m_minW, dh); break; case TOP: bitBlt(m_originalBackground.get(), 0, 0, &m_dock->m_wallpaperManager->getWallpaper(KWin::currentDesktop()), 0, 0, dw, m_h); bitBlt(m_background.get(), 0, 0, &m_dock->m_wallpaperManager->getWallpaper(KWin::currentDesktop()), 0, 0, dw, m_minH); break; case BOTTOM: bitBlt(m_originalBackground.get(), 0, 0, &m_dock->m_wallpaperManager->getWallpaper(KWin::currentDesktop()), 0, dh - m_h, dw, m_h); bitBlt(m_background.get(), 0, 0, &m_dock->m_wallpaperManager->getWallpaper(KWin::currentDesktop()), 0, dh - m_minH, dw, m_minH); break; default: break; } // fade the background if (m_dock->m_dockOpacity > 0) { KPixmapEffect::fade(*m_background, ((float)m_dock->m_dockOpacity)*0.01, m_dock->m_backgroundColor); } // draw borders if (m_dock->m_showBorders) { QPainter p(m_background.get()); QPainter p1(m_sideBorder.get()); p.setPen(m_dock->m_borderColor); p1.fillRect(m_sideBorder->rect(), m_dock->m_borderColor); switch(m_dock->m_position) { case LEFT: p.drawLine(m_minW - 1, 0, m_minW - 1, dh - 1); break; case RIGHT: p.drawLine(0, 0, 0, dh - 1); break; case TOP: p.drawLine(0, m_minH - 1, dw - 1, m_minH - 1); break; case BOTTOM: p.drawLine(0, 0, dw - 1, 0); break; default: break; } } // update the snapshot if (!m_isMinimised) { updateSnapshotFromWallpaper(); m_dock->setDockBelow(); pauseExecution(); updateSnapshotFromDesktop(); m_dock->setDockAbove(); }}/** * Update after showing/un-showing the desktop */void ParabolicZoomState::updateAfterShowingDesktop() { bool desktopShowing = ShowDesktop::the()->desktopShowing(); if (desktopShowing) { updateSnapshotFromWallpaper(); } else { m_dock->setDockBelow(); pauseExecution(); // update the snapshot from the desktop updateSnapshotFromDesktop(); m_dock->setDockAbove(); } m_dock->repaint();}/** * Update the snapshot, copying from wallpaper image */void ParabolicZoomState::updateSnapshotFromWallpaper() { int dw = QApplication::desktop()->width(); int dh = QApplication::desktop()->height(); switch(m_dock->m_position) { case TOP: bitBlt(&m_snapshot, 0, 0, &m_dock->m_wallpaperManager->getWallpaper(KWin::currentDesktop()), 0, m_minH, dw, m_h - m_minH); break; case BOTTOM: bitBlt(&m_snapshot, 0, 0, &m_dock->m_wallpaperManager->getWallpaper(KWin::currentDesktop()), 0, dh - m_h, dw, m_h - m_minH); break; case LEFT: bitBlt(&m_snapshot, 0, 0, &m_dock->m_wallpaperManager->getWallpaper(KWin::currentDesktop()), m_minW, 0, m_w - m_minW, dh); break; case RIGHT: bitBlt(&m_snapshot, 0, 0, &m_dock->m_wallpaperManager->getWallpaper(KWin::currentDesktop()), dw - m_w, 0, m_w - m_minW, dh); break; default: break; } if (m_dock->m_isAutohide) { fadeSnapshot(); } }/** * Update the snapshot, copying from desktop */void ParabolicZoomState::updateSnapshotFromDesktop() { int x = (QApplication::desktop()->width() - m_w) / 2; int y = (QApplication::desktop()->height() - m_h) / 2; QRect rect = m_dock->frameGeometry(); for (QValueList<WId>::ConstIterator it = m_dock->m_windowManager.stackingOrder().begin(); it != m_dock->m_windowManager.stackingOrder().end(); it++) { if (m_dock->m_windowManager.hasWId(*it)) { KWin::WindowInfo info(*it, 0, 0); if (info.onAllDesktops() || info.desktop() == KWin::currentDesktop()) { QRect windowFrameGeometry = info.frameGeometry(); NET::WindowType type = info.windowType(0xffff); NET::MappingState mapping_state = info.mappingState(); if ((mapping_state == NET::Visible) && (type == NET::Normal || type == NET::Dialog || type == NET::Unknown || type == NET::Override) && rect.intersects(windowFrameGeometry)) { QRect intersection = rect & windowFrameGeometry; QPixmap intersection_pix = QPixmap::grabWindow(qt_xrootwin(), intersection.x(), intersection.y(), intersection.width(), intersection.height()); QPoint pos = m_dock->mapFromGlobal(intersection.topLeft()); switch(m_dock->m_position) { case TOP: bitBlt(&m_snapshot, pos.x() + x, pos.y() - m_minH, &intersection_pix, 0, 0, intersection.width(), intersection.height()); break; case BOTTOM: bitBlt(&m_snapshot, pos.x() + x, pos.y(), &intersection_pix, 0, 0, intersection.width(), intersection.height()); break; case LEFT: bitBlt(&m_snapshot, pos.x() - m_minW, pos.y() + y, &intersection_pix, 0, 0, intersection.width(), intersection.height()); break; case RIGHT: bitBlt(&m_snapshot, pos.x(), pos.y() + y, &intersection_pix, 0, 0, intersection.width(), intersection.height()); break; default: break; } } } } } if (m_dock->m_isAutohide && !m_isMinimised) { fadeSnapshot(); }}/** * Find the index of the item with mouse focus given the mouse's x and y position */int ParabolicZoomState::findItemIndex(int x, int y) { unsigned int i = 0; unsigned int no_items = m_dock->m_items.size(); if (m_isMinimised) { if (m_dock->m_orientation == Qt::Horizontal) { int dx = (m_w - m_minW)/2; if ((x < dx) || (x > m_w - dx)) return -1; if ((m_dock->m_position == TOP && y > m_minH) || (m_dock->m_position == BOTTOM && y < m_h - m_minH)) return -1; } else { // Vertical int dy = (m_h - m_minH)/2; if ((y < dy) || (y > m_h - dy)) return -1; if ((m_dock->m_position == LEFT && x > m_minW) || (m_dock->m_position == RIGHT && x < m_w - m_minW)) return -1; } } if (m_dock->m_orientation == Qt::Horizontal) { int w = 0; while (i < no_items && x > w) { w = m_itemsCenter[i] - m_dock->m_items[i]->getWidth(m_itemsSize[i]) / 2; i++; } if (i == no_items && x > w) i = no_items - 1; else i -= 2; } else { // Vertical int h = 0;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -