Skip to content

Commit

Permalink
Fix hide on hover
Browse files Browse the repository at this point in the history
  • Loading branch information
lsk-china committed May 19, 2023
1 parent 70c6167 commit a7c25bf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
6 changes: 3 additions & 3 deletions mouseEventThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ void MouseEventThread::processEvent(XRecordInterceptData *hook) {
if (queryCursor(relX, relY, absX, absY)) {
break;
}
emit mousePress(QPoint(relX * sensibility, relY * sensibility), QPoint(absX * sensibility, absY * sensibility));
emit mousePress(QPoint(relX * sensibility, relY * sensibility), QPoint(relX, relY));
}
break;
case ButtonRelease:
if (buttonCode == 1) {
if (queryCursor(relX, relY, absX, absY)) {
break;
}
emit mouseRelease(QPoint(relX * sensibility, relY * sensibility), QPoint(absX * sensibility, absY * sensibility));
emit mouseRelease(QPoint(relX * sensibility, relY * sensibility), QPoint(relX, relY));
}
break;
case MotionNotify:
Expand All @@ -85,7 +85,7 @@ void MouseEventThread::processEvent(XRecordInterceptData *hook) {
// qDebug() << "motion too small, ignoring...";
// break;
// }
emit mouseEvent(QPoint(relX * sensibility, relY * sensibility), QPoint(absX * sensibility, absY * sensibility));
emit mouseEvent(QPoint(relX * sensibility, relY * sensibility), QPoint(relX, relY));
break;
}
XRecordFreeData (hook);
Expand Down
6 changes: 3 additions & 3 deletions mouseEventThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public slots:
double sensibility;
// int dx, dy, lastx, lasty = 0;
signals:
void mouseEvent(QPoint relPosition, QPoint absPosition);
void mousePress(QPoint relPosition, QPoint absPosition);
void mouseRelease(QPoint relPosition, QPoint absPosition);
void mouseEvent(QPoint relPosition, QPoint rawPosition);
void mousePress(QPoint relPosition, QPoint rawPosition);
void mouseRelease(QPoint relPosition, QPoint rawPosition);
};


Expand Down
18 changes: 6 additions & 12 deletions widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ void Widget::live2dInitialized(QLive2dWidget *wid) {
wid->setModel(this->currentConfiguration.getModelName().toStdString());
this->initialized = true;
}
void Widget::mouseEvent(QPoint rel, QPoint abs) {
void Widget::mouseEvent(QPoint rel, QPoint raw) {
//cout<<"rel: "<<rel.x()<<", "<<rel.y()<<endl;
//cout<<"abs: "<<abs.x()<<", "<<abs.y()<<endl;
//cout<<"abs: "<<raw.x()<<", "<<raw.y()<<endl;
widget->mouseMove(rel);
//widget->mouseMove(rel);
if (this->currentConfiguration.isHideOnHover()) {
if (widget->geometry().contains(rel) && widget->isVisible()) {
if (widget->geometry().contains(raw) && widget->isVisible()) {
widget->hide();
}
if (!widget->geometry().contains(rel) && !widget->isVisible()) {
if (!widget->geometry().contains(raw) && !widget->isVisible()) {
widget->show();
}
}
Expand All @@ -122,10 +122,7 @@ void Widget::setWidgetPosition(bool widgetOnLeft) {
}
}

void Widget::mousePress(QPoint rel, QPoint abs) {
if (!this->widget->isVisible()) {
return;
}
void Widget::mousePress(QPoint rel, QPoint raw) {
if (this->widget->geometry().contains(rel)) {
if (this->currentConfiguration.isHideOnHover()) {
this->widget->mousePress(QPoint(rel.x(), this->height() - rel.y()));
Expand All @@ -136,10 +133,7 @@ void Widget::mousePress(QPoint rel, QPoint abs) {
}
}

void Widget::mouseRelease(QPoint rel, QPoint abs) {
if (!this->widget->isVisible()) {
return;
}
void Widget::mouseRelease(QPoint rel, QPoint raw) {
if (this->widget->geometry().contains(rel)) {
if (this->currentConfiguration.isHideOnHover()) {
this->widget->mouseRelease(QPoint(rel.x(), this->height() - rel.y()));
Expand Down

0 comments on commit a7c25bf

Please sign in to comment.