Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try let the window manager move the window, fixes #429 #445

Merged
merged 2 commits into from
Feb 8, 2023

Conversation

nuttyartist
Copy link
Owner

This should fix #429. Can you please review if the code is satisfactorily written?

@nuttyartist
Copy link
Owner Author

Whoops, I see I'm uploading here CMakeLists.txt.user. Is it not in gitignore?

@guihkx
Copy link
Collaborator

guihkx commented Jan 15, 2023

Whoops, I see I'm uploading here CMakeLists.txt.user. Is it not in gitignore?

It seems that file is generated by QtCreator (which I personally don't use), but it should be fine to add it to .gitignore.

CMakeLists.txt.user Outdated Show resolved Hide resolved
src/mainwindow.cpp Outdated Show resolved Hide resolved
src/mainwindow.cpp Outdated Show resolved Hide resolved
Copy link
Collaborator

@bjorn bjorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that you'll want to do the same change to the UpdaterWindow.

int dy = event->globalY() - m_mousePressY;
move(dx, dy);

if (!window()->windowHandle()->startSystemMove()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea whether it is fine to continuously call this function on all platforms. Or does mouseMoveEvent stop being called when this function succeeded? The documentation doesn't say anything about it, so I guess we could just test.

Alternatively, this function could be called in MainWindow::mousePressEvent instead, where we maybe could do m_canMoveWindow = !window()->windowHandle()->startSystemMove() instead of just assigning true (untested)

@nuttyartist
Copy link
Owner Author

My C++ and Qt skills are quite rusty. If someone wants to take that PR, I'd be glad 😅

Also, why is after adding CMakeLists.txt.user to gitignore the file is still added?

Note that you'll want to do the same change to the UpdaterWindow.

Good catch. I tried but with no success. I got member access into incomplete type QWindow

@bjorn
Copy link
Collaborator

bjorn commented Jan 19, 2023

My C++ and Qt skills are quite rusty. If someone wants to take that PR, I'd be glad 😅

You're maintaining this thing, I think I'll let you the opportunity to get a little bit less rusty. ;-)

Also, why is after adding CMakeLists.txt.user to gitignore the file is still added?

Because you added it to .gitignore after it was already added to git. Changing .gitignore is not going to rewrite history for you. :-) To remove that file from git without removing the file from your workspace, you can use git rm --cached CMakeLists.txt.user and commit that.

member access into incomplete type QWindow

It means you need to add #include <QWindow> to the affected .cpp file.

@nuttyartist
Copy link
Owner Author

You're maintaining this thing, I think I'll let you the opportunity to get a little bit less rusty. ;-)

Haha fair. Thanks for the tip. Seems to work now. Let me know if it's fine.

@zjeffer Thanks 😉

zjeffer
zjeffer previously approved these changes Jan 21, 2023
@zjeffer
Copy link
Collaborator

zjeffer commented Jan 21, 2023

I fixed the qt5.9 build, rebased and squashed the commits.

@mominul can you test this on wayland by downloading the latest build from here: https://github.com/nuttyartist/notes/actions/runs/3976090004. At the bottom, you can download the AppImages for both Qt5 and Qt6.

@guihkx
Copy link
Collaborator

guihkx commented Jan 21, 2023

The AppImages currently don't include the Wayland platform plugin, so it will just fallback to XWayland.

However, I think it's just a matter of installing the qtwayland5 / qtwayland6 packages and the linuxdeploy tool will pick up those plugins automatically.

If that doesn't work, we'll have to find a way to include the Wayland plugin manually.

I would add those changes myself, but I'm not home at the moment...

@zjeffer Feel free to experiment, if you want. If that doesn't work, I can pick it up from where you left later.

@nuttyartist
Copy link
Owner Author

Feel free to merge this when it's ready.

@guihkx
Copy link
Collaborator

guihkx commented Jan 22, 2023

Okay, I think we aren't quite there yet regarding Wayland support in AppImages. And even people much smarter than me seem to agree:

linuxdeploy/linuxdeploy-plugin-qt#25

First, because it's a struggle to bundle all the required Wayland libraries. Even though I succeeded (to the best of my knowledge, anyway).

But I either experienced random, weird behavior, like this one:

wayland.mp4

... Or just straight up the crashing of the whole desktop (wtf, GNOME?):

Jan 22 16:23:28 arch-des gnome-shell[798]: Buggy client caused popup to be placed outside of parent window
Jan 22 16:23:29 arch-des gnome-shell[798]: **
Jan 22 16:23:29 arch-des gnome-shell[798]: libmutter:ERROR:../mutter/src/wayland/meta-wayland-popup.c:233:meta_wayland_popup_grab_get_top_popup: assertion failed: (!wl_list_empty (&grab->al>
Jan 22 16:23:29 arch-des gnome-shell[798]: Bail out! libmutter:ERROR:../mutter/src/wayland/meta-wayland-popup.c:233:meta_wayland_popup_grab_get_top_popup: assertion failed: (!wl_list_empty >
Jan 22 16:26:46 arch-des systemd-coredump[2336]: [🡕] Process 798 (gnome-shell) of user 1001 dumped core.

Even if those are rare and I was just unlucky, I don't think it's something we want to ship to users, considering that the Xbc backend still works and offers a better experience overall.

@guihkx
Copy link
Collaborator

guihkx commented Jan 22, 2023

Regarding the changes itself, I'm experiencing some very weird behavior while testing the Qt 5 build on Linux (not running on Wayland)...

After moving the window for a bit (and then releasing it), the mouse cursor will flicker like crazy sometimes:

weird-behavior-after-moving-window.mp4

Not only that, clicking on the text editor makes the window manager think we are grabbing the window again, lol.

@zjeffer zjeffer dismissed their stale review January 22, 2023 20:05

Further testing revealed bugs

@zjeffer
Copy link
Collaborator

zjeffer commented Jan 22, 2023

I realized I'm also getting some strange bugs:

notes-2023-01-22_21.06.51.mp4

Here's me with this PR's branch on bspwm, which uses X11. Resizing with bspwm's keyboard shortcuts works fine: I press super+left click on the window to move, super+right click near a corner to resize.

  1. Moving the window using the window bar works fine. I don't get the bug you're having.
  2. Resizing the window by dragging the top border continuously moves the window diagonally to the left until I release the mouse button. Only the top border seems to be interactive.
    • Resizing windows by dragging the border shouldn't even be possible in most tiling window managers. I've been using bspwm for around 5 years, and I've never come across an app that can be resized by dragging one of the window's borders. I always resize using keyboard shortcuts.
  3. With native window frame disabled, double clicking the bar will create new borders around the whole window (see 0:40 in the video). This makes all borders have resizing handles, including the corners for diagonal resizing. Dragging these handles results in the same bug as point 2.
  4. Resizing this way widens the notes list pane to be about half the window width.

EDIT: Oops, looks like this behaviour has been present for a while. The aur's latest version and the dev version both have these bugs on bspwm. I'll create a separate issue. I never use this app in floating mode so I've never noticed this behaviour before.

@guihkx
Copy link
Collaborator

guihkx commented Jan 22, 2023

LOL, that's hilariously broken. We'll need to investigate some more...

@nuttyartist
Copy link
Owner Author

So is it not preferable to let the window manager handle the move operation if supported?

@guihkx
Copy link
Collaborator

guihkx commented Jan 25, 2023

So is it not preferable to let the window manager handle the move operation if supported?

It definitely is, IMO. It's just that it's probably broken thanks to our own window management code, so we should fix it first.

@nuttyartist
Copy link
Owner Author

So what's left here to fix? If this solution is still better than our previous one, I think we can merge this and open a new issue.

@nuttyartist
Copy link
Owner Author

This is the only issue that currently remains for completing version 2.1.0.

This provides more direct feedback (mouse changes to move cursor on
press already on GNOME), avoids repeated calls in case the system move
is not supported and simplifies the code a little.
@bjorn
Copy link
Collaborator

bjorn commented Feb 6, 2023

So what's left here to fix? If this solution is still better than our previous one, I think we can merge this and open a new issue.

I've pushed a change that addresses my comment.

This is the only issue that currently remains for completing version 2.1.0.

While ideally we'd also improve / fix the resize behavior in 2.1, I think this PR is ready to be merged.

@guihkx
Copy link
Collaborator

guihkx commented Feb 7, 2023

Right now this change only affects non-Windows builds, but I think we should also add this functionality on Windows, which appears to be done here instead:

notes/src/mainwindow.cpp

Lines 2806 to 2814 in 1471e87

void MainWindow::mouseMoveEvent(QMouseEvent *event)
{
if (m_canMoveWindow) {
// this->setCursor(Qt::ClosedHandCursor);
int dx = event->globalPos().x() - m_mousePressX;
int dy = event->globalY() - m_mousePressY;
move(dx, dy);
}
}

@guihkx
Copy link
Collaborator

guihkx commented Feb 7, 2023

Ah, the Windows code was added elsewhere, my bad.

LGTM!

@bjorn
Copy link
Collaborator

bjorn commented Feb 7, 2023

Right now this change only affects non-Windows builds, but I think we should also add this functionality on Windows, which appears to be done here instead:

Yeah, in general I think we could do better in unifying certain code paths, but for now i just adjusted both versions of the mousePressEvent.

@nuttyartist
Copy link
Owner Author

Tested and works. Merging... Thanks everybody!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Window is not moveable in Gnome 43.2 + Wayland
4 participants