ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
has focus (icon)
loop
on key-press event.
if match
trigger app.
can it be done, ???? donno..
Otherwise it'd have to be a big loop that has to have access to the desktop to capture keystrokes. You might be able to just give a keyboard SC for whatever desktop you're using the command to fire off an app. that'd be what I'd do. and forget about programming anything to do with that icon doing it.
// Main Program
int main(int argc, char **argv)
{
gtk_init(&argc, &argv);
setlocale( LC_ALL, "" );
bindtextdomain( "refresh_my_desktop", "/usr/share/locale" );
textdomain( "refresh_my_desktop" );
tray_icon = create_tray_icon();
gtk_main();
return 0;
}
I know I could implement this also into the window manager (openbox, jwm etc.), but I don't want to. I want to have a binary sitting in the system tray waiting for my keyboard short-cut.
I want to have a binary sitting in the system tray waiting for my keyboard short-cut.
that logic itself is in error. binaries do not sit on the system tray, they are kept elsewhere within the system, for one.
two the system is not written as such to operate as such.
The icon button is used as a mechanism to call a binary or script to preform an action.
you do understand the concept of , "has focus" and how that is obtained? Mostly by a mouse cursor, and if a mouse cursor is needed to be used to gain focus on an object, say an icon that if pressed starts an application, then having to move this cursor over top of the icon to gain focus by using ones hand, what is to stop them from just clicking the mouse button to start the application? Instead of moving the mouse cursor over top of the icon then removing ones hand from that mouse unto the keyboard then hitting the keys required to start the app?
Why not just click the icon instead?
I do hope you see what I am getting at here.
Actually sit there and (re)think out the steps required to preform the operation. Frist to start an app that the icon belongs to using a mouse, and then a keyboard.
I am not trying to discourage you from programming, just trying to nudge you over some to applying a little more logical thought to it while you're programming.
look into events - ie HasFocus event if you still find yourself needing to go down that road. I do not know the exact function call. but yeah... search.. GTK and keyboard shortcuts.
The object has to have focus in order to talk to it. Unless it is hard coded to preform an action within itself.
what you are asking to do. You would still have to go through the desktop to remove focus on whatever has focus then put that onto your button.
this requires finding out what has focus first. then removing it. how does one find out what has focus?
you would need to ask the desktop manager what has focus then request to remove that focus from the object that has it and give it to that button.
think about, and find out what actions need to be preform in order to obtain a line of communication with your desktop using a keyboard.
that logic itself is in error.binaries do not sit on the system tray, they are kept elsewhere within the system, for one.
Darn, this is kind of "hair splitting" (literally tranlsated from "Haare spalten") and not really of any kind of help!
Quote:
Why not just click the icon instead?
I do hope you see what I am getting at here.
Actually sit there and (re)think out the steps required to preform the operation. Frist to start an app that the icon belongs to using a mouse, and then a keyboard.
Ok, probably I should have mentioned what I want to achieve.
My problem is to NOT to find the mouse cursor on the screen after a long period of not using it. So I want to hit a keyboard short-cut to make the mouse "visible" for my poor eye-light. Therefor I have a small bash program that pops up on the position of the mouse offering a ca. 48 pixel sized GUI to click simply out of the way after finding the mouse cursor.
So, I just CAN'T use the mouse to click that ICON of the binary in the system tray.
Darn, this is kind of "hair splitting" (literally tranlsated from "Haare spalten") and not really of any kind of help!
Ok, probably I should have mentioned what I want to achieve.
My problem is to NOT to find the mouse cursor on the screen after a long period of not using it. So I want to hit a keyboard short-cut to make the mouse "visible" for my poor eye-light. Therefor I have a small bash program that pops up on the position of the mouse offering a ca. 48 pixel sized GUI to click simply out of the way after finding the mouse cursor,
So, I just CAN'T use the mouse to click that ICON of the binary in the system tray.
I hope it's fully explained now.
Sorry for any confusion...
so you've already have a script/program that when executed shows you where the mouse cursor is. I'd still attach that to the keyboard itself via the desktop shortcut menu.
because of the limitations or design of an application has to have focus in order for it to do what it needs to do within a windowed environment, to my knowledge.
The window manager keeps track of what has focus. It can be keyboard, or mouse driven. If keyboard driven then it is the desktop that takes care of it, mouse driven then it is through the mouse cursor, but still the desktop keeps track of the mouse position.
here are two links that deal with this issue of showing mouse cursor.
For now I'm using another mouse cursor type which is some bigger and I changed my wallpapers. Probably I decide to include this into the window managers .xml files.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.