Code Monkey home page Code Monkey logo

kde-snap-assist's Introduction

KDE Snap Assist

KDE Store

This KWin script for KDE Plasma suggests other window thumbnails on snap. It tries to replicate the famous Windows 10/11 feature of the same name.

Assist can be shown by dragging a window to the screen edge, as well as via default keyboard shortcuts (super+arrows). You can select the window with mouse, as well as with arrow keys + Enter. To dismiss the assist, hit Escape key, press the close button or click anywhere on the empty area. Script also supports quarter and triple tiling: you can switch layouts with the Tab key or using the button in corner.

Ideas, suggestions, bugs reports and contributions to the project are welcome!

screenshot_snapassist


Snap Groups

Since version 1.4, there are also experimental snap group features:

  • Minimize/restore snapped windows together (demo)
  • Raise snapped windows together (demo)
  • On close snapped window, try to fill the area (demo)
  • Try to fit snapped window in group behind (demo)

When you enable any of these options in the script settings, it will start tracking windows snapped via the script. Group of snapped windows is remembered once you fill the layout using the assist. Window is no longer considered snapped once it was closed or moved manually using the mouse (sometimes you need to do it twice to break it from the group). Snap groups are not persistent, and should be recreated after each reboot.


Manual Installation

In order to install this script manually from GitHub, you'd need to:

  • Delete current version of script and re-login to KDE Plasma
  • Download the code as .zip (green "Code" button > "Download as ZIP"), and rename file to .kwinscript extension
  • Use the "Install from file" button in System settings > Windows manager > KWin scripts
  • Re-login to Plasma again (or restart KWin) to make sure the script is installed

You can also help testing the experimental 2.0-dev version, if you're into this kind of stuff!


Troubleshooting

  • To apply the new settings, you may need to re-enable the script or restart KWin. The same is recommended if you switch from one version of the script to another
  • Assist will not show if you have no other windows matching the conditions set in the script settings. For example, by default the script does not show windows from other screens — so, if you have only one window on the current screen, assist will not show
  • Script settings button is not visible, or complains that "Plugin doesn't provide configuration file in the expected location" — this is a known KWin's bug, not related to the script. Make sure your system is up-to-date, as it seems to be fixed now. If it doesn't help, you can also try to install the script manually
  • KWin crashes after sleep — it was reported here that you may need to install pygdbmi library to fix the crash after sleep

Compatibility notes

Compatibility with Window Gap

  • Since version 1.2, there's an option "Snap detect tolerance" in the script settings, which basically defines how much window's size and position can differ to still be detected as "snapped" by the script. If you use some external scripts which constantly modify windows size and position, you may want to set it to 15px or 25px, so that Snap Assist could detect your snaps.

Compatibility with Exquisite

  • Most of default layouts are supported out the box. You may also like to enable "Hide after tiling a window" in Exquisite's settings for the smoothest workflow. Over time, support for custom layouts will expand, possibly with ability to edit them.

Compatibility with Sticky Window Snapping

  • Fully compatible. Highly recommended to be used in conjunction with Snap Assist!

Compatibility with diagonal keyboard shortcuts

  • Version 1.4 introduces an option "Delay before showing the assist", which gives some time to execute 'diagonal' shortcuts (super + + ) before Assist gets shown. The default value is 100ms.

Donate

If you really like this script, you can always thank for it by buying me a coffee :)

kde-snap-assist's People

Contributors

emvaized avatar mdl48 avatar nclarius avatar vistaus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

kde-snap-assist's Issues

Can't get snap-assist to work at all

I have logged out and in again, then installed the latest version of kde-snap-assist manually, then restarted kwin (DISPLAY=:0 kwin --replace). Snap-assist doesn't show up at all. I can change its settings, but that doesn't have an effect either.

Operating System: Fedora Linux 38
KDE Plasma Version: 5.27.6
KDE Frameworks Version: 5.108.0
Qt Version: 5.15.8
Kernel Version: 6.2.14-200.fc37.x86_64 (64-bit)
Graphics Platform: X11
Memory: 15,3 GiB of RAM

KWin crashes when a JetBrains editor displays a tooltip

This happens both in WebStorm and CLion. I suppose it would happen in any IDE from JetBrains.

KWin crashes anytime an autocompletion tooltip is shown automatically during typing. This happens consistently and only when KDE Snap Assist is enabled. Both under X11 and Wayland.

This is the stack trace from GDB on X11: kwin_x11.gdb.zip. Unfortunately, my system seems to be missing some debug symbols.

Let me know if I can help with resolving this. I have never written a KWin script but I know JavaScript so if you point me into the right direction, I can add null checks, logs, etc. to the code to help diagnose where this is happening.

Unwanted assist reveal on Plasma Wayland

Hi
i would like to report an issue regarding snap assists
before that here is my spec:

Operating System: Manjaro Linux
KDE Plasma Version: 5.24.6
KDE Frameworks Version: 5.96.0
Qt Version: 5.15.5
Kernel Version: 5.17.15-1-MANJARO (64-bit)
Graphics Platform: Wayland

when i snap a window from using the script, the script still think the other window need snap assists

here is the video:
https://youtu.be/_Z29SH4p4Ag

I hope you are willing to look into this issue
Thank you

[Bug] Keyboard inputs get swallowed

With the Snap Assist Kwin script active, keyboard inputs don't make it to search fields or receivers. The only exception that I could find was the Meta key.

System information:

Operating System: Fedora Linux 38
KDE Plasma Version: 5.27.6
KDE Frameworks Version: 5.108.0
Qt Version: 5.15.10
Kernel Version: 6.4.11-200.fc38.x86_64 (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 3600X 6-Core Processor
Memory: 31.3 GiB of RAM
Graphics Processor: AMD Radeon RX 6600 XT
Manufacturer: Micro-Star International Co., Ltd.
Product Name: MS-7B85
System Version: 1.0

unable to type in applications with snap-assist enabled

Hi, first very cool program. I am getting an odd error. when I first login if I open a single app (eg kate) I cannot type into it. If I start a second program (eg dolphin) and activate snap-assist with meta-uparrow being able to type into applications is restored. Note I have to have more than one program running otherswise meta-uparrow does not activate snap-assist.
Disabling snap-assist also restores functionality.

Happy to provide what ever logs might be helpful
OS Arch
plasma 5.25.4
display server = wayland

Multiple monitors support

I use two monitors, and I'm able to see the snap assist borders for the outside halves of the screens, but not the inside (i.e. I can make a vertical half window on the right side of the right screen, and left side of the left screen, but there's no snap assist for the inner halves).

Plasma notifications crash kwin_x11 when Snap Assist is enabled

I can realiably trigger this by invoking notify-send --expire-time=10 --app-name="$RANDOM" "$RANDOM" -p.
The important part is the expire-time on notifications. Non-timed notifications do not trigger the crash at all it seems like.
Setting --expire-time to something between 1 and 10 crashes kwin almost all the time. Setting it higher makes the crashes appear to be more random.

Disabling KDE Snap Assist fixes the issue.

To reproduce:

  1. enable KDE Snap Assist
  2. trigger timed notification with notify-send --expire-time=10 --app-name="$RANDOM" "$RANDOM" -p

Crashlog taken with journalctl --user -u plasma-kwin_x11.service -u plasma-plasmashell.service -f

crashtest-2022-10-03_15.53.07.mp4

Bug: Titlebar is visible sometimes

I'm on Wayland (on ArchBTW), and the titlebar is visible sometimes:

Screenshot

It seems to only occur when it is selecting some position at the bottom (bottom left or right, or horizontal snapping in the bottom as seen in the screenshot).

That window can be moved around, and if closed the snapping script stops working.

Note: Did not test on X11

kde-snap-assist interrupts KDE's normal snap shortcuts

When snapping windows without kde-snap-assist, windows can be corner tiled by pressing meta + right arrow followed by meta + up arrow or vice versa (meta + up arrow followed by meta + right arrow). When kde-snap-assist is active, it interrupts the first tile operation and prevents the second one that would move a window to a corner. The user has to first hit esc to close kde-snap-assist to tile it normally.

I think kde-snap-assist could:

  • ignore arrow key presses that include meta and allow the normal KDE tiling. If only arrow keys are pressed, kde-snap-assist can move through currently open windows as usual
  • add a delay before it shows itself to allow for time to snap a window into the desired position

KDE Snap Assist suggests windows from other activities

First, thanks for this wonderful script =)

When one is using more than one activity, KDE Snap Assist suggests windows present in other activities.

In addition, if one chose a window from another activity, its icon is not migrated to the current activity.

Just to be clear, I expected windows from another activity to not be available at all, I just wanted to share the behavior if one is selected.

Setting Menu is Too Big For Small Resolution

Hi
I would like to report issue regarding setting menu for snap assists, the setting menu is too big for my laptop screen (1366x768)

This is the screenshot for the setting menu

image

I hope you can make it so it can adapt for small screen resolution
Thanks :D

Feature request: Option to suggest only on vertical and horizontal "snap"

Hello. Fist of all, great work!
I think that would be nice to have an option to suggest other windows only on vertical and horizontal "snap".
On Windows, when you try the "quarter layout" (snap window to upper left, upper right, bottom left or bottom right) it not suggest you other windows.

Issue with using keyboard to enter quarter tiling

First of all, thanks for this amazing script!

There is just this small issue with the (relatively new) KWin shortcut to enter quarter tiling. When you want to place the active window to, let's say, the top left quarter, you would normally press Meta and then hit Top and Left arrows in rapid succession. However, the Snap Assist is triggered right after pressing Meta+Top and the following Left arrow is not registered.

I don't know what kind of solution is feasible but maybe adding a small delay before triggering the Snap Assist would be enough?

Bug: Snapping does not resize the window

On Wayland, ArchBTW.

When snapping, the window does not resize horizontally: it retains whatever size it had before. Is that intentional?

Note: Did not test on X11

Issues when unsnaping the windows snapped by the script

Sometimes when you unsnap the window, which previously was snapped by the script, it can become shaded or completely invisible during dragging. I'm not sure what could be causing it, as the script only modifies client's geometry when snapping a window

Adding options for Ultrawide screens

I was reading the Reddit Thread where one user spoke about using Ultrawide Kwin Script.

While having both working side by side is possible, it would be nice to have the possibility of displaying more combinations.
At least the 1/3 | 1/3 | 1/3 would be helpful.

Ideally, having all in one place would make it better in regard to dealing with shortcuts, but I can understand if that was out of scope.

[Feature Request] Autoresize without asking the user

An option to automatically resize windows without prompting the user could be useful, for example, if I have two 1/2 windows, I just want that, 1/2, I don't have any more windows open so I don't need KDE Snap Assistand asked me how I want to arrange my windows

Maximized windows that are tiled don't get set to windowed

I use the kwin option "BorderlessMaximizedWindows" with the window buttons plasmoid.
When a maximized window gets tiled the maximized state is not set to windowed for those windows, due to that the window doesn't get the border back.
I tried adding client.visibility = Window.Windowed; in the function selectClient but it didn't work, I am not sure if in that function the window gets tiled.
The attachment is a video showcasing the problem.
https://user-images.githubusercontent.com/111306180/184692971-255d2cf5-49a3-49c4-9177-3f5c191ec0d5.mp4

UI: remove the little sidebar

The sidebar on the right with the close and quarter button takes too much space from the window previews. The little buttons themselves are neither intuitive nor convenient. (close button seems like "close window", tile button makes the whole UI hop around the screen etc.)

I therefore recommend to follow the canonical Windows UI and remove this thing. The close button isn't necessary since Esc is universally recognized. The quarter tile could be exported to a context menu, or - better - by simply draggin the thumbnail to the desired region.

Thank you for finally bringing this indispensable feature to KDE!

It actually doesn't work on kde plasma 5.20.5

So, it doesn't work, when I move a window in left or right, and then the window will be automaticly resized, after that nothing happens. It looks like I didn't install the kde-snap-assist, but I installed it and enable in settings and relogin after that.

KWin crashes after sleep with snap-assist enabled

Hi,
> Failed to do pygdbmi parsing: No module named 'pygdbmi'> frame={level="0",func="onWindowResize",file="/home/aronkvh/.local/share/kwin/scripts/kdesnapassist/contents/ui/code/windows.js",fullname="/home/aronkvh/.local/share/kwin/scripts/kdesnapassist/c".
Kwin broke or restarted every time after installing the script and waking from sleep. It was fixed by installing pygdbmi.
Bug against KWin.
System info:

Operating System: KDE neon 5.25
KDE Plasma Version: 5.25.4
KDE Frameworks Version: 5.97.0
Qt Version: 5.15.5
Kernel Version: 5.15.0-46-generic (64-bit)
Graphics Platform: X11
Processors: 8 × Intel® Core™ i7-3770 CPU @ 3.40GHz
Memory: 31,3 GiB of RAM
Graphics Processor: NVIDIA GeForce RTX 3060/PCIe/SSE2

Snap Group Cause Kwin To Crash (X11)

Hi

i would like to report issue regarding snap group causing Kwin X11 to crash

Step To Reproduce:

  1. Activate snap group (any of the three options)
  2. Restart Kwin_x11
  3. doing snap window (no matter the layout) on any window
  4. Minimize the window few times
  5. Move one of the snapped window to other virtual desktop
  6. Move to other virtual desktop few times
  7. Activate Overview Effect a few times (Default Hotkey in Manjaro, Meta + W)
  8. Kwin X11 will crash immediately

Kwin X11 will also crash event without doing step 5 and 6, i guess the overview effect doesn't cooperate well with snap group

Here is The Video for More Information: https://youtu.be/omfewsz5-mo

Some Log i got from terminal when Kwin_X11 crash

kwin_core: XCB error: 10 (BadAccess), sequence: 2575, resource id: 999, major code: 142 (Composite), minor code: 2 (RedirectSubwindows)
QQmlEngine::setContextForObject(): Object already has a QQmlContext
QQmlEngine::setContextForObject(): Object already has a QQmlContext
file:///usr/share/kwin/effects/overview/qml/ScreenView.qml:183: ReferenceError: animationDuration is not defined
file:///usr/share/kwin/effects/overview/qml/ScreenView.qml:183: ReferenceError: animationDuration is not defined
file:///usr/share/kwin/effects/overview/qml/ScreenView.qml:183: ReferenceError: animationDuration is not defined
file:///usr/share/kwin/effects/overview/qml/ScreenView.qml:0: ReferenceError: animationDuration is not defined
file:///usr/share/kwin/effects/overview/qml/ScreenView.qml:0: ReferenceError: animationDuration is not defined
file:///usr/share/kwin/effects/overview/qml/ScreenView.qml:0: ReferenceError: animationDuration is not defined
file:///usr/share/kwin/effects/overview/qml/ScreenView.qml:0: ReferenceError: animationDuration is not defined
file:///usr/share/kwin/effects/overview/qml/ScreenView.qml:0: ReferenceError: animationDuration is not defined
file:///usr/share/kwin/effects/overview/qml/ScreenView.qml:0: ReferenceError: animationDuration is not defined
file:///usr/share/kwin/effects/overview/qml/ScreenView.qml:0: ReferenceError: animationDuration is not defined
file:///usr/share/kwin/effects/overview/qml/ScreenView.qml:0: ReferenceError: animationDuration is not defined
file:///usr/share/kwin/effects/overview/qml/ScreenView.qml:0: ReferenceError: animationDuration is not defined
file:///usr/share/kwin/effects/overview/qml/ScreenView.qml:0: ReferenceError: animationDuration is not defined
qt.qpa.xcb: Unhandled client message: "_NET_CURRENT_DESKTOP"
kwin_core: XCB error: 152 (BadDamage), sequence: 24424, resource id: 39848693, major code: 143 (DAMAGE), minor code: 2 (Destroy)
kwin_core: XCB error: 3 (BadWindow), sequence: 24425, resource id: 62914742, major code: 129 (SHAPE), minor code: 6 (Input)
qt.qpa.xcb: QXcbConnection: XCB error: 3 (BadWindow), sequence: 24426, resource id: 62914742, major code: 2 (ChangeWindowAttributes), minor code: 0
qt.qpa.xcb: Unhandled client message: "_NET_CURRENT_DESKTOP"

I hope you don't mind to look into this issue
Thank you for your hard work :D

Keyboard shortcut won't work after first use

When using shortcuts you might want to move the window multiple times with keyboard shortcuts. But after the first shortcut the window is not focused anymore and you can't move the window anymore.

Cannot set colors in settings

I don't know if this is an issue with the script, or with KDE, but I cannot set the colors in the system settings for the script:
image

Integrate sticky resize into the extension.

The sticky windows extension hasn't been updated in over a year, so it doesn't make much sense to rely on a dead third party project to deliver the full functionality of the Windows snap assist feature. I would suggest just integrating it into the project and maybe improving it a little (the sticky window extension was pretty flaky last time I tried it: the behavior was very unreliable and the transparent windows UI was a bizarre choice)

Bug: Causing all keyboard inputs to be swallowed, causing the whole desktop unusable

Platform: wayland / x11
KDE: 5.27.10
KDE frameworks: 5.112.0
QT: 5.15.11
Linux: 6.6.4-zen1-1-zen
Distro: Arch
Problem: https://bbs.archlinux.org/viewtopic.php?pid=2136003#p2136003
Recently I found my keyboard stops working in KDE and gnome except for a few keys like meta. After debugging for days I have managed to identify the problem to be located at ~/.local/share/kwin/scripts/kdesnapassist/, and the problem ceased after removing the directory.

Snap Assist only works on one monitor

I can only seem to get snap assist to work on one monitor. I have a screen recording as attatched. If i have 2 windows on my side monitor, and use the shortcut to drag one into place, the window select dialog shows up. However, when I replicate this with the same windows on my main monitor, it dosen't work. I also attatched system specs in case it's of any help.

2024-02-07.18-24-30.mp4

image

Increase default opacity

The transparency setting is set too high in my opinion and this makes the white text labels hard to read (also makes the whole interface less legible). I suggest something like 200 alpha for the default instead of 50. Obviously users can set it how they like but higher opacity would be better for most IMO.

Ability to easily edit layouts

It would be good to refactor the script in order to use 12x12 grid, so that users could easily manage all supported layouts, add new or remove the current ones.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.