Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ export default class SaneBreakGNOME extends Extension {

_applyWindowWorkaround(window) {
// GNOME does not expose layer-shell here, so the shell extension forcefully
// stretches the transparent Wayland workaround window to cover the monitor.
// stretches the transparent Wayland workaround window to cover the full
// virtual desktop.
const [w, h] = global.display.get_size();
window.stick();
window.move_resize_frame(false, 0, 0, w, h);
Expand Down
27 changes: 18 additions & 9 deletions src/app/break-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void BreakWindow::showFullScreen() {
QPropertyAnimation* resizeAnim =
new QPropertyAnimation(m_waylandWorkaround ? mainWidget : this, "geometry");
resizeAnim->setStartValue(m_waylandWorkaround ? mainWidget->geometry() : geometry());
resizeAnim->setEndValue(m_waylandWorkaround ? screen()->availableGeometry()
resizeAnim->setEndValue(m_waylandWorkaround ? m_intendedScreenGeometry
: screen()->geometry());
resizeAnim->setDuration(300);
resizeAnim->start();
Expand Down Expand Up @@ -263,26 +263,35 @@ void BreakWindow::showFlashPrompt() {

QPropertyAnimation* resizeAnim =
new QPropertyAnimation(m_waylandWorkaround ? mainWidget : this, "geometry");
QRect rect =
m_waylandWorkaround ? screen()->availableGeometry() : screen()->geometry();
QRect targetGeometry = QRect(rect.x() + rect.width() / 2 - SMALL_WINDOW_WIDTH / 2,
rect.y(), SMALL_WINDOW_WIDTH, SMALL_WINDOW_HEIGHT);
QRect rect = screen()->geometry();
QRect targetGeometry = m_waylandWorkaround
? QRect(m_intendedScreenGeometry.x() +
m_intendedScreenGeometry.width() / 2 -
SMALL_WINDOW_WIDTH / 2,
m_intendedScreenGeometry.y(),
SMALL_WINDOW_WIDTH, SMALL_WINDOW_HEIGHT)
: QRect(rect.x() + rect.width() / 2 - SMALL_WINDOW_WIDTH / 2,
rect.y(), SMALL_WINDOW_WIDTH, SMALL_WINDOW_HEIGHT);
resizeAnim->setStartValue(m_waylandWorkaround ? mainWidget->geometry() : geometry());
resizeAnim->setEndValue(targetGeometry);
resizeAnim->setDuration(100);
resizeAnim->start();
}

void BreakWindow::initSize(QScreen* screen) {
m_intendedScreenGeometry = screen->geometry();
if (m_waylandWorkaround) {
QRect rect = screen->availableGeometry();
QRect rect = m_intendedScreenGeometry;
// Avoid using full height when initializing the main window. GNOME will refuse to
// make the window always on top (done in custom shell extension) if it is too large
// See https://askubuntu.com/questions/1122921.
rect.setHeight(100);
setGeometry(rect);
mainWidget->setGeometry(rect.x() + rect.width() / 2 - SMALL_WINDOW_WIDTH / 2,
rect.y(), SMALL_WINDOW_WIDTH, SMALL_WINDOW_HEIGHT);
mainWidget->setGeometry(m_intendedScreenGeometry.x() +
m_intendedScreenGeometry.width() / 2 -
SMALL_WINDOW_WIDTH / 2,
m_intendedScreenGeometry.y(),
SMALL_WINDOW_WIDTH, SMALL_WINDOW_HEIGHT);
} else {
QRect rect = screen->geometry();
setGeometry(rect.x() + rect.width() / 2 - SMALL_WINDOW_WIDTH / 2, rect.y(),
Expand All @@ -298,7 +307,7 @@ void BreakWindow::initSize(QScreen* screen) {
QString path = url.isLocalFile() ? url.toLocalFile() : m_data.theme.backgroundImage;
QPixmap original(path);
if (!original.isNull()) {
QSize targetSize = m_waylandWorkaround ? screen->availableGeometry().size()
QSize targetSize = m_waylandWorkaround ? m_intendedScreenGeometry.size()
: screen->geometry().size();
QPixmap scaled = original.scaled(targetSize, Qt::KeepAspectRatioByExpanding,
Qt::SmoothTransformation);
Expand Down
1 change: 1 addition & 0 deletions src/app/break-window.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class BreakWindow : public QMainWindow {
QGraphicsOpacityEffect* m_bgImageOpacity = nullptr;
bool m_waylandWorkaround = false;
bool m_supportTransparentInput = true;
QRect m_intendedScreenGeometry;
int m_totalSeconds;

static void colorizeButton(QPushButton* button, QColor color);
Expand Down