summaryrefslogtreecommitdiff
path: root/plugingui
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2013-09-27 20:16:12 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2013-09-27 20:16:12 +0200
commita5d271dd8f3c2726aa42929c923704f98ad37010 (patch)
treee4a30dd1c425903060ac60d360b81c8f123f3213 /plugingui
parentf26b9cb7418917b3ecc7fec877e11eedcb7fefa9 (diff)
Optimise repaint events greatly improving GUI responsiveness.
Diffstat (limited to 'plugingui')
-rw-r--r--plugingui/Makefile.mingw325
-rw-r--r--plugingui/eventhandler.cc5
-rw-r--r--plugingui/window.cc14
-rw-r--r--plugingui/window.h2
4 files changed, 21 insertions, 5 deletions
diff --git a/plugingui/Makefile.mingw32 b/plugingui/Makefile.mingw32
index b8ffe9e..d1cd3bc 100644
--- a/plugingui/Makefile.mingw32
+++ b/plugingui/Makefile.mingw32
@@ -40,7 +40,10 @@ CXX_SOURCES = \
$(top_srcdir)/plugingui/resource.cc \
$(top_srcdir)/plugingui/resource_data.cc \
$(top_srcdir)/src/thread.cc \
- $(top_srcdir)/src/semaphore.cc
+ $(top_srcdir)/src/semaphore.cc \
+ $(top_srcdir)/src/mutex.cc \
+ $(top_srcdir)/src/messagehandler.cc \
+ $(top_srcdir)/src/messagereceiver.cc
OBJECTS=$(CXX_SOURCES:.cc=.o) $(C_SOURCES:.c=.o)
#OBJECTS=$(PLUGIN_GUI_SOURCES:.cc=.o)
diff --git a/plugingui/eventhandler.cc b/plugingui/eventhandler.cc
index 7eae827..cec5fab 100644
--- a/plugingui/eventhandler.cc
+++ b/plugingui/eventhandler.cc
@@ -27,6 +27,7 @@
#include "eventhandler.h"
#include "window.h"
+#include "painter.h"
GUI::EventHandler::EventHandler(GUI::NativeWindow *n, GUI::Window *w)
{
@@ -56,6 +57,8 @@ void GUI::EventHandler::registerCloseHandler(void (*handler)(void *), void *ptr)
void GUI::EventHandler::processEvents()
{
while(hasEvent()) {
+ Painter p(window); // Make sure we only redraw buffer one time.
+
Event *event = getNextEvent();
if(event == NULL) continue;
@@ -72,7 +75,7 @@ void GUI::EventHandler::processEvents()
ResizeEvent *re = (ResizeEvent*)event;
if(re->width != window->width() || re->height != window->height()) {
window->resized(re->width, re->height);
- window->repaint_r(NULL);
+ //window->repaint_r(NULL);
}
}
break;
diff --git a/plugingui/window.cc b/plugingui/window.cc
index 1f98c6f..0d11b17 100644
--- a/plugingui/window.cc
+++ b/plugingui/window.cc
@@ -50,6 +50,7 @@ GUI::Window::Window()
_height = wpixbuf.height;
refcount = 0;
+ max_refcount = 0;
_keyboardFocus = this;
_buttonDownFocus = NULL;
_mouseFocus = NULL;
@@ -140,6 +141,7 @@ GUI::Window *GUI::Window::window()
void GUI::Window::beginPaint()
{
refcount++;
+ if(refcount > max_refcount) max_refcount = refcount;
}
void GUI::Window::endPaint()
@@ -147,8 +149,11 @@ void GUI::Window::endPaint()
if(refcount) refcount--;
if(!refcount) {
- updateBuffer();
- redraw();
+ if(max_refcount > 1) { // Did we go deep enough for a buffer update?
+ updateBuffer();
+ redraw();
+ }
+ max_refcount = 0;
}
}
@@ -197,8 +202,11 @@ GUI::Widget *GUI::Window::keyboardFocus()
void GUI::Window::setKeyboardFocus(GUI::Widget *widget)
{
+ GUI::Widget *old_focus = _keyboardFocus;
_keyboardFocus = widget;
- repaint_r(NULL);
+
+ if(old_focus) old_focus->repaintEvent(NULL);
+ if(_keyboardFocus) _keyboardFocus->repaintEvent(NULL);
}
GUI::Widget *GUI::Window::buttonDownFocus()
diff --git a/plugingui/window.h b/plugingui/window.h
index 2a25d41..2e3d17c 100644
--- a/plugingui/window.h
+++ b/plugingui/window.h
@@ -95,6 +95,8 @@ protected:
Image back;
Image logo;
+
+ size_t max_refcount;
};
};