Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Mouse cursor not captured when triggered via global shortcut #737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sebalips opened this issue Oct 19, 2021 · 13 comments
Closed

Mouse cursor not captured when triggered via global shortcut #737

sebalips opened this issue Oct 19, 2021 · 13 comments
Assignees
Labels

Comments

@sebalips
Copy link

The mouse cursor is not captured triggered via the Print hotkey defined in KDE settings.
The option to capture the mouse cursor is set.

Steps to reproduce the behavior:

  1. Open KDE settings, navigate to Shortcuts: Application. If ksnip is present, remove it, press apply, Otherwise Press "Add Application" and choose ksnip (see attached screenshot)
  2. Assign a key to "Capture a fullscreen", e.g. Print
  3. Press assigned key
  4. ksnip opens, mouse cursor not captured

The mouse cursor is captured if ksnip is started from console.

Desktop (please complete the following information):

  • OS: Debian 11, X11
  • Distribution in case of Linux : MX Linux 21 RC 1
  • Window System in case of Linux: X11
  • ksnip version: 1.9.1
  • How did you install ksnip: preinstalled and via apt

grafik

@sebalips sebalips added the bug label Oct 19, 2021
@DamirPorobic
Copy link
Member

Thanks for reporting.

@DamirPorobic DamirPorobic changed the title Mouse cursor not captured Mouse cursor not captured when triggered via global shortcut Oct 21, 2021
@DamirPorobic DamirPorobic self-assigned this Oct 21, 2021
@DamirPorobic
Copy link
Member

Can you check if this is fixed in the latest continuous build?

@sebalips
Copy link
Author

Tester Version:
Version: 1.10.0-continuous
Build: 1-ca53637

Option to include mouse pointer is set in image grabber setting.
Taking the screenshot with ksnip shortcuts Shift+L,F,M,A and global shortcuts set in options global shortcuts, captures the mouse pointer at correct position.

But using shortcuts set in KDE Settings - Shortcuts, does not capture the mouse pointer.
Settings are like in this screenshot:
grafik

If ksnip is opened via Hotkey from Tray, no screenshot is taken. Is this expected?

My system configuration:
System: MX Linux 21 RC 1
Host: Kernel: 5.10.0-9-amd64 x86_64 bits: 64 compiler: N/A
parameters: BOOT_IMAGE=/boot/vmlinuz-5.10.0-9-amd64
root=UUID= ro quiet splash
Desktop: KDE Plasma 5.20.5 wm: kwin_x11 dm: SDDM
Distro: MX-21_KDE_RC1_x64 Wildflower October 5 2021
base: Debian GNU/Linux 11 (bullseye)

@DamirPorobic
Copy link
Member

Yes, I've suspected already that it only affects does KDE global shortcuts. The config for them comes from ksnip's desktop file, in there the command executes was a simple ksnip -m but for the cursor to be included you would need to call ksnip -m -c, that's what I did, I've changed the command in the desktop file. The issue could that you either didn't get the desktop file or our mouse capture via command line is broken.

Can you try to find locally on your system a file called org.ksnip.ksnip.desktop and see the capture cursor option is set, like here:
image

Also, can you try running ksnip from command line with ksnip -m -c and see if the mouse cursor is captured?

@DamirPorobic
Copy link
Member

If ksnip is opened via Hotkey from Tray, no screenshot is taken. Is this expected?

How do you mean? Doesn't sound right though.

@sebalips
Copy link
Author

If ksnip is opened via Hotkey from Tray, no screenshot is taken. Is this expected?

How do you mean? Doesn't sound right though.

By default the "use tray icon" option is set. If the Print key is configured just to start ksnip (what is was on my installation by default) no screenshot is taken if ksnip was running before and is now in the task bar, even if the option "Take screenshot on start" is set. IMHO this is a bad user experience.

@DamirPorobic
Copy link
Member

Can you write the steps to reproduce that? I'm not sure that I understand how "use tray icon" is related to this scenario and how you got print key to just start ksnip without taking screenshots.

@sebalips
Copy link
Author

sebalips commented Oct 22, 2021

Yes, I've suspected already that it only affects does KDE global shortcuts. The config for them comes from ksnip's desktop file, in there the command executes was a simple ksnip -m but for the cursor to be included you would need to call ksnip -m -c, that's what I did, I've changed the command in the desktop file. The issue could that you either didn't get the desktop file or our mouse capture via command line is broken.

Can you try to find locally on your system a file called org.ksnip.ksnip.desktop and see the capture cursor option is set

Also, can you try running ksnip from command line with ksnip -m -c and see if the mouse cursor is captured?

To my surprise, the screenshot today was captured correct with mouse pointer when using the global shortcut :-)

I also found the file org.ksnip.ksnip.desktop. It's in /usr/share/applications/
The content is fine, like this

[Desktop Action FullScreen]
Exec=ksnip -m -c

The reason why it did not work in the first try is, the content of this file is only read during login. And after installing the test version 1.10 this file was obviously not reread and thus executed without the -c flag.

The downside of this solution to put the -c flag in this file is, that if you switch the flag in the settings dialog to not capture the mouse cursor, it will not behave like you expect (tried it). And since this file is only read during login, its not an option to dynamically update it according to settings.
To solve this I would suggest, to make a new flag e.g. -s that captures the mouse cursor depending on the settings made in the GUI and write this command with -s flag into the .desktop file.
What do you think?

@DamirPorobic
Copy link
Member

The downside of this solution to put the -c flag in this file is, that if you switch the flag in the settings dialog to not capture the mouse cursor, it will not behave like you expect (tried it).

It depends on what you expect, the desktop file uses the command line flags to trigger a screenshot so you either set it or not, it's detached from the GUI.

To solve this I would suggest, to make a new flag e.g. -s that captures the mouse cursor depending on the settings made in the GUI and write this command with -s flag into the .desktop file.
What do you think?

I think it's problematic from a expectation point of view because you would selectively pick some config from the GUI (capture cursor, delay maybe) and some from CLI (what type of screenshot you want). It doesn't feel right to be honest.

Using ksnip's global hotkeys would work as you expect, why don't use them?

Also, I was thinking about making triggering the actions from CLI possible, then you could configure action like you need them and call them by their name from the CLI. But that would not be part of the desktop file though. However, you can modify your desktop file locally as you prefer.

@sebalips
Copy link
Author

I just wanted do give a hint so other users would find this nice tool helpful and not go into the same trap than I did when using it in KDE whit the shortcurs set in KDE settings.

When using it with KDE it is configured via the KDE settings. If you change settings in the GUI like want to capture the Mouse pointer for whatever you do, people would go into the same trap than I did. The GUI setting does not do (in there point of view) what they expect. So I suggested to make a new flag that can be used in the desktop file and takes the GUI settings into account. I see nothing problematic there, its just user friendly.
If you want to use the CLI you can still do it.

I think it's problematic from a expectation point of view because you would selectively pick some config from the GUI (capture cursor, delay maybe) and some from CLI (what type of screenshot you want). It doesn't feel right to be honest.

The program is driven by CLI, so what can't be none else? I only mean an CLI flag that is used in the desktop file.

However, you can modify your desktop file locally as you prefer.

Of cause, I could edit the files on my side, but thats not my intension, thats not why I wrote this report here. I would think, the average KDE user will use it by the Print shortcut defined via the settings dialog and not via the global hotkey defined in the ksnip settings.

@DamirPorobic
Copy link
Member

I only mean an CLI flag that is used in the desktop file.

Well that's the thing, there is no "desktop file only" command, if you add it, it's available everywhere.

What we could do is add two new command line options, one for delay and one for cursor, when set will take the setting from config for cursor and/or delay, respectively and ignore the one passed (or not passed via command line).

Or, we could change the desktop file to use the dbus interface when we implement dbus support for ksnip, that's also how Spectacle is called through the desktop file. For this one we would need to implement the dbus support first but that shouldn't be so complex I think.

Anyways, both would not come with the next path, this one is just for bug fixes, I would have to ask you to log a new feature request for the first one or add a comment to the dbus feature request with your expectation #323.

@sebalips
Copy link
Author

Well that's the thing, there is no "desktop file only" command, if you add it, it's available everywhere.
Of cause, but I don't see a problem with this.

What we could do is add two new command line options, one for delay and one for cursor, when set will take the setting from config for cursor and/or delay, respectively and ignore the one passed (or not passed via command line).

That would be great, exactly what I thought. Please do it like this (if you don't want to go with the dbus).

Or, we could change the desktop file to use the dbus interface

I also considered this but did not suggest because of the effort it makes.

Anyways, both would not come with the next path, this one is just for bug fixes
That's a pity.

@DamirPorobic
Copy link
Member

Let's go with the DBus for now, it's easier for me and capacity wise I'm totally behind the feature requests that keep pilling up. For now the cursor is captured so I'll be closing this issue as I'm releasing 1.9.2 soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants