Hello,
I have noticed, that the autocompletion in Scintilla is not working on wayland. The widget is not shown at all and no error is logged. It works when I force it to use XWayland (by setting environment variable GDK_BACKEND=x11), but that is just an ugly workaround.
This might or might not be related to [#2261], although for me it is broken even when there is secondary monitor plugged in.
Tested with SciTE (Version 5.1.5 Scintilla:5.1.4 Lexilla:5.1.3 compiled for GTK:3.24.30) and Geany (version 1.38 and current master) on Arch Linux with sway WM.
I'm willing to test and debug the potential solutions. However, I'm not very familiar with either GTK nor scintilla code, so I might need some hints. So far I believe the problem is probably somewhere in ListBoxX::Create implementation, but there is quite a lot going on. Any ideas where I could start poking?
After bit more reconnaissance it seems that the problem is not actually in showing the window, but in its positioning and in my sway config.
I have the displays configured in sway config like this:
eDP-1is internal display of my notebook,HDMI-A-2is a HDMI port I use to plug in external monitor at work. I have the internal monitor offseted (to be below the external monitor). The code inListBoxX::GetDesiredRect()does not detect that and returns screen-based coordinates, which are then probably incorrectly interpreted by GTK.I might be able to fix this just by changing the config, but it doesn't solve the problem in #2261, which is definitely related. Actually, this is most probably a duplicate.
Start in
ScintillaBase::AutoCompleteStart, with the calls toSetPositionRelativemost likely to be interesting. Add some tracing herefprintf(stderr, ...or, if more familiar with debuggers, break just before those calls to check what the rectangles are for placing the list.Thanks for the hint Neil, it proved very helpful. I tracked it down to a single condition in
SetPositionRelative:I believe that the
oyvalue is correctly calculated in coordinates relative to the window (I gess the "o" stands for offset, rigt?), so comparing it torcMonitor.y, which is in global coordinates is wrong. It triggers every time, since the offset is always within the 1080px high screen, which is less than the 1080px of monitor offset.I believe that the correct thing to do here is to do the comparison in relative coordinates:
Similar fix would of course also be needed for all other conditions in this function, as they all seem to mix global and screen-relative coordinates.
The only remaining question is, whether this behaviour is specific to Sway (or Wayland). I really don't want to break it for other users using environments...
Also, I'm not sure how will this change affect various cases when the window is positioned over two monitors (although it is probably not very common case). I'll try to test it bit more on Monday, when I'll get to my office with the secondary monitor.
I have been able to add a second virtual monitor but its very limited and breaks easily. The problem only occurs for me on Wayland, not Xorg.
The
oy < rcMonitor.yclause comes from bug [#1920] change set [8e0cb3], "GTK: Fix popup positioning on monitors not positioned at 0,0".The above change (with corresponding change for 'x') does appear to help show the list with Wayland on my system.
Related
Bugs:
#1920Commit: [8e0cb3]
I have tried to figure out whether the suggested change would affect X11 users (by running with
GDK_BAKCEND=x11on wayland, I don't have Xorg installed). Unfortunately, it seems it would break current behaviour on X11.The problem is, that the behaviour of
gdk_window_get_originis not consistent accross platforms. I have looked through its implementation and found out it's probably documented behavior, see the comment here: https://gitlab.gnome.org/GNOME/gtk/-/blob/gtk-3-24/gdk/wayland/gdkwindow-wayland.c#L3671-3705So we should probably check what GDK backend is used. If it is wayland, than we can apply different corrections, while keeping current behaviour on X11 (and win32 and others which probably work correctly).
See the attached patch. Hope it is in correct format, I have never worked with mercurial before.
That works OK on Wayland.
The Wayland headers and calls may not be available on other systems like Win32 so should be protected with
#if defined(GDK_WINDOWING_WAYLAND)as is done inScintillaGTK.cxx.Good point, I didn't think of that. Here is an updated patch.
Diff:
Related
Bugs:
#2261Fix committed as [77364f].
Related
Commit: [77364f]
Fix committed as [77364f].
Related
Commit: [77364f]