Commit ca677962 authored by Christoffer Ackelman's avatar Christoffer Ackelman

Fixed scroll widgets event handling.

parent d26c7731
...@@ -320,15 +320,11 @@ int FlowDrawQt::event_handler(QEvent *event) ...@@ -320,15 +320,11 @@ int FlowDrawQt::event_handler(QEvent *event)
} }
} }
if (event->type() == QEvent::KeyPress) {
debug_print("event_handler: KeyPress!\n");
}
if (windowEvent || event->type() == QEvent::KeyPress) { if (windowEvent || event->type() == QEvent::KeyPress) {
switch (event->type()) { switch (event->type()) {
case QEvent::KeyPress : { case QEvent::KeyPress : {
QKeyEvent *keyEvent = ((QKeyEvent *) event); QKeyEvent *keyEvent = ((QKeyEvent *) event);
debug_print("event_handler: KeyPress key=%d\n", keyEvent->key()); debug_print("event_handler: KeyPress key=%s\n", QKeySequence(keyEvent->key()).toString().toAscii().data());
switch (keyEvent->key()) { switch (keyEvent->key()) {
case Qt::Key_Return: case Qt::Key_Return:
......
...@@ -59,6 +59,7 @@ void QtScrollWidgetFlow::init( ...@@ -59,6 +59,7 @@ void QtScrollWidgetFlow::init(
void *client_data)) void *client_data))
{ {
createBuffer(size()); createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
this->ctxType = eCtxType; this->ctxType = eCtxType;
this->init_proc = init_proc; this->init_proc = init_proc;
this->init_widget_proc = init_proc2; this->init_widget_proc = init_proc2;
...@@ -71,12 +72,12 @@ QWidget *QtScrollWidgetFlow::initScroll( ...@@ -71,12 +72,12 @@ QWidget *QtScrollWidgetFlow::initScroll(
void *client_data)) void *client_data))
{ {
createBuffer(size()); createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
this->ctxType = eCtxType; this->ctxType = eCtxType;
this->init_proc = init_proc; this->init_proc = init_proc;
this->init_widget_proc = init_proc2; this->init_widget_proc = init_proc2;
this->client_data = client_data; this->client_data = client_data;
QScrollArea *form = new QScrollArea();
QScrollAreaFlow *form = new QScrollAreaFlow();
scroll_h = form->horizontalScrollBar(); scroll_h = form->horizontalScrollBar();
scroll_v = form->verticalScrollBar(); scroll_v = form->verticalScrollBar();
QObject::connect(scroll_h, SIGNAL(valueChanged(int)), this, QObject::connect(scroll_h, SIGNAL(valueChanged(int)), this,
...@@ -89,20 +90,10 @@ QWidget *QtScrollWidgetFlow::initScroll( ...@@ -89,20 +90,10 @@ QWidget *QtScrollWidgetFlow::initScroll(
return form; return form;
} }
bool QScrollAreaFlow::event(QEvent *event)
{
QtScrollWidgetFlow *child = ((QtScrollWidgetFlow *) widget());
time_t t;
time(&t);
if (event->type() != child->lastEvent->type() || difftime(t, child->t) > 0.000001) {
child->handleEvent(event);
}
return QScrollArea::event(event);
}
void QtScrollWidgetFlow::init(unsigned int eCtxType, QWidget *main) void QtScrollWidgetFlow::init(unsigned int eCtxType, QWidget *main)
{ {
createBuffer(size()); createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
this->ctxType = eCtxType; this->ctxType = eCtxType;
is_navigator = 1; is_navigator = 1;
main_widget = main; main_widget = main;
...@@ -266,8 +257,6 @@ bool QtScrollWidgetFlow::event(QEvent *event) ...@@ -266,8 +257,6 @@ bool QtScrollWidgetFlow::event(QEvent *event)
is_realized = true; is_realized = true;
} }
handleEvent(event); handleEvent(event);
lastEvent = event;
time(&t);
return QWidget::event(event); return QWidget::event(event);
} }
......
...@@ -59,13 +59,6 @@ typedef struct { ...@@ -59,13 +59,6 @@ typedef struct {
int scroll_v_managed; int scroll_v_managed;
} widget_sScroll; } widget_sScroll;
// QScrollArea does not forward events to its child widget
// So we subclass QScrollArea and override the event() handler
class QScrollAreaFlow : public QScrollArea {
protected:
bool event(QEvent *event);
};
class QtScrollWidgetFlow : public QWidget { class QtScrollWidgetFlow : public QWidget {
Q_OBJECT Q_OBJECT
...@@ -105,9 +98,6 @@ public: ...@@ -105,9 +98,6 @@ public:
QImage image; QImage image;
QEvent *lastEvent;
time_t t;
virtual void handleEvent(QEvent *event); virtual void handleEvent(QEvent *event);
protected: protected:
......
...@@ -59,6 +59,7 @@ void QtScrollWidgetGlow::init( ...@@ -59,6 +59,7 @@ void QtScrollWidgetGlow::init(
void *client_data)) void *client_data))
{ {
createBuffer(size()); createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
this->ctxType = eCtxType; this->ctxType = eCtxType;
this->init_proc = init_proc; this->init_proc = init_proc;
this->init_widget_proc = init_proc2; this->init_widget_proc = init_proc2;
...@@ -71,12 +72,13 @@ QWidget *QtScrollWidgetGlow::initScroll( ...@@ -71,12 +72,13 @@ QWidget *QtScrollWidgetGlow::initScroll(
void *client_data)) void *client_data))
{ {
createBuffer(size()); createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
this->ctxType = eCtxType; this->ctxType = eCtxType;
this->init_proc = init_proc; this->init_proc = init_proc;
this->init_widget_proc = init_proc2; this->init_widget_proc = init_proc2;
this->client_data = client_data; this->client_data = client_data;
QScrollAreaGlow *form = new QScrollAreaGlow(); QScrollArea *form = new QScrollArea();
scroll_h = form->horizontalScrollBar(); scroll_h = form->horizontalScrollBar();
scroll_v = form->verticalScrollBar(); scroll_v = form->verticalScrollBar();
QObject::connect(scroll_h, SIGNAL(valueChanged(int)), this, QObject::connect(scroll_h, SIGNAL(valueChanged(int)), this,
...@@ -89,20 +91,10 @@ QWidget *QtScrollWidgetGlow::initScroll( ...@@ -89,20 +91,10 @@ QWidget *QtScrollWidgetGlow::initScroll(
return form; return form;
} }
bool QScrollAreaGlow::event(QEvent *event)
{
QtScrollWidgetGlow *child = ((QtScrollWidgetGlow *) widget());
time_t t;
time(&t);
if (event->type() != child->lastEvent->type() || difftime(t, child->t) > 0.000001) {
child->handleEvent(event);
}
return QScrollArea::event(event);
}
void QtScrollWidgetGlow::init(unsigned int eCtxType, QWidget *main) void QtScrollWidgetGlow::init(unsigned int eCtxType, QWidget *main)
{ {
createBuffer(size()); createBuffer(size());
setFocusPolicy(Qt::StrongFocus);
this->ctxType = eCtxType; this->ctxType = eCtxType;
is_navigator = 1; is_navigator = 1;
main_widget = main; main_widget = main;
...@@ -266,8 +258,6 @@ bool QtScrollWidgetGlow::event(QEvent *event) ...@@ -266,8 +258,6 @@ bool QtScrollWidgetGlow::event(QEvent *event)
is_realized = true; is_realized = true;
} }
handleEvent(event); handleEvent(event);
lastEvent = event;
time(&t);
return QWidget::event(event); return QWidget::event(event);
} }
......
...@@ -59,13 +59,6 @@ typedef struct { ...@@ -59,13 +59,6 @@ typedef struct {
int scroll_v_managed; int scroll_v_managed;
} widget_sScroll; } widget_sScroll;
// QScrollArea does not forward events to its child widget
// So we subclass QScrollArea and override the event() handler
class QScrollAreaGlow : public QScrollArea {
protected:
bool event(QEvent *event);
};
class QtScrollWidgetGlow : public QWidget { class QtScrollWidgetGlow : public QWidget {
Q_OBJECT Q_OBJECT
...@@ -105,9 +98,6 @@ public: ...@@ -105,9 +98,6 @@ public:
QImage image; QImage image;
QEvent *lastEvent;
time_t t;
virtual void handleEvent(QEvent *event); virtual void handleEvent(QEvent *event);
protected: protected:
......
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