Skip to content
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

Pointer mode (Zoom) changes on double click (same behavior as of official software) #54

Closed
wants to merge 15 commits into from

Conversation

mayanksuman
Copy link
Contributor

@mayanksuman mayanksuman commented Nov 17, 2019

The Zoom is toggled if user double tap the pointer (top most) button (within 300ms; can be changed as it is part of Setting).

A major redesign of events handling has occurred. As it was necessary that the double click (and associated two clicks) events should not be passed to presentation so projecteur now grabs the input from SpotLight device. However, all other events (except Mouse Click) is passed again to the system by using uinput interface. The current redesign can help in giving solution to #43 without using a custom bash script.

Double Click is not passed to system rather used for changing the mode of presenter (toggling Zoom Setting). This is same behaviour as official software.

Further Work: To introduce the third mode (Digital Laser) and additionally the provision for different options/setting for each of the mode.

@mayanksuman mayanksuman changed the title Presenter mode (Zoom) changes on double click (same behavior as of official software) Pointer mode (Zoom) changes on double click (same behavior as of official software) Nov 18, 2019
@jahnf
Copy link
Owner

jahnf commented Nov 18, 2019

Thanks for the pull request. 👍
We can also reuse grabbing the device for key assignment later (later == please keep pull requests small focused on one feature/fix)

While the idea of predefined spotlight settings (you call it pointer modes) is good,
I don't necessarily want to do the same as the official software - why just copy everything?

Code Review follows probably tonight. (Central European Time)

@mayanksuman
Copy link
Contributor Author

A clarification: predefined spotlight settings does not mean hardcoded. I want to provide user the option that they can define three different set of settings -- Highlight, SpotLight(Zoom) and Digital Laser. The mode can customized by user.

No, We are not copying everything. The idea of customized key event on Next/Back press is unique to Projecteur. However, I do not want that the users of Projecteur feel limited when compared to their experience over Win/Mac.

In a way, Projecteur will provide unique feature that is not present in official software.

Copy link
Owner

@jahnf jahnf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, so I had a quick review.
Please don't be put off comments on code style and indentation. But I like to be a bit picky here, since I really much like a code base that follows the same style (Even though I did not put up a style guide).
Your pull request is still really appreciated.

For the UInputDevice class please see comments about making it a member instead of a Singleton - I want to avoid Singletons as much as global variables. Use them only if absolutely necessary.

src/projecteurapp.cc Outdated Show resolved Hide resolved
src/settings.cc Outdated Show resolved Hide resolved
src/settings.h Outdated Show resolved Hide resolved
src/settings.h Outdated Show resolved Hide resolved
src/spotlight.cc Outdated Show resolved Hide resolved

using namespace std;

class uinputEvents;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary.

src/uinputevents.h Outdated Show resolved Hide resolved
src/uinputevents.h Outdated Show resolved Hide resolved
src/uinputevents.h Outdated Show resolved Hide resolved
src/uinputevents.cc Outdated Show resolved Hide resolved
@mayanksuman
Copy link
Contributor Author

Thanks for quick review. I will be able to resolve them in the evening (IST).

Copy link
Owner

@jahnf jahnf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See individual comments. Especially the memory leak.

@@ -87,15 +88,35 @@ namespace {
Spotlight::Spotlight(QObject* parent)
: QObject(parent)
, m_activeTimer(new QTimer(this))
, m_clickTimer(new QTimer(this))
, m_virtualDevice(new VirtualDevice)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Memory leak, object will never get destroyed. m_virtualDevice member should be of type QScopedPointer or std::unique_ptr

@@ -62,4 +66,7 @@ class Spotlight : public QObject
std::map<QString, QScopedPointer<QSocketNotifier>> m_eventNotifiers;
QTimer* m_activeTimer;
bool m_spotActive = false;
bool m_clicked = false;
QTimer* m_clickTimer;
VirtualDevice* m_virtualDevice;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Memory leak. m_virtualDevice member should be of type QScopedPointer or std::unique_ptr

class VirtualDevice{
private:
struct uinput_user_dev uinp;
static int uinp_fd;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static , should be a regular member

int uinp_fd = -1;


// Setup uinput device that can send mouse and keyboard events. Logs the result too.
void VirtualDevice::setupVirtualDevice() {
int i=0;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c-style ... remove .. use for (int i = 0; .... instead

ioctl(uinp_fd, UI_SET_RELBIT, REL_X);
ioctl(uinp_fd, UI_SET_RELBIT, REL_Y);

for (i=0; i < 256; i++) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use for (int i = 0; .... instead

src/virtualdevice.cc Outdated Show resolved Hide resolved
src/virtualdevice.cc Outdated Show resolved Hide resolved
Comment on lines +100 to +102
char msg[] = "A virtual device was not created. "\
"Some features like changing pointer modes might not work.\n\n"\
"Please check if uinput kernel module is loaded.";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't be picked up by Qt's lupdate tool.
Use const auto msg = tr("..."); and then the msg variable directly for QMessagebox

#include <linux/uinput.h>
#include <unistd.h>

#include <QDebug>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to include this in the header

class VirtualDevice{
private:
struct uinput_user_dev uinp;
int uinp_fd;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set default value

int uinp_fd = -1;

Comment on lines +62 to +66
if (ioctl(uinp_fd, UI_DEV_CREATE)) {
qDebug("Unable to create Virtual (UINPUT) device.");
deviceCreated = false;
return;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Close uinp_fd, otherwise it will not get closed.
Alternative: check in constructor if uinp_fd >= 0 and close

@jahnf
Copy link
Owner

jahnf commented Nov 18, 2019

I'd rather would merge your changes to a feature branch and then after all bugs and major issues are resolved merge it to develop . Even though it's develop I'd like it as stable as possible - and I am most likely will overlook an issue like the memory leak or sth else in a code review. I will create a feature branch , could you then please create a pull request into that new branch?

@jahnf
Copy link
Owner

jahnf commented Nov 18, 2019

Please make the pull request for feature/pointer-mode-uinput-dev instead of develop.

@mayanksuman
Copy link
Contributor Author

Ok, I am making a pull request to feature/pointer-mode-uinput-dev.

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

Successfully merging this pull request may close these issues.

None yet

2 participants