fvwmorg / fvwm3

FVWM version 3 -- the successor to fvwm2
Other
505 stars 79 forks source link

X windows started on newly defined monitor doesn't accept focus #16

Closed NsCDE closed 4 years ago

NsCDE commented 4 years ago

It was said on the fvwm list that after turning new monitor everything should work without restart of fvwm3, but ...

Either windows moved (with mouse) from primary monitor to the new one, or started there, most of them doesn't have a keyboard/mouse focus. I can move them around, but that's it. Strangely, gvim doesn't have this problem, while Okular (Qt PDF viewer) even doesn't show drop down menu when I click on "File" or "View" etc ... When moved to the old display, they have a focus.

Another interesting behaviour is when I move from old monitor, from focused window to the new one, I can focus window on the new monitor, but only if I position mouse on the titlebar, borders or corners. The moment mouse pointer is moved further in the window - out of decoration, focus is lost.

Workaround: FVWM Restart solves all this.

Tried with the master and ta/desktops branch - same behaviour.

CentOS 7 x86_64 Xorg X.Org X Server 1.20.4

ThomasAdam commented 4 years ago

Hi,

Yes, I've sometimes seen this but have had trouble reproducing it. Your observations will help, thanks!

Is there anything printed to stderr which might help?

NsCDE commented 4 years ago

Of course. I have repeated all now and watched stderr.

Notice: happens for sure on the fresh Xorg process after initial login. Maybe you can reproduce this in that way. For mate-terminal and xterm, it is like that. Gvim works even without Restart. Strange.

  1. When I physically plug in DisplayPort cable of the DP1 monitor:

Monitor: eDP1 (PRIMARY) (x: 0, y: 0, w: 1920, h: 1080) monitor_create_randr_region: monitor 'eDP1' already in list, so skipping Screen found; no crtc present Screen found; no crtc present Screen found; no crtc present monitor_init_contents: init monitor for global Global, restoring previous desktop count is: 4

  1. When I do xrandr --output eDP1 --mode 1920x1080 --primary --output DP1 --mode 2560x1440 --right-of eDP1 --noprimary:

Monitor: eDP1 (x: 0, y: 0, w: 1920, h: 1080) monitor_create_randr_region: monitor 'eDP1' already in list, so skipping Monitor: DP1 (x: 1920, y: 0, w: 2560, h: 1440) Screen found; no crtc present Screen found; no crtc present monitor_init_contents: init monitor for global Global, restoring previous desktop count is: 4 Monitor: eDP1 (x: 0, y: 0, w: 1920, h: 1080) monitor_create_randr_region: monitor 'eDP1' already in list, so skipping Monitor: DP1 (x: 1920, y: 0, w: 2560, h: 1440) monitor_create_randr_region: monitor 'DP1' already in list, so skipping Screen found; no crtc present Screen found; no crtc present monitor_init_contents: init monitor for global Global, restoring previous desktop count is: 4 Monitor: eDP1 (x: 0, y: 0, w: 1920, h: 1080) monitor_create_randr_region: monitor 'eDP1' already in list, so skipping Monitor: DP1 (x: 1920, y: 0, w: 2560, h: 1440) monitor_create_randr_region: monitor 'DP1' already in list, so skipping Screen found; no crtc present Screen found; no crtc present monitor_init_contents: init monitor for global Global, restoring previous desktop count is: 4 Monitor: eDP1 (x: 0, y: 0, w: 1920, h: 1080) monitor_create_randr_region: monitor 'eDP1' already in list, so skipping Tried to create monitor 'DP1' but not connectedScreen found; no crtc present Screen found; no crtc present monitor_init_contents: init monitor for global Global, restoring previous desktop count is: 4 Monitor: eDP1 (x: 0, y: 0, w: 1920, h: 1080) monitor_create_randr_region: monitor 'eDP1' already in list, so skipping Monitor: DP1 (x: 1920, y: 0, w: 2560, h: 1440) monitor_create_randr_region: monitor 'DP1' already in list, so skipping Screen found; no crtc present Screen found; no crtc present monitor_init_contents: init monitor for global Global, restoring previous desktop count is: 4

While moving to the new monitor or calling terminal from the menu:

monitor_by_name: couldn't find monitor: (c) monitor_by_name: returning current monitor (DP1) MONITOR: I SHOULD HAVE PLACED ON: 'c' FindScreenOfXY: couldn't find screen at 2901 x 528 returning first monitor. This is a bug. monitor_by_number: couldn't find monitor id: 1 monitor_by_number: returning current monitor (eDP1) FindScreenOfXY: couldn't find screen at 2901 x 528 returning first monitor. This is a bug. monitor_by_number: couldn't find monitor id: 1 monitor_by_number: returning current monitor (eDP1) FindScreenOfXY: couldn't find screen at 2901 x 528 returning first monitor. This is a bug. monitor_by_number: couldn't find monitor id: 1 monitor_by_number: returning current monitor (eDP1) sh: pointer.screen: syntax error: invalid arithmetic operator (error token is ".screen") monitor_init_contents: init monitor for global Global, restoring previous desktop count is: 4 monitor_by_name: couldn't find monitor: (c) monitor_by_name: returning current monitor (eDP1) monitor_by_number: couldn't find monitor id: 1 monitor_by_number: returning current monitor (eDP1) monitor_by_number: couldn't find monitor id: 1 monitor_by_number: returning current monitor (eDP1) monitor_by_number: couldn't find monitor id: 1 monitor_by_number: returning current monitor (eDP1) monitor_init_contents: init monitor for global Global, restoring previous desktop count is: 4 monitor_by_name: couldn't find monitor: (c) monitor_by_name: returning current monitor (eDP1) monitor_init_contents: init monitor for global Global, restoring previous desktop count is: 4 monitor_by_name: couldn't find monitor: (c) monitor_by_name: returning current monitor (eDP1)

While trying to focus terminal window on the new monitor, and suceeding only if pointer is on decoration and not touching inside window, there is no any new output on stderr.

ThomasAdam commented 4 years ago

Thanks -- I'll take a look later.

In your config, are you using any StartsOnScreen styles?

NsCDE commented 4 years ago

Indeed. It is defined among other options in default (*) Style with "c" option.

StartsOnScreen c

ThomasAdam commented 4 years ago

Indeed. It is defined among other options in default (*) Style with "c" option.

StartsOnScreen c

Right -- this won't work now. Previously, 'c' meant the current monitor with the mouse pointer. Try changing all of those to: PositionPlacement UnderMouse.

NsCDE commented 4 years ago

Ok, removed StartsOnScreen while testing fvwm3.

If your intention was to inspect if behaviour described in this issue will gone if I remove this option, I have tested fvwm3 ta/desktops again without StartsOnScreen and strange focus behaviour remains until fvwm3 Restart from menu/console/etc ... after restart, everything is ok - every time I tested.

ThomasAdam commented 4 years ago

Ok, removed StartsOnScreen while testing fvwm3.

If your intention was to inspect if behaviour described in this issue will gone if I remove this option, I have tested fvwm3 ta/desktops again without StartsOnScreen and strange focus behaviour remains until fvwm3 Restart from menu/console/etc ... after restart, everything is ok - every time I tested.

Not at all -- your observations are valid and correct. I was more informing you about an incompatability from fvwm2 which isn't going to work in fvwm3, hence the suggestion on how to fix that. It doesn't impact or have anything to do with the focus problems you've described. :)

ThomasAdam commented 4 years ago

Hi,

Please can you:

git fetch
git checkout ta/desktops
git reset --hard @{u}

and retest. I've changed how FVWM is tracking RandR event subtypes, so I'm hoping this situation fixes this issue.

NsCDE commented 4 years ago

Hi Thomas,

Segfaults the same moment I turn on secondary screen with xrandr --right-of ...

Core was generated by `/opt/fvwm3/bin/fvwm3 -f /opt/NsCDE/config/NsCDE-Main.conf'. Program terminated with signal SIGSEGV, Segmentation fault.

0 0x000000000047cfa2 in EWMH_SetDesktopNames (m=0x1cb8040) at ewmh_names.c:285

285 d = m->Desktops->next;

(gdb) bt

0 0x000000000047cfa2 in EWMH_SetDesktopNames (m=0x1cb8040) at ewmh_names.c:285

1 0x000000000042b458 in HandleRRScreenChangeNotify () at events.c:1805

2 0x000000000042c9b9 in dispatch_event (e=e@entry=0x7fff73a150c0) at events.c:4193

3 0x000000000042d710 in HandleEvents () at events.c:4310

4 0x000000000040b49f in main (argc=, argv=) at fvwm3.c:2593

(gdb) print m->Desktops->next Cannot access memory at address 0x30

ThomasAdam commented 4 years ago

Hmm, I'm still unable to reproduce this after my latest commit.

Can you please set:

BugOpts DebugRandR on

At the top of your .fvwm2rc file (or whichever config you use), and watch STDERR again when the problem happens. I'm also assuming that m->Desktops is NULL (rather than m->Desktops->next). I suspect I'm missing some configuration point - so if you could also point me at your config(s) so I can use those here, that would probably help.

Thanks for your help and patience!

NsCDE commented 4 years ago

I didn't know for that BugOpts option. I have put it directly before any other directive.

No need thank me, I'm a great fun of FVWM and I'm glad if I can help. If you need some testing or similar, just ask, no problem.

About configuration: I'm using FVWM as a framework for my diabolic project of modern CDE-ish desktop called NsCDE (Not so Common Desktop Environment). All FVWM configuration is in config/ subdirectory. NsCDE-Main.conf is core part, and other parts are included/read from it. User part of the configuration is in ~/.NsCDE and it is default in my virtual machines for testing. It doesn't interfere with standard FVWM paths such is ~/.fvwm. Here it is: https://github.com/NsCDE/NsCDE

Here are the outputs (stderr and gdb):

1. Stderr from the moment of "xrandr --output Virtual-1 --mode 1400x1050 --right-of Virtual-0 --auto" till the logout after segfault.

[fvwm][My_XNextEvent]: <> executing module comand queue [fvwm][My_XNextEvent]: <> taking care of queued up events & returning (2) [fvwm][dispatch_event]: <> Routine Entered [fvwm][HandleVisibilityNotify]: <> Routine Entered [fvwm][dispatch_event]: <> Leaving Routine [fvwm][My_XNextEvent]: <> Routine Entered [fvwm][My_XNextEvent]: <> taking care of queued up events & returning (1) [fvwm][dispatch_event]: <> Routine Entered [fvwm][HandleVisibilityNotify]: <> Routine Entered [fvwm][dispatch_event]: <> Leaving Routine [fvwm][My_XNextEvent]: <> Routine Entered [fvwm][My_XNextEvent]: <> taking care of queued up events & returning (1) [fvwm][dispatch_event]: <> Routine Entered [fvwm][HandleVisibilityNotify]: <> Routine Entered [fvwm][dispatch_event]: <> Leaving Routine [fvwm][My_XNextEvent]: <> Routine Entered [fvwm][My_XNextEvent]: <> waiting for module input/output [fvwm][My_XNextEvent]: <> executing module comand queue [fvwm][My_XNextEvent]: <> taking care of queued up events & returning (2) [fvwm][dispatch_event]: <> Routine Entered [fvwm][HandleVisibilityNotify]: <> Routine Entered [fvwm][dispatch_event]: <> Leaving Routine [fvwm][My_XNextEvent]: <> Routine Entered [fvwm][My_XNextEvent]: <> taking care of queued up events & returning (1) [fvwm][dispatch_event]: <> Routine Entered [fvwm][HandleVisibilityNotify]: <> Routine Entered [fvwm][dispatch_event]: <> Leaving Routine [fvwm][My_XNextEvent]: <> Routine Entered [fvwm][My_XNextEvent]: <> taking care of queued up events & returning (1) [fvwm][dispatch_event]: <> Routine Entered [fvwm][HandleVisibilityNotify]: <> Routine Entered [fvwm][dispatch_event]: <> Leaving Routine [fvwm][My_XNextEvent]: <> Routine Entered [fvwm][My_XNextEvent]: <> waiting for module input/output [fvwm][My_XNextEvent]: <> executing module comand queue [fvwm][My_XNextEvent]: <> taking care of queued up events & returning (2) [fvwm][dispatch_event]: <> Routine Entered [fvwm][dispatch_event]: <> Leaving Routine [fvwm][My_XNextEvent]: <> Routine Entered [fvwm][My_XNextEvent]: <> waiting for module input/output [fvwm][My_XNextEvent]: <> executing module comand queue [fvwm][My_XNextEvent]: <> taking care of queued up events & returning (2) [fvwm][dispatch_event]: <> Routine Entered [fvwm][dispatch_event]: <> Leaving Routine [fvwm][My_XNextEvent]: <> Routine Entered [fvwm][My_XNextEvent]: <> waiting for module input/output [fvwm][My_XNextEvent]: <> executing module comand queue [fvwm][My_XNextEvent]: <> taking care of queued up events & returning (2) [fvwm][dispatch_event]: <> Routine Entered Monitor Debug number of outputs: 1 Name: Virtual-0 Is Primary: no Is Current: yes Coords: {x: 0, y: 0, w: 1400, h: 1050} Desktops: yes Flags:global

Monitor: Virtual-1 (x: 1400, y: 0, w: 1400, h: 1050) HandleRRScreenChangeNotify: monitor debug... Monitor Debug number of outputs: 1 Name: Virtual-0 Is Primary: no Is Current: yes Coords: {x: 0, y: 0, w: 1400, h: 1050} Desktops: yes Flags:global

Name:   Virtual-1
Is Primary: no
Is Current: no
Coords: {x: 1400, y: 0, w: 1400, h: 1050}
Desktops:   no
Flags:global

XIO: fatal IO error 4 (Interrupted system call) on X server ":0" after 212 requests (212 known processed) with 0 events remaining. XIO: fatal IO error 4 (Interrupted system call) on X server ":0" XIO: fatal IO error 4 (Interrupted system call) on X server ":0" after 343 requests (343 known processed) with 0 events remaining. XIO: fatal IO error 4 (Interrupted system call) on X server ":0" after 274 requests (274 known processed) with 0 events remaining. XIO: fatal IO error 4 (Interrupted system call) on X server ":0" after 141 requests (141 known processed) with 0 events remaining. X connection to :0 broken (explicit kill or server shutdown). XIO: fatal IO error 4 (Interrupted system call) on X server ":0" X connection to :0 broken (explicit kill or server shutdown). after 441 requests (441 known processed) with 0 events remaining. XIO: fatal IO error 4 (Interrupted system call) on X server ":0" after 306 requests (306 known processed) with 0 events remaining. after 198 requests (198 known processed) with 0 events remaining. X connection to :0 broken (explicit kill or server shutdown). kgpg: Fatal IO error 11 (Resource temporarily unavailable) on X server :0. Gdk-Message: 15:32:36.328: mate-terminal: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.

python3: Fatal IO error 11 (Resource temporarily unavailable) on X server :0. resapplet: Fatal IO error 11 (Resource temporarily unavailable) on X server :0. XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0" after 846 requests (846 known processed) with 27 events remaining. gkrellm: Fatal IO error 11 (Resource temporarily unavailable) on X server :0. X connection to :0 broken (explicit kill or server shutdown). X connection to :0 broken (explicit kill or server shutdown). X connection to :0 broken (explicit kill or server shutdown).

XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0" after 117 requests (117 known processed) with 0 events remaining. XIO: fatal IO error 11 (Resource temporarily unavailable) on X server ":0" after 166 requests (166 known processed) with 0 events remaining.

2. gdb full trace, including print of m->Desktops

Core was generated by `/opt/fvwm3/bin/fvwm3 -f /opt/NsCDE/config/NsCDE-Main.conf'. Program terminated with signal SIGSEGV, Segmentation fault.

0 EWMH_SetDesktopNames (m=0x14df550) at ewmh_names.c:285

285 d = m->Desktops->next; (gdb) bt

0 EWMH_SetDesktopNames (m=0x14df550) at ewmh_names.c:285

1 0x000000000043a113 in HandleRRScreenChangeNotify () at events.c:1805

2 0x000000000043eaf9 in dispatch_event (e=0x7ffe17923fa0) at events.c:4193

3 0x000000000043edf7 in HandleEvents () at events.c:4310

4 0x000000000046776e in main (argc=4, argv=0x7ffe17924418) at fvwm3.c:2593

(gdb) print m->Desktops $1 = (DesktopsInfo *) 0x0 (gdb) print m->Desktops->next Cannot access memory at address 0x30

NsCDE commented 4 years ago

I'm adding video instructions of how to reproduce this bug.

View->Display 2 is equivalent of hardware monitor connecting with cable

https://www.youtube.com/watch?v=pbZInippBpc

NsCDE commented 4 years ago

Update:

I was able to reproduce this with vanilla FVWM configuration.

If spice-vdagent is turned on, it presents 3 more additional virtual screens to the Xorg and driver. If FVWM is started with all but first screen off and then second screen is plugged on, it is blank until I enable it with xrandr from xterm. FVWM background is visible for a part of a second on new screen, and then sigsegv comes. Backtrace is the same as always - m->Desktops is 0x0.

Also, when using FVWM 2.6.9 I'm not triggering this bug. Neither with vanilla not with my setup.

After logout, scrondary screen remains turned on (see video) and if I log in again with such pre-defined setup, bug is not manifesting again itsel, so I can at least confirm that focus problems from the subject of this bug are fixed.

ThomasAdam commented 4 years ago

Hi,

Perfect. I have now spent wayyyy too long understanding what's happening. Thanks for the video, BTW, that was useful.

FVWM looks at the rectangle per page when deciding if InputFocus should be given. The problem here is that when RandR tells FVWM that it has a new monitor to deal with, then two things happens:

  1. FVWM scans the new monitor and adds it to the list, with the appropriate coordinates;
  2. FVWM will then instantiate desktops, etc., and EWMH sizes based on the DesktopConfiguration setting (defaults to global).

Because the existing connection to the XServer is open. the use of DefaultWidth() and DefaultHeight() macros won't understand that the root window's size has changed. So what was happening is that the windows were being mapped fine, but their bounding page rectangle was something FVWM knew nothing about.

So, I've tried to fix this in a few ways:

  1. Listening more to what's happening with RandR and handling existing/new outputs, by updating existing dimensions for monitors, or creating new ones. Existing outputs, when they're turned off, will be marked as inactive and dead.
  2. Trying to better handle DesktopConfiguration per-desktop by tracking the EWMH working area.
  3. Updated the debug output for BugOpts DebugRandR

So, @NsCDE -- can you please update your git repo per the following:

git fetch
git checkout -t origin/ta/fix-gh-16

and try and see what you get this time? There's going to be a few extra bugs here, I'm sure of it, as it's quite a big change (770aab77935b9db35a69b17c9b6b7ecfe49a6e2d) -- so we'll tackle those one-by-one. #17 is definitely going to bite us -- so if you can test the behaviour with DesktopSize 1x1 first of all, and then expand that out to DesktopSize 3x3, that will help me undesrtand the page dynamics. I wouldn't recommend going near FvwmPager just yet either.

Thanks again for your help!

NsCDE commented 4 years ago

Hi,

I have checked out ta/desktops but it is the same as 2 days ago, which I tested during the weekend. You probably meant to checkout ta/fix-gh-16 from 770aab7 right?

EDIT: I started to type this in the morning, but had work to do. Now I see you edited and clarified that.

It doesn't segfault anymore on new monitor plug + xrandr. Focus on the new screen is working ok without Restart. So you did it on this bug. Interesting part of the stderr output (see below). But, as you said, there is more bugs here. So my observations are further this:

  1. After turning new screen, manual "xrefresh" is needed to clean up more or less messed up screens. This is probably minor annoyance and cosmetical thing which can be handled when more serious problems are solved.

  2. With DesktopConfiguration per-monitor, FvwmPager is not working yet as you said, but opening various apps on 1x1 DesktopSize is mainly ok with some glitches and lost windows which can be fetched with WindowList only. Later I will make some time to document it in detail, and then try with 3x3. I will probably make video for visual observation. Should this be handled here on #16 or under issue #19 or #17 ? In other words, are we are still diagnosing focus on new screen or per-monitor DesktopConfiguration now? :)

Stderr output in the moment of xrandr adding screen:

... [fvwm][dispatch_event]: <> Routine Entered Monitor Debug number of outputs: 1 Name: Virtual-0 Disabled: false Is Primary: no Is Current: yes Wants Refresh: false Output: 67 Coords: {x: 0, y: 0, w: 1400, h: 1050} VirtScr: { VxMax: 2800, VyMax: 2100, Vx: 0, Vy: 0 EdgeScrollX: 1400, EdgeScrollY: 1050 CurrentDesk: 0 MyDisplayWidth: 1400, MyDisplayHeight: 1050 } Desktops: yes Flags:per-monitor

monitor_output_change: changed output: 68, mon output: 67 Monitor: Virtual-1 (x: 1400, y: 0, w: 1400, h: 1050) HandleRRScreenChangeNotify: monitor debug... Monitor Debug number of outputs: 1 Name: Virtual-0 Disabled: false Is Primary: no Is Current: yes Wants Refresh: false Output: 67 Coords: {x: 0, y: 0, w: 1400, h: 1050} VirtScr: { VxMax: 2800, VyMax: 2100, Vx: 0, Vy: 0 EdgeScrollX: 1400, EdgeScrollY: 1050 CurrentDesk: 0 MyDisplayWidth: 1400, MyDisplayHeight: 1050 } Desktops: yes Flags:per-monitor

Name:   Virtual-1
Disabled:   false
Is Primary: no
Is Current: no
Wants Refresh:  true
Output: 68
Coords: {x: 1400, y: 0, w: 1400, h: 1050}
VirtScr: {
    VxMax: 5600, VyMax: 2100, Vx: 0, Vy: 0
    EdgeScrollX: 2800, EdgeScrollY: 1050
    CurrentDesk: 0
    MyDisplayWidth: 2800, MyDisplayHeight: 1050
}
Desktops:   yes
Flags:per-monitor

HandleRRScreenChangeNotify: refreshing monitor Virtual-1

ThomasAdam commented 4 years ago

Hi,

I have checked out ta/desktops but it is the same as 2 days ago, which I tested during the weekend. You probably meant to checkout ta/fix-gh-16 from 770aab7 right?

Yes, sorry. All of this work is happening on ta/fix-gh-16 for now, until I can tidy it up and commit that, and outstanding work on ta/desktops, but ta/fix-gh-16 is based from ta/desktops anyway.

EDIT: I started to type this in the morning, but had work to do. Now I see you edited and clarified that.

:). I realised this morning it was ambiguous.

It doesn't segfault anymore on new monitor plug + xrandr. Focus on the new screen is working ok without Restart. So you did it on this bug. Interesting part of the stderr output (see below).

Good -- and thanks.

But, as you said, there is more bugs here. So my observations are further this:

1. After turning new screen, manual "**xrefresh**" is needed to clean up more or less messed up screens. This is probably minor annoyance and cosmetical thing which can be handled when more serious problems are solved.

Interesting. I've not seen this yet, and I've been testing both on two physical monitors, and three virtual monitors where I can assign them weird/different sizes from one another (most physical screens tend to have the same dimensions). If you could capture either a screenshot or video, that would help me.

2. With `DesktopConfiguration per-monitor`, FvwmPager is not working yet as you said, but opening various apps on `1x1` `DesktopSize` is mainly ok with some glitches and lost windows which can be fetched with WindowList only. Later I will make some time to document it in detail, and then try with 3x3. I will probably make video for visual observation. Should this be handled here on #16 or under issue #19 or #17 ? In other words, are we are still diagnosing focus on new screen or per-monitor DesktopConfiguration now? :)

I think it might be better if we split this up. I understand why the original focus problem existed, and have fixed that, although it has uncovered other problems, so I would suggest you split out your observations.

Stderr output in the moment of xrandr adding screen:

BTW, you don't need to use --enable-debug when running ./configure -- at this point, it's just noise with nothing useful in there.

Thanks for the output, I'll keep that in mind!

ThomasAdam commented 4 years ago

Hi,

I've just pushed an additional fix (120a22577746d16025790daee9f07a318c18844b) which might help with areas of the screen still not being able to focus windows -- do please:

git checkout ta/fix-gh-16
git fetch
git reset --hard @{u}

make and build as usual, and try again. This removes a memcpy call which would have overwritten virtual_scr information when switching desks.

NsCDE commented 4 years ago

HEAD is now at 120a2257 WIP: RandR: track subtypes for outputs

At DesktopSize 1x1: MUCH more consistent, Except Scroll 100 goes some noware, even at 1x1. I will test 3x3 and all details in the evening (central Europe time). No time now ...

BTW, about xrefresh need when turning screen off/on: https://youtu.be/eeazHqdlLdk

NsCDE commented 4 years ago

At DesktopSize 3x3 wherever I go or move, "Echo $[page.nx] $[page.ny]" is always 0 0. With one screen or two screens. After I jump myself with "GotoPage 1 1" I'm still at 0 0, but terminal window is not there anymore. If I try to go back at 0 0, terminal is still not there. It is accessible only through WindowList, and repositioned at left top corner.

At DesktopSize 1x1, while walking through desktops with "GotoDesk 0 0" to 0 3, all seems to be ok. I have opened 2x4 terminals and wrote screen name and desk number in prompt, and make walk. Seems legit, except $[screen] is uninitialized.

[fvwm][Echo]: DEBUG-DSK: Screen: $[screen], Desk: 1, Page X: 0, Page Y: 0 [fvwm][Echo]: DEBUG-DSK: Screen: $[screen], Desk: 2, Page X: 0, Page Y: 0 [fvwm][Echo]: DEBUG-DSK: Screen: $[screen], Desk: 3, Page X: 0, Page Y: 0 [fvwm][Echo]: DEBUG-DSK: Screen: $[screen], Desk: 0, Page X: 0, Page Y: 0 EWMH_GetWorkAreaIntersection: using: {x: 0, y: 0, w: 1400, h: 1050} EWMH_GetWorkAreaIntersection: using: {x: 0, y: 0, w: 1400, h: 1050} [fvwm][Echo]: DEBUG-DSK: Screen: $[screen], Desk: 0, Page X: 0, Page Y: 0 [fvwm][Echo]: DEBUG-DSK: Screen: $[screen], Desk: 1, Page X: 0, Page Y: 0 [fvwm][Echo]: DEBUG-DSK: Screen: $[screen], Desk: 2, Page X: 0, Page Y: 0 [fvwm][Echo]: DEBUG-DSK: Screen: $[screen], Desk: 3, Page X: 0, Page Y: 0

Additionaly, if I try to print desktop name with "Echo $[desk.nameX]" I get segmentation fault and express logout.

Reading symbols from /opt/fvwm3/bin/fvwm3... [New LWP 111389] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Core was generated by/opt/fvwm3/bin/fvwm3 -f /opt/NsCDE/config/NsCDE-Main.conf'. Program terminated with signal SIGSEGV, Segmentation fault.

0 0x000000000049dab0 in expand_vars_extended (var_name=0x276de4f "desk.name1", output=0x0, cond_rc=0x7ffd68038138, exc=0x274d290) at expand.c:446

446 string = GetDesktopName(fw->m, cs); (gdb) bt full

0 0x000000000049dab0 in expand_vars_extended (var_name=0x276de4f "desk.name1", output=0x0, cond_rc=0x7ffd68038138, exc=0x274d290) at expand.c:446

    rest = 0x276de58 "1"
    dummy = '\000' <repeats 63 times>
    target = 0x7ffd68037ec0 ""
    cs = 1
    n = 1
    i = 1
    l = 32765
    x = 32765
    y = 1745059648
    pixel = 0
    val = -12345678
    string = 0x0
    allocated_string = 0x0
    quoted_string = 0x0
    should_quote = 0
    is_numeric = 0
    is_target = 0
    is_x = 2147483647
    context_w = 710
    fw = 0x0
    m = 0x24bf980
    len = -1

1 0x000000000049ed58 in expand_vars (input=0x276de48 "Echo $[desk.name1", arguments=0x7ffd680380d0, addto=0, ismod=0, cond_rc=0x7ffd68038138, exc=0x274d290) at expand.c:1095

    l = 18
    i = 5
    l2 = 18
    n = 0
    k = 10
    j = 0
    m = 17
    xlen = -1
    xlevel = 0
    name_has_dollar = 0
    out = 0x7ffd68038040 "\300\201\003h\375\177"
    var = 0x276de4f "desk.name1"
    string = 0x0
    is_string = 0
    fw = 0x0
    mon = 0x24bf980

2 0x000000000048cae1 in __execute_function (cond_rc=0x0, exc=0x274d290, action=0x276de48 "Echo $[desk.name1", exec_flags=0 '\000', args=0x0, has_ref_window_moved=0) at functions.c:549

    func_depth = 1
    func_rc = 0x7ffd68038138
    dummy_rc = {rc = COND_RC_OK, break_levels = 0}
    w = 710
    j = 11
    function = 0x274b330 "Echo"
    taction = 0x276de48 "Echo $[desk.name1"
    trash = 0x50fe00 <tmptok> "Echo"
    trash2 = 0x276de4d "$[desk.name1"
    expaction = 0x0
    arguments = {0x0 <repeats 11 times>}
    bif = 0x4e9740 <func_table+1152>
    set_silent = 0

--Type for more, q to quit, c to continue without paging-- must_free_string = 0 must_free_function = 1 do_keep_rc = 0 dummy_w = 0

3 0x000000000048df66 in execute_function (cond_rc=0x0, exc=0x274d290, action=0x276de48 "Echo $[desk.name1", exec_flags=0 '\000') at functions.c:1302

4 0x00000000004a1374 in module_input_execute (input=0x276de30) at module_interface.c:693

    e = 
        {type = 5, xany = {type = 5, serial = 0, send_event = 0, display = 0x0, window = 0}, xkey = {type = 5, serial = 0, send_event = 0, display = 0x0, window = 0, root = 0, subwindow = 0, time = 0, x = 0, y = 0, x_root = 638, y_root = 712, state = 0, keycode = 1, same_screen = 0}, xbutton = {type = 5, serial = 0, send_event = 0, display = 0x0, window = 0, root = 0, subwindow = 0, time = 0, x = 0, y = 0, x_root = 638, y_root = 712, state = 0, button = 1, same_screen = 0}, xmotion = {type = 5, serial = 0, send_event = 0, display = 0x0, window = 0, root = 0, subwindow = 0, time = 0, x = 0, y = 0, x_root = 638, y_root = 712, state = 0, is_hint = 1 '\001', same_screen = 0}, xcrossing = {type = 5, serial = 0, send_event = 0, display = 0x0, window = 0, root = 0, subwindow = 0, time = 0, x = 0, y = 0, x_root = 638, y_root = 712, mode = 0, detail = 1, same_screen = 0, focus = 0, state = 0}, xfocus = {type = 5, serial = 0, send_event = 0, display = 0x0, window = 0, mode = 0, detail = 0}, xexpose = {type = 5, serial = 0, send_event = 0, display = 0x0, window = 0, x = 0, y = 0, width = 0, height = 0, count = 0}, xgraphicsexpose = {type = 5, serial = 0, send_event = 0, display = 0x0, drawable = 0, x = 0, y = 0, width = 0, height = 0, count = 0, major_code = 0, minor_code = 0}, xnoexpose = {type = 5, serial = 0, send_event = 0, display = 0x0, drawable = 0, major_code = 0, minor_code = 0}, xvisibility = {type = 5, serial = 0, send_event = 0, display = 0x0, window = 0, state = 0}, xcreatewindow = {type = 5, serial = 0, send_event = 0, display = 0x0, parent = 0, window = 0, x = 0, y = 0, width = 0, height = 0, border_width = 0, override_redirect = 0}, xdestroywindow = {type = 5, serial = 0, send_event = 0, display = 0x0, event = 0, window = 0}, xunmap = {type = 5, serial = 0, send_event = 0, display = 0x0, event = 0, window = 0, from_configure = 0}, xmap = {type = 5, serial = 0, send_event = 0, display = 0x0, event = 0, window = 0, override_redirect = 0}, xmaprequest = {type = 5, serial = 0, send_event = 0, display = 0x0, parent = 0, window = 0}, xreparent = {type = 5, serial = 0, send_event = 0, display = 0x0, event = 0, window = 0, parent = 0, x = 0, y = 0, override_redirect = 0}, xconfigure = {type = 5, serial = 0, send_event = 0, display = 0x0, event = 0, window = 0, x = 0, y = 0, width = 0, height = 0, border_width = 0, above = 3058016715390, override_redirect = 0}, xgravity = {type = 5, serial = 0, send_event = 0, display = 0x0, event = 0, window = 0, x = 0, y = 0}, xresizerequest = {type = 5, serial = 0, send_event = 0, display = 0x0, window = 0, width = 0, height = 0}, xconfigurerequest = {type = 5, serial = 0, send_event = 0, display = 0x0, parent = 0, window = 0, x = 0, y = 0, width = 0, height = 0, border_width = 0, above = 3058016715390, detail = 0, value_mask = 0}, xcirculate = {type = 5, serial = 0, send_event = 0, display = 0x0, event = 0, window = 0, place = 0}, xcirculaterequest = {type = 5, serial = 0, send_event = 0, display = 0x0, parent = 0, window = 0, place = 0}, xproperty = {type = 5, serial = 0, send_event = 0, display = 0x0, window = 0, atom = 0, time = 0, state = 0}, xselectionclear = {type = 5, serial = 0, send_event = 0, display = 0x0, window = 0, selection = 0, time = 0}, xselectionrequest = {type = 5, serial = 0, send_event = 0, display = 0x0, owner = 0, requestor = 0, selection = 0, target = 0, property = 0, time = 3058016715390}, xselection = {type = 5, serial = 0, send_event = 0, display = 0x0, requestor = 0, selection = 0, target = 0, property = 0, time = 0}, xcolormap = {type = 5, serial = 0, send_event = 0, display = 0x0, window = 0, colormap = 0, new = 0, state = 0}, xclient = {type = 5, serial = 0, send_event = 0, display = 0x0, window = 0, message_type = 0, format = 0, data = {b = '\000' <repeats 16 times>, "~\002\000", s = {0, 0, 0, 0, 0, 0, 0, 0, 638, 0}, l = {0, 0, 3058016715390, 4294967296, 0}}}, xmapping = {type = 5, serial = 0, send_event = 0, display = 0x0, window = 0, request = 0, first_keycode = 0, count = 0}, xerror = {type = 5, display = 0x0, resourceid = 0, serial = 0, error_code = 0 '\000', request_code = 0 '\000', minor_code = 0 '\000'}, xkeymap = {type = 5, serial = 0, send_event = 0, display = 0x0, window = 0, key_vector = '\000' <repeats 31 times>}, xgeneric = {type = 5, serial = 0, send_event = 0, display = 0x0, extension = 0, evtype = 0}, xcookie = {type = 5, serial = 0, send_event = 0, display = 0x0, extension = 0, evtype = 0, cookie = 0, data = 0x0}, pad = {5, 0, 0, 0, 0, 0, 0, 0, 0, 3058016715390, 4294967296, 0 <repeats 13 times>}}
    exc = 0x274d290
    ecc = {type = EXCT_MODULE, x = {etrigger = 0x7ffd68038250, elast = 0x7ffd68038920}, w = {fw = 0x0, w = 0, wcontext = 8}, m = {module = 0x24a4820}}
    flags = 0

5 0x00000000004a13fd in ExecuteCommandQueue () at module_interface.c:734

    input = 0x276de30

6 0x000000000043f1d1 in My_XNextEvent (dpy=0x24af1a0, event=0x7ffd680384b0) at events.c:4500

    in_fdset = {fds_bits = {1024, 0 <repeats 15 times>}}
    out_fdset = {fds_bits = {0 <repeats 16 times>}}
    num_fd = 1
    moditr = 0x0
    module = 0x0
    input = 0x276de30
    timeout = {tv_sec = 42, tv_usec = 0}
    timeoutP = 0x0

7 0x000000000043eccc in HandleEvents () at events.c:4315

    ev = 
        {type = 28, xany = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, window = 46137355}, xkey = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, window = 46137355, root = 339, subwindow = 100045556, time = 0, x = 560, y = 475, x_root = 560, y_root = 475, state = 2, keycode = 2, same_screen = 1}, xbutton = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, window = 46137355, root = 339, subwindow = 100045556, time = 0, x = 560, y = 475, x_root = 560, y_root = 475, state = 2, button = 2, same_screen = 1}, xmotion = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, window = 46137355, root = 339, subwindow = 100045556, time = 0, x = 560, y = 475, x_root = 560, y_root = 475, state = 2, is_hint = 2 '\002', same_screen = 1}, xcrossing = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, window = 46137355, root = 339, subwindow = 100045556, time = 0, x = 560, y = 475, x_root = 560, y_root = 475, mode = 2, detail = 2, same_screen = 1, focus = 0, state = 0}, xfocus = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, window = 46137355, mode = 339, detail = 0}, xexpose = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, window = 46137355, x = 339, y = 0, width = 100045556, height = 0, count = 0}, xgraphicsexpose = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, drawable = 46137355, x = 339, y = 0, width = 100045556, height = 0, count = 0, major_code = 0, minor_code = 560}, xnoexpose = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, drawable = 46137355, major_code = 339, minor_code = 0}--Type <RET> for more, q to quit, c to continue without paging--

, xvisibility = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, window = 46137355, state = 339}, xcreatewindow = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, parent = 46137355, window = 339, x = 100045556, y = 0, width = 0, height = 0, border_width = 560, override_redirect = 475}, xdestroywindow = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, event = 46137355, window = 339}, xunmap = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, event = 46137355, window = 339, from_configure = 100045556}, xmap = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, event = 46137355, window = 339, override_redirect = 100045556}, xmaprequest = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, parent = 46137355, window = 339}, xreparent = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, event = 46137355, window = 339, parent = 100045556, x = 0, y = 0, override_redirect = 560}, xconfigure = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, event = 46137355, window = 339, x = 100045556, y = 0, width = 0, height = 0, border_width = 560, above = 2040109466160, override_redirect = 2}, xgravity = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, event = 46137355, window = 339, x = 100045556, y = 0}, xresizerequest = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, window = 46137355, width = 339, height = 0}, xconfigurerequest = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, parent = 46137355, window = 339, x = 100045556, y = 0, width = 0, height = 0, border_width = 560, above = 2040109466160, detail = 2, value_mask = 1}, xcirculate = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, event = 46137355, window = 339, place = 100045556}, xcirculaterequest = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, parent = 46137355, window = 339, place = 100045556}, xproperty = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, window = 46137355, atom = 339, time = 100045556, state = 0}, xselectionclear = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, window = 46137355, selection = 339, time = 100045556}, xselectionrequest = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, owner = 46137355, requestor = 339, selection = 100045556, target = 0, property = 2040109466160, time = 2040109466160}, xselection = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, requestor = 46137355, selection = 339, target = 100045556, property = 0, time = 2040109466160}, xcolormap = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, window = 46137355, colormap = 339, new = 100045556, state = 0}, xclient = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, window = 46137355, message_type = 339, format = 100045556, data = {b = "\000\000\000\000\000\000\000\000\060\002\000\000\333\001\000\000\060\002\000", s = {0, 0, 0, 0, 560, 0, 475, 0, 560, 0}, l = {0, 2040109466160, 2040109466160, 8589934594, 1}}}, xmapping = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, window = 46137355, request = 339, first_keycode = 0, count = 100045556}, xerror = {type = 28, display = 0xb117, resourceid = 0, serial = 38465952, error_code = 11 '\v', request_code = 0 '\000', minor_code = 192 '\300'}, xkeymap = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, window = 46137355, key_vector = "S\001\000\000\000\000\000\000\364\222\366\005", '\000' <repeats 12 times>, "\060\002\000\000\333\001\000"}, xgeneric = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, extension = 46137355, evtype = 0}, xcookie = {type = 28, serial = 45335, send_event = 0, display = 0x24af1a0, extension = 46137355, evtype = 0, cookie = 339, data = 0x5f692f4}, pad = {140063178489884, 45335, 0, 38465952, 46137355, 339, 100045556, 0, 2040109466160, 2040109466160, 8589934594, 1, 0, 14680065, 2098310, 41202800, 8454150701025817422, 14755881688330338, 33, 41304080, 41225728, 672, 112, 38442512}}

8 0x000000000046769b in main (argc=4, argv=0x7ffd68038928) at fvwm3.c:2598

    valuemask = 8202
    attributes = 
      {background_pixmap = 0, background_pixel = 12500670, border_pixmap = 0, border_pixel = 0, bit_gravity = 0, win_gravity = 0, backing_store = -1568832607, backing_planes = 38290720, backing_pixel = 140065904520576, save_under = 124, event_mask = 2097155, do_not_propagate_mask = 4097, override_redirect = 1, colormap = 32, cursor = 2097156}
    i = 1
    len = 2
    display_string = 0x24b1330 ""
    do_force_single_screen = 0
    single_screen_num = -1
    replace_wm = 0
    visualClass = -1
    visualId = -1
    colorLimitop = {color_limit = -1, strict = -1, allocate = -1, not_dynamic = -1, use_named_table = -1}
    exc = 0x24dd6b0
    ecc = {type = EXCT_INIT, x = {etrigger = 0x0, elast = 0x770000007c}, w = {fw = 0x5b0000006e, w = 38331728, wcontext = 8}, m = {module = 0x7f63a25419e0 <main_arena>}}
    m = 0x0

(gdb) p string $1 = 0x0 (gdb) p fw->m Cannot access memory at address 0x510 (gdb) p cs $2 = 1 (gdb) `

ThomasAdam commented 4 years ago

Ooh nice!

Two things to note here (more detail in commit message (ea81cc123fdb2630a832aaf1642b71c8853948a1)):

  1. When expanding variables, don't assume fw->m as fw is not guaranteed to be present or a valid context to reference a monitor from.
  2. When handling pages/desks, copy over the changed monitor values to all other monitors. This should now expand variables such as $[page.nx] and $[page.ny].

I'm hoping that point 2 above also helps to go further when handling desks/pages when the DesktopSize is 3x3 or greater than 1x1.

Do please take a look and check I've not broken anything else!

NsCDE commented 4 years ago

Hi,

Now about DektopSize 3x3 from my test: it behaves correctly with one screen, but with DesktopConfiguration per-monitor, windows from pages on first screen are shown on second screen later. For example:

With GotoPage 0 0 on Virtual-0, page 1 0 with gvim from Virtual-0 is shown on Virtual-1, and when I open terminal next to that gvim (which I use as scratch with text indicator in tests) and Echo page.nx and page.ny, it shows "1 1" etc ...

I'm sending you visual preview of this. For the sake of being a bit shorter, I worked with DesktopSize 2x2 while capturing this, but behaviour is the same. Working desk ("One") was not changed during this, just pages. 4 and half minutes with stderr on tail -f. Hope this helps.

https://youtu.be/Fm1SlvMGmx4

ThomasAdam commented 4 years ago

Hi,

Hello,

* desk.nameX variable access looks fixed

Good.

* page.nx and page.ny are expanded ok now according to stderr

Good.

* `$[screen]` is still unexpanded, it should be nice if `$[screen]` and `$[pointer.screen]` contains numerical values as in 2.6.X, because they are expected as such (things can break if "DP2" is presented to some PipeRead for `$(($[pointer.screen] + 1))` instead od "2". Maybe `$[pointer.screen.name]` and `$[screen.name]` can be introduced? Akin to gethostbyaddr vs gethostbyname. :)

Yeah -- it's something to consider. I'll add it to the TODO list, but at least there's a mechanism for ascertaining the RandR output. I probably made $[screen] a NOP when RandR is enabled for backwards compatibility with FVWM2, but that's less of a concern.

Now about DektopSize 3x3 from my test: it behaves correctly with one screen, but with DesktopConfiguration per-monitor, windows from pages on first screen are shown on second screen later. For example:

With GotoPage 0 0 on Virtual-0, page 1 0 with gvim from Virtual-0 is shown on Virtual-1, and when I open terminal next to that gvim (which I use as scratch with text indicator in tests) and Echo page.nx and page.ny, it shows "1 1" etc ...

This is related to #17 -- essentially, to work out which monitor a given window is on, we're only comparing the physical dimensions of the output. For DesktopSize 1x1 that's easy as it's just one dimension. But for 2x2, the geometry of the window is a multiple of the monitor's root-window. What I need to do is modulo the actual window geometry's page, relative to the output it's on.

The maths will be tricky to do. This will also fix dragging windows around in FvwmPager. (On that note, with the changes I've made recently on ta/fix-gh-16, the reason why FvwmPager doesn't load is because there's no reliable way for FvwmPager to register its interest in finding out which RandR outputs are available. I'll look in to this soon.

I'm sending you visual preview of this. For the sake of being a bit shorter, I worked with DesktopSize 2x2 while capturing this, but behaviour is the same. Working desk ("One") was not changed during this, just pages. 4 and half minutes with stderr on tail -f. Hope this helps.

https://youtu.be/Fm1SlvMGmx4

It does help me a lot -- thank you! I'll see what I can!

NsCDE commented 4 years ago

Ok, looks like #19 is solved by activities on this (#16) issue, and problems with window/page addressing in per-monitor conditions can be continued on #17 right. This #16 also looks as solved. during the day, I will put "on paper" some throughts about #17 and wrote something. Maybe it can help to solve this screen/desk/page puzzle.