khanhas / ShapeCorners

KDE effect rounds/chisels corners of your windows.
GNU General Public License v3.0
80 stars 10 forks source link

Make "SquareAtScreenEdge" handle multiple monitors #6

Open ericmacedo opened 3 years ago

ericmacedo commented 3 years ago

Hi guys.

This tool is just amazing and worked like a charm!.. Until I plugged an external monitor: image

I'm using a dual-head setup, laptop(on the left) + monitor (on the right), and as you can see, the SquareAtScreenEdge does not handle more than one monitor. SquareAtScreenEdge works as expected in the other corners (the actual edges of the virtual screen):

image

My setup:

OS: Manjaro 21.1.0 Pahvo
Kernel: x86_64 Linux 5.10.59-1-MANJARO
Resolution: 2966x900
DE: KDE 5.85.0 / Plasma 5.22.4
WM: KWin
GTK Theme: Breeze [GTK2/3]

I'll try to work on a solution and send a pull request, but I don't have much time available, so if anyone can help sending a quick fix, that would be great!

Best regards.

ZacharyTalis commented 3 years ago

More info: SquareAtScreenEdge seems to fail on a corner-by-corner basis when the corner of a display is beside the edge of another display. Adding a gap between monitors doesn't resolve this issue.

Example:

Three displays in KDE's multi-monitor configuration tool.

No corners of HDMI-0 fail, the top corners of DP-0 fail, and the top-left corner of DP-2 fails. It's interesting that the top-right corner of DP-0 fails; I think that has to do with the differing resolutions between displays?

One weird fix would be to let users define which corners of which displays should always square. Though it sounds like a hassle to implement!

Here's the snippet of code that determines whether or not a corner should be squared.

I'm gonna dig some more into this, my understanding of how display corners are mapped in this program is pretty rudimentary.

Edit: Oh! Corners bordering another display will fail to square unless they're located at the edge of the display configuration as a whole. The top-right corner of DP-0 fails because it's lower than the top edge of HDMI-0.

ericmacedo commented 3 years ago

You are 100% correct @ZacharyTalis

I've spent some time analyzing the source code, reading Kwin's documentation, and as far as I understand it, kwineffects.h doesn't have an interface to Xinerama-like multi-screen setups. It handles multiple screens by combining all screens into a single output area.

Perhaps, using a different getter (other than Kwin::virtualScreenGeometry()) might provide more data about multi-head setups.

I believe that the simplest solution and a quick fix would be to make a boolean "isWindowMaximized" and just don't draw the corners... 🤔

ZacharyTalis commented 3 years ago

I made a fork with a (janky) approach: new SquareEdgesX and SquareEdgesY config options! You can check it out here.

The klutziness of this solution means my fork isn't PR-worthy, but it works well enough for my own use case.

A different getter would totally be the way to go, but I wasn't able to find one. Here's hoping some future person arrives at an elegant solution.