eteran / nedit-ng

a Qt5 port of the NEdit using modern C++14
GNU General Public License v2.0
94 stars 26 forks source link

Nedit-ng window stuck on top right of the screen when nedit-ng is invoked with a file path to open. #48

Open ahmedo15 opened 6 years ago

ahmedo15 commented 6 years ago

Hello,

Thanks for your development of this new nedit with Qt.

I have downloaded the sources ( release 2018.5) and compile it with qt 5.6.3 on RHE6. When I launch nedit-ng with a file path as argument, the nedit-ng window is open at the upper right corner of the screen and I cannot move it. Nedit-ng window appears correctly at the center of the screen when no filecis given as argument. It works fine on Ubuntu in both cases.

Thanks.

eteran commented 6 years ago

If I understand you correctly, the issue seems to be specific to RHE6 (and not Ubuntu)?

Does nedit-ng get proper window decorations when it is "stuck"? Does the name of the file have any bearing on the result?

Also, have you tried (just as a test), some window managers let you hold down ALT to left click a window and drag it even regardless of whether or not you're clicking the title bar (useful for windows half off the screen).

I just want to get a feel for the nature of the issue and see what factors are at play.

ahmedo15 commented 6 years ago

Right. The problem is encoutered only in RHEL6. I use xfce 4.8 and this is the only desktop I have on my work machine. In fact I use vnc and RHEL6 is installed on a server. When the window is "stuck" i have the menu bar hidden by the top xfce panel.

In my personal pc, I use ubuntu 2018.4 and gnome and the qt installed on it should the latest release available ( probably 5.9). I will try xfce and see if I encounter the same issue as on work machine.

ahmedo15 commented 6 years ago

It works fine on Ubuntu using XFCE desktop. screenshot1

eteran commented 6 years ago

Very strange, I'm not exactly sure how I would go about re-creating the issue locally. I'll see if I can get a CentOS6 VM setup using xfce.

Is it possible that VNC is somehow a factor? Can you test locally?

ahmedo15 commented 6 years ago

Old Motif based nedit 5.6 works fine on VNC. I cannot test locally as the only mean to have linux at work is to use VNC. For now, I use nedit and when I use nedit-ng , I open it without specifying any file path. Then I use ctrl-y to open the file with the path under selection.

I wonder if this issue is linked to a bug in qt 5.6? Anyway I don't want to give you extra work to fix this issue which I'am the only one to encounter it:-)

eteran commented 6 years ago

I suspect that it is an upstream Qt bug with 5.6, but it's very hard to tell without first reproducing the issue myself. I'll leave this issue open, in the hopes that if anyone else is experiencing this, they can chime in but I'll try and see if I can figure out what is going on regardless :+1:

eteran commented 6 years ago

Just out of curiosity, are you launching it via the client/server? It's a mode that I don't personally use much so it doesn't get tested as often.

ahmedo15 commented 6 years ago

Do you ask if I launch the program "nc-ng" instead of "nedit-ng"? The answer is no. I'm using nedit-ng.

By thd way I have tested your suggestion: "Also, have you tried (just as a test), some window managers let you hold down ALT to left click a window and drag it even regardless of whether or not you're clicking the title bar (useful for windows half off the screen).". Thanks for the tip, I'm able to move the windows by holding down ALT and clicking left on the windows title bar and then dragging it.

ahmedo15 commented 5 years ago

Hello,

I think that the issue is coming from these lines in the function void MainWindow::parseGeometry(QString geometry) in file MainWindow.cpp.

const int w = extent + (fm.width(QLatin1Char('X')) * cols) + m.left() + m.right() + area->lineNumberAreaWidth();
const int h = extent + (fm.ascent() + fm.descent()) * rows + m.top() + m.bottom();

//document->setMinimumSize(w, h);
//adjustSize();

When I change them to this code, the window which appears is of small size. But, obviously, this new code isn't good as the window initial size doesn't change when I change the initial window size in nedit-ng default settings.

// NOTE(eteran): maxWidth()
const int w = extent + (fm.width(QLatin1Char('X')) * cols) + m.left() + m.right() + area->lineNumberAreaWidth();
const int h = extent + (fm.ascent() + fm.descent()) * rows + m.top() + m.bottom();
document->setMinimumSize(cols, rows);
//adjustSize();

Thanks, Ahmed

eteran commented 5 years ago

Thank you for looking into this!

I can't say that I understand why this would have the effect that you describe. The code in question is (obviously) trying to set the initial size of the window. Which is complicated... because I want the size of the text area to be a specific size, regardless of any window decorations, tabs, menus, etc...

The adjustSize() and subsequent processEvents() calls are intended to force the window to "squeeze" down to the exact size that the user wants.

I'll have to look into this further. Thank you for the input!

rnhaddad commented 5 years ago

Related to this issue, on ubuntu: VERSION="18.04.2 LTS (Bionic Beaver)"

And nedit-ng SHA 4c347b96bab2dade4229a69b52c707911e2d9ae8 If the -geometry width (or initial window settings) is > 75 e.g. 80x50, AND using nedit-ng to open a file e.g. nedit-ng -geometry 80x50 test.txt (assuming the file exists), the window shrinks down to 10x5 . It works fine if the window width <75, and it works fine if using nedit-ng without a file e.g. nedit-ng &.

It is not very clear what is happening, but "75" seems to be a limit somewhere (or bug).