wxwidgets detect mouse click on another window - linux

Is it possible to detect a double click on another window in wxwidgets?
In my quest to switch to linux I wanna build a program that reacts to double click on the desktop and the file manager and displays a menu.
Same as listary does on Windows.
Is this something that can be done with wxwidgets (preferably wxpython) under linux? What about on Windows?

You can't receive mouse clicks, or any other events, for windows of another process unless you capture the mouse (and never release it, which would be a bad idea).

You can try to use FindWindow() and then Bind() the event handler.

Related

How to bind keyboard shortcut to run command on selected file in linux?

I know how to set a keyboard command shortcut, that's easy, I just go to Applications > Settings > Keyboard and then click the Application Shortcuts tab within my Manjaro Linux system and set whatever command to whatever shortcut.
But how can I make it run that command on a selected file or selection of files?
Is there something I can change or add to the command to make it run on the file or files currently selected within my XFCE desktop environment?
Thanks!
Your approach would require to correlate your mouse position to your desktop and file-manager. Then you would need to have knowledge of the internal state. You then would need to display some GUI. This way of thinking in regards of programing is seriously wrong.
What you are looking for are context menu actions. So keep it that way.
You have files on your desktop or in the file-manager and can call user defined actions on one or more files. I think XFCE had something like Thunar. You may use caja wit caja --no-desktop and create some actions with caja-actions-config-tool. Gnome still has it, if you prefer Nautilus.

How to bring an application to the front with picoe/Eto on Mac OSX?

I want to minimize the main window of a C#/Eto app and switch to another program. But when a timer in the Eto app fires it opens a new window, which I want to see. It should be displayed on top of all other windows currently open. The focus may switch to that window, but it's ok if not.
Using BringToFront() of the Form class does not work.
What else could I do?
Due to the way Apple made OS X, you are unable to make a window go to the top with programming. On Windows it is different.
Good luck!

Detect mouse and keyboard events on TravisCI

I've been working on a native Node.js module called RobotJS that allows the user to automate the mouse and keyboard. I've been trying to find a way to automate testing for keyboard and mouse events. For example, I need to be able to confirm that RobotJS is sending the correct keycodes, like "a" and "!". And I need to be able to detect mouse clicks.
I got this working locally using the terminal, here is the code to detect mouse clicks:
https://github.com/octalmage/robotjs/blob/keyboard-tests/test/detectMouse.js
But it doesn't work on TravisCI. I imagine because they don't open an actual terminal window, even though I start xvfb and can detect mouse movement.
I considered writing a new application using Electron to open a window to detect the events, but I'd rather not if I could get my current tests to work.
Thoughts? Here's my current .travis.yml:
https://github.com/octalmage/robotjs/blob/master/.travis.yml
And here's the projects GitHub:
https://github.com/octalmage/robotjs

How do I make a window move to the top of other windows in Gnome when that window already has the focus?

I have an application that sends the focus to other windows but those windows then don't automatically display themselves in the foreground, i.e. on top of all the other windows. Where can I configure the preferences of my window manager so that this is the default behaviour?
In particular I'm using the Ctrl-0 and Ctrl-Shft-0 shortcuts in the MATLAB IDE to move between the command window and the editor window and although the focus seems to be transferred the new window doesn't automatically redraw itself in the foreground.
Not sure of a key binding off hand that does it, but if you alt-click on a window (which allows you to drag a window) it should come to the front.
As codeDr suggests, MATLAB is also kind of bad about repainting its windows. If you draw to a figure while code is executing, the figure does not update unless you execute drawnow or have some similar pause in the execution to allow the GUI to repaint. Since we're talking about MATLAB, the figure command will also cause the indicated figure to come to the front (in fact, it's harder to get it to not come to the front). So you could do figure(gcf) to bring the current figure to the front, or save the figure number with h = figure; and then later do figure(h). Incidentally, if you want to switch current figures without switching focus, set(0, 'CurrentFigure', h) should set h to the current figure.
Your window manager (probably Metacity?) implements focus-stealing prevention so that rogue apps don't pop up windows that would disturb your typing. Matlab needs to raise its window, and give it the input focus with the correct timestamp. If this is being done from a KeyPress event handler, the timestamp for setting the input focus would be the timestamp from the KeyPress event (i.e. the timestamp of the user-generated event that caused a window to be raised/focused).
To politely give the input focus to a window, google for _NET_ACTIVE_WINDOW.
Usually when the window doesn't repaint, it means that the application's main application loop isn't running to refresh the window. Could it be that Matlab is doing some computation or disk activity when you are switching between windows?

How to change focus in X-Windows?

I am working on old Motif-based application for Linux. I want to be able to programmatically change the active window of our application. I can redirect the input by using XSetInputFocus() function and the keyboard input start to go there, but XReconfigureWMWindow() and XRaiseWindow() functions just don't work.
I've read that Window Managers try to stop this behaviour, so tried to disable configure redirection, but this doesn't work either. Any ideas how to make one of my own windows on top of the window stack?
There is a tiny program called wmctrl available (at least in Debian/Ubuntu it is in standard distribution) which is able to perform many operations on windows and desktops, and handles plenty of window managers. I'd suggest testing whether it works in your environment, and if so, peeking at its sources.
You may find the answer to this is dependent on the Window Manager the user is using, or even what settings they've given to the Window Manager. I like to set my Window Managers to do "focus follows mouse", which means you can't send the focus to a window that I haven't put my mouse on, unless you also warp the mouse there (is that function called XWarpMouse?).

Resources