How does vim detect and handle mouse scroll when started in XTerm? - unix

Is there an app that can handle mouse scroll in xterm, other than vim? I wanted to scroll man pages and less won't handle mouse scroll but why is it that vim can? Is this because of curses?

Curses does infact have mouse support. If I remember right wheel-up is button 4 and wheel-down is button 2. It may be system / terminal dependent, I'm not sure.
As for what other apps make use of this feature, midnight commander and ranger come to mind.

Related

how to disable the scroll function when I use the tmux?

Tmux uses the scroll to find the history commands which bothers me too much.
How to disable this function? I have tried to use "set mouse on", but it gives me another problem. I just want to disable my mouse all the time, with the scroll leaves its original usage.
Tmux no longer has multiple options for mouse mode, there is just mouse on or off (assuming a recent version of tmux).
If you want to use the mouse, including the scroll wheel, for anything except scrolling history, mouse mode must be on (set -g mouse on). Turning on the mouse should not prevent you from not using your mouse to accomplish things; the default tmux key functionality remains.

tmux use mouse only to resize panes

In new versions of tmux, I know that I can use set -g mouse on to enable mouse support in order to be able to resize panes with the mouse.
But it also enable a feature that I do not want which is using copy mode when I select text in the terminal. In that way I am no more able to copy text in the system clipboard in order to paste it outside of tmux.
My question is: is there a way to enable resizing panes with the mouse, which very handy, without having to enable mouse support for other things?
Because there in no answer, I will try to answer myself:
Apparently there is no way to do this, since when a mouse event is intercepted by tmux, it cannot be forwarded to the system. I say this but it is pure deduction, I have no knowledge about that.
As an alternative, there is a way to prevent tmux to intercept the mouse, by holding a key like "fn" on Mac OS.

hide system cursor in system wide

I want to hide system cursor for 10s for some reason ,but I found
cursor.setShape(Qt.BlankCursor)
can only hide mouse cursor that is associated with QWidgets ,not in system wide ,i.e. when mouse cursor is hovering on QWidgets, it is invisible ,otherwise it is visible ,so is there any way to hide system cursor in system wide?
The win32 system call ShowCursor works per-window only. You can access this from either ctypes or pywin32's win32api. But apparently the cursor drawing is controlled by display driver and can only be affected by specific windows. You can't force another window to hide its cursor. Two options:
use ShowCursor(False) on your window, and for the display background, create a root window application that you spawn from your GUI app, it hides cursor; your app would cause it to exit after 10 seconds, but again if user moves mouse over other app windows they will see cursor.
make your application a root window application; then while in view, ShowCursor(False) will make cursor disappear everywhere on screen except system toolbar (which is a good thing).
I don't think it is a good idea anyways; what if your app crashes while the mouse is hidden? Then user can't use their desktop easily. Definitely good reason that this is not allowed.
Best approach is to think of a different solution to whatever problem led you to try cursor hiding.

Mouse button status

From what I see, QApplication::mouseButtons() may return no buttons even when a button is held down. This happens when you have clicked a side of a window for re-sizing. It's coherent with the docs because mouseButtons() reflects the state from the flow of QEvent::mouseButtonPress, etc. However, I need just to know if the button is held down. Does any one know if it's possible through the Qt API?
I think it's not possible. Mouse events outside an application's window are not passed to its event handlers. Dragging mouse borders is one of such events, it's processed by the window system. Another example is clicking on other windows. Usually an application doesn't know what the user does with other windows. You need to install system-wide event listener or use native API features(e.g. GetAsyncKeyState on Windows) to determine that. This behavior is unusual and possibly dangerous. In most cases it's not useful, and it seems that Qt doesn't have this ability.

ddd gets inactive when mouse is moved out of its window

My ddd window doesn't take any keyboard input when my mouse cursor is moved out of the window. Although ddd window is still active, but it doesn't take any inputs. I will have to move my mouse over its window to make it work again. Is there a way to configure it in a way that it takes the input no matter where the mouse pointer is, just like any other X window, xterm for example.
I had the same problem; DDD behaved like focus-follows-mouse, when all other windows (and the setting in gnome) was click-to-focus. This was in DDD 3.3.11.
For me, it (mostly) works now, after I changed "Keyboard focus" to "Click to type" in the Preferences, Startup tab.
If ddd implements some sort of follow-focus itself instead of relying on the window manager, I am afraid that it's not going to be easy to prevent it. The good news is that ddd doesn't do anything very smart, it's just a front-end for real debuggers (say, gdb). So if you don't find any way to fix it, you can easily switch to any other front-end (say, Emacs).
Your are under unix, right? That depends on your window manager. The current behavior is called "focus follow mouse."
OTOH, the commenter is right to point out that if DDD is the only program showing this problem, it might be something else. One idea is to turn of some tool auto raise magic, as indicated in the manual.

Resources