From a6ad872b60672571da2d25718c7b21f13656e7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 27 Mar 2009 19:35:32 +0000 Subject: [PATCH] * Works around a race condition/bug/design issue in our layout engine: sometimes the size isn't set in AttachedToWindow() yet, and the first FrameResized() comes after the first Draw(). We now relayout in Draw() in case the size changed since last time. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29748 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/preferences/keymap/KeyboardLayoutView.cpp | 14 ++++++++++---- src/preferences/keymap/KeyboardLayoutView.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/preferences/keymap/KeyboardLayoutView.cpp b/src/preferences/keymap/KeyboardLayoutView.cpp index bc5500558b..a1a2700be5 100644 --- a/src/preferences/keymap/KeyboardLayoutView.cpp +++ b/src/preferences/keymap/KeyboardLayoutView.cpp @@ -29,7 +29,8 @@ KeyboardLayoutView::KeyboardLayoutView(const char* name) fModifiers(0), fDeadKey(0), fDragKey(NULL), - fDropTarget(NULL) + fDropTarget(NULL), + fOldSize(0, 0) { fLayout = new KeyboardLayout; memset(fKeyState, 0, sizeof(fKeyState)); @@ -90,9 +91,6 @@ KeyboardLayoutView::AttachedToWindow() SetFont(*be_plain_font); fSpecialFont = *be_fixed_font; fModifiers = modifiers(); - - _InitOffscreen(); - _LayoutKeyboard(); } @@ -230,6 +228,11 @@ KeyboardLayoutView::MouseMoved(BPoint point, uint32 transit, void KeyboardLayoutView::Draw(BRect updateRect) { + if (fOldSize != BSize(Bounds().Width(), Bounds().Height())) { + _InitOffscreen(); + _LayoutKeyboard(); + } + BView* view; if (fOffscreenBitmap != NULL) { view = fOffscreenView; @@ -396,6 +399,9 @@ KeyboardLayoutView::_LayoutKeyboard() fGap = 1; else fGap = 2; + + fOldSize.width = Bounds().Width(); + fOldSize.height = Bounds().Height(); } diff --git a/src/preferences/keymap/KeyboardLayoutView.h b/src/preferences/keymap/KeyboardLayoutView.h index 06d81d914f..4c7604334e 100644 --- a/src/preferences/keymap/KeyboardLayoutView.h +++ b/src/preferences/keymap/KeyboardLayoutView.h @@ -99,6 +99,7 @@ private: Key* fDropTarget; BPoint fDropPoint; + BSize fOldSize; BFont fFont; BFont fSpecialFont; float fBaseFontHeight;