Commit 0e6c4ce7 authored by Christoffer Ackelman's avatar Christoffer Ackelman

QT: Fixed Proviews fake double click.

parent 03e7bfab
......@@ -92,7 +92,7 @@ static char font_names[draw_eFont__][DRAW_FONT_SIZE][80]
"-*-Helvetica-Medium-R-Normal--18-*-*-*-P-*-ISO8859-1",
"-*-Helvetica-Medium-R-Normal--24-*-*-*-P-*-ISO8859-1" } };
static QEvent last_event(QEvent::None);
static QMouseEvent *last_event;
static QColor flow_allocate_color(
FlowDrawQt* draw_ctx, const char* named_color);
......@@ -409,7 +409,6 @@ int FlowDrawQt::event_handler(QEvent* event)
if (click_sensitivity & flow_mSensitivity_MB1Click
&& !(click_sensitivity & flow_mSensitivity_MB1DoubleClick)
&& !(click_sensitivity & flow_mSensitivity_MB1Press)) {
memcpy((void*)&last_event, (void*)&event, sizeof(QEvent));
button_pressed = 0;
button_clicked = 1;
last_press_x = mouseEvent->x();
......@@ -418,7 +417,6 @@ int FlowDrawQt::event_handler(QEvent* event)
} else if (!(click_sensitivity & flow_mSensitivity_MB1Click)
&& !(click_sensitivity & flow_mSensitivity_MB1DoubleClick)
&& click_sensitivity & flow_mSensitivity_MB1Press) {
memcpy((void*)&last_event, (void*)&event, sizeof(QEvent));
button_pressed = 1;
button_clicked = 0;
last_press_x = mouseEvent->x();
......@@ -431,7 +429,6 @@ int FlowDrawQt::event_handler(QEvent* event)
if (click_sensitivity & flow_mSensitivity_MB2Click
&& !(click_sensitivity & flow_mSensitivity_MB2DoubleClick)
&& !(click_sensitivity & flow_mSensitivity_MB2Press)) {
memcpy((void*)&last_event, (void*)&event, sizeof(QEvent));
button_pressed = 0;
button_clicked = 1;
last_press_x = mouseEvent->x();
......@@ -440,7 +437,6 @@ int FlowDrawQt::event_handler(QEvent* event)
} else if (!(click_sensitivity & flow_mSensitivity_MB2Click)
&& !(click_sensitivity & flow_mSensitivity_MB2DoubleClick)
&& click_sensitivity & flow_mSensitivity_MB2Press) {
memcpy((void*)&last_event, (void*)&event, sizeof(QEvent));
button_pressed = 1;
button_clicked = 0;
last_press_x = mouseEvent->x();
......@@ -467,21 +463,20 @@ int FlowDrawQt::event_handler(QEvent* event)
button_clicked_and_pressed = 1;
cancel_event_timer();
button_clicked = 0;
memcpy((void*)&last_event, (void*)&event, sizeof(QEvent));
button_pressed = mouseEvent->button();
last_press_x = mouseEvent->x();
last_press_y = mouseEvent->y();
event_timer(200);
event_timer(mouseEvent);
return 1;
}
if (!button_pressed) {
memcpy((void*)&last_event, (void*)&event, sizeof(QEvent));
button_pressed = mouseEvent->button();
last_press_x = mouseEvent->x();
last_press_y = mouseEvent->y();
event_timer(200);
event_timer(mouseEvent);
return 1;
} else {
debug_print("event_handler: MouseButtonPress from timer\n");
/* Press event, callback from timer */
button_pressed = 0;
button_clicked_and_pressed = 0;
......@@ -607,9 +602,8 @@ int FlowDrawQt::event_handler(QEvent* event)
cancel_event_timer();
if (!button_clicked_and_pressed) {
/* wait for button double click */
memcpy((void*)&last_event, (void*)&event, sizeof(QEvent));
button_clicked = 1;
event_timer(200);
event_timer(mouseEvent);
button_pressed = 0;
return 1;
} else {
......@@ -690,8 +684,7 @@ int FlowDrawQt::event_handler(QEvent* event)
}
case QEvent::MouseMove: {
QMouseEvent* mouseEvent = ((QMouseEvent*)event);
debug_print("event_handler: MouseMove\n");
QPoint pos = QCursor::pos();
QPoint pos = mouseEvent->pos();
if (button3_pressed) {
button3_pressed = 0;
......@@ -1642,7 +1635,7 @@ bool FlowDrawQt::event_timer_cb()
{
delete timer_id;
timer_id = 0;
event_handler(&last_event);
event_handler(last_event);
return FALSE;
}
......@@ -1654,12 +1647,17 @@ void FlowDrawQt::cancel_event_timer()
}
}
void FlowDrawQt::event_timer(int time_ms)
void FlowDrawQt::event_timer(QMouseEvent *event)
{
if (last_event) {
delete last_event;
}
last_event = new QMouseEvent(event->type(), event->pos(), event->globalPos(), event->button(), event->buttons(), event->modifiers());
timer_id = new QTimer();
timer_id->setSingleShot(true);
connect(timer_id, SIGNAL(timeout()), this, SLOT(event_timer_cb()));
timer_id->start(time_ms);
timer_id->start(200);
}
void FlowDrawQt::set_timer(
......
......@@ -258,7 +258,7 @@ private:
int x, int y, char* text, int len);
void cursor_helper(FlowCtx* ctx, draw_eCursor cursor, bool nav = false);
void event_timer(int timer_ms);
void event_timer(QMouseEvent *event);
void cancel_event_timer();
flow_draw_sTimerCb* timer_cb;
......
......@@ -58,6 +58,7 @@ void QtScrollWidgetFlow::init(unsigned int eCtxType,
{
createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
setMouseTracking(true);
this->ctxType = eCtxType;
this->init_proc = init_proc;
this->init_widget_proc = init_proc2;
......@@ -70,6 +71,7 @@ QWidget* QtScrollWidgetFlow::initScroll(unsigned int eCtxType,
{
createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
setMouseTracking(true);
this->ctxType = eCtxType;
this->init_proc = init_proc;
this->init_widget_proc = init_proc2;
......@@ -91,6 +93,7 @@ void QtScrollWidgetFlow::init(unsigned int eCtxType, QWidget* main)
{
createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
setMouseTracking(true);
this->ctxType = eCtxType;
is_navigator = 1;
main_widget = main;
......
......@@ -140,7 +140,7 @@ static char font_names[glow_eFont__][glow_eDrawFont__][DRAW_FONT_SIZE][80] = {
"-*-courier-Medium-R-Normal--24-*-*-*-m-*-ISO8859-1" } }
};
static QEvent last_event(QEvent::None);
static QMouseEvent *last_event;
static QColor glow_allocate_named_color(
GlowDrawQt* draw_ctx, const char* named_color);
......@@ -489,7 +489,6 @@ int GlowDrawQt::event_handler(QEvent* event)
if (click_sensitivity & glow_mSensitivity_MB1Click
&& !(click_sensitivity & glow_mSensitivity_MB1DoubleClick)
&& !(click_sensitivity & glow_mSensitivity_MB1Press)) {
memcpy((void*)&last_event, (void*)&event, sizeof(QEvent));
button_pressed = 0;
button_clicked = 1;
last_press_x = mouseEvent->x();
......@@ -498,7 +497,6 @@ int GlowDrawQt::event_handler(QEvent* event)
} else if (!(click_sensitivity & glow_mSensitivity_MB1Click)
&& !(click_sensitivity & glow_mSensitivity_MB1DoubleClick)
&& click_sensitivity & glow_mSensitivity_MB1Press) {
memcpy((void*)&last_event, (void*)&event, sizeof(QEvent));
button_pressed = 1;
button_clicked = 0;
last_press_x = mouseEvent->x();
......@@ -518,7 +516,6 @@ int GlowDrawQt::event_handler(QEvent* event)
} else if (click_sensitivity & glow_mSensitivity_MB3Click
&& !(click_sensitivity & glow_mSensitivity_MB3DoubleClick)
&& !(click_sensitivity & glow_mSensitivity_MB3Press)) {
memcpy((void*)&last_event, (void*)&event, sizeof(QEvent));
button_pressed = 0;
button_clicked = 1;
last_press_x = mouseEvent->x();
......@@ -536,19 +533,17 @@ int GlowDrawQt::event_handler(QEvent* event)
button_clicked_and_pressed = 1;
cancel_event_timer();
button_clicked = 0;
memcpy((void*)&last_event, (void*)&event, sizeof(QEvent));
button_pressed = mouseEvent->button();
last_press_x = mouseEvent->x();
last_press_y = mouseEvent->y();
event_timer(200);
event_timer(mouseEvent);
return 1;
}
if (!button_pressed) {
memcpy((void*)&last_event, (void*)&event, sizeof(QEvent));
button_pressed = mouseEvent->button();
last_press_x = mouseEvent->x();
last_press_y = mouseEvent->y();
event_timer(200);
event_timer(mouseEvent);
return 1;
} else {
/* Press event, callback from timer */
......@@ -694,9 +689,8 @@ int GlowDrawQt::event_handler(QEvent* event)
cancel_event_timer();
if (!button_clicked_and_pressed) {
/* wait for button double click */
memcpy((void*)&last_event, (void*)&event, sizeof(QEvent));
button_clicked = 1;
event_timer(200);
event_timer(mouseEvent);
button_pressed = 0;
return 1;
} else {
......@@ -780,7 +774,7 @@ int GlowDrawQt::event_handler(QEvent* event)
}
case QEvent::MouseMove: {
QMouseEvent* mouseEvent = ((QMouseEvent*)event);
QPoint pos = QCursor::pos();
QPoint pos = mouseEvent->pos();
if (button3_pressed) {
button3_pressed = 0;
......@@ -1597,10 +1591,9 @@ bool GlowDrawQt::draw_timer_cb()
bool GlowDrawQt::event_timer_cb()
{
delete timer_id;
timer_id = 0;
event_handler(&last_event);
event_handler(last_event);
return FALSE;
}
......@@ -1612,12 +1605,17 @@ void GlowDrawQt::cancel_event_timer()
}
}
void GlowDrawQt::event_timer(int time_ms)
void GlowDrawQt::event_timer(QMouseEvent *event)
{
if (last_event) {
delete last_event;
}
last_event = new QMouseEvent(event->type(), event->pos(), event->globalPos(), event->button(), event->buttons(), event->modifiers());
timer_id = new QTimer();
timer_id->setSingleShot(true);
QObject::connect(timer_id, SIGNAL(timeout()), this, SLOT(event_timer_cb()));
timer_id->start(time_ms);
timer_id->start(200);
}
void GlowDrawQt::set_timer(GlowCtx* paintertx, int time_ms,
......
......@@ -272,7 +272,7 @@ private:
int image_helper(GlowWind* wind, int x, int y, int width, int height,
glow_tImImage image, glow_tPixmap clip_mask, bool d = false);
void event_timer(int time_ms);
void event_timer(QMouseEvent *event);
void cancel_event_timer();
glow_draw_sTimerCb* timer_cb;
......
......@@ -60,6 +60,7 @@ void QtScrollWidgetGlow::init(unsigned int eCtxType,
{
createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
setMouseTracking(true);
this->ctxType = eCtxType;
this->init_proc = init_proc;
this->init_widget_proc = init_proc2;
......@@ -72,6 +73,7 @@ QWidget* QtScrollWidgetGlow::initScroll(unsigned int eCtxType,
{
createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
setMouseTracking(true);
this->ctxType = eCtxType;
this->init_proc = init_proc;
this->init_widget_proc = init_proc2;
......@@ -94,6 +96,7 @@ void QtScrollWidgetGlow::init(unsigned int eCtxType, QWidget* main)
{
createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
setMouseTracking(true);
this->ctxType = eCtxType;
is_navigator = 1;
main_widget = main;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment