From 75bc99e67a764f915d7d64af3d2d1863258a4be5 Mon Sep 17 00:00:00 2001 From: hybrid Date: Fri, 14 Sep 2007 09:57:40 +0000 Subject: [PATCH] Made Linux event local to event handler. Cleaned up file choosing. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@955 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/CGUIFileOpenDialog.cpp | 2 +- source/Irrlicht/CGUIListBox.cpp | 20 +++++++++----------- source/Irrlicht/CIrrDeviceLinux.cpp | 9 +++++---- source/Irrlicht/CIrrDeviceLinux.h | 1 - 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/source/Irrlicht/CGUIFileOpenDialog.cpp b/source/Irrlicht/CGUIFileOpenDialog.cpp index 589fd526..9bd790b7 100644 --- a/source/Irrlicht/CGUIFileOpenDialog.cpp +++ b/source/Irrlicht/CGUIFileOpenDialog.cpp @@ -176,7 +176,7 @@ bool CGUIFileOpenDialog::OnEvent(SEvent event) case EGET_LISTBOX_SELECTED_AGAIN: { - s32 selected = FileBox->getSelected(); + const s32 selected = FileBox->getSelected(); if (FileList && FileSystem) { if (FileList->isDirectory(selected)) diff --git a/source/Irrlicht/CGUIListBox.cpp b/source/Irrlicht/CGUIListBox.cpp index 71ac4f03..84e368ac 100644 --- a/source/Irrlicht/CGUIListBox.cpp +++ b/source/Irrlicht/CGUIListBox.cpp @@ -378,16 +378,14 @@ bool CGUIListBox::OnEvent(SEvent event) } case EMIE_LMOUSE_LEFT_UP: - - if (!isPointInside(p)) - { - Selecting = false; - return true; - } - + { Selecting = false; - selectNew(event.MouseInput.Y); + + if (isPointInside(p)) + selectNew(event.MouseInput.Y); + return true; + } case EMIE_MOUSE_MOVED: if (Selecting || MoveOverSelect) @@ -420,11 +418,11 @@ void CGUIListBox::selectNew(s32 ypos, bool onlyHover) if (ItemHeight!=0) Selected = ((ypos - AbsoluteRect.UpperLeftCorner.Y - 1) + ScrollBar->getPos()) / ItemHeight; - if (Selected >= (s32)Items.size()) - Selected = Items.size() - 1; - else if (Selected<0) Selected = 0; + else + if ((u32)Selected >= Items.size()) + Selected = Items.size() - 1; recalculateScrollPos(); diff --git a/source/Irrlicht/CIrrDeviceLinux.cpp b/source/Irrlicht/CIrrDeviceLinux.cpp index c135509c..63fd3261 100644 --- a/source/Irrlicht/CIrrDeviceLinux.cpp +++ b/source/Irrlicht/CIrrDeviceLinux.cpp @@ -671,6 +671,7 @@ bool CIrrDeviceLinux::run() while (XPending(display) > 0 && !Close) { + XEvent event; XNextEvent(display, &event); switch (event.type) @@ -773,16 +774,16 @@ bool CIrrDeviceLinux::run() break; case KeyRelease: - if (!AutorepeatSupport) + if (0 == AutorepeatSupport) { // check for Autorepeat manually // We'll do the same as Windows does: Only send KeyPressed // So every KeyRelease is a real release XEvent next_event; XPeekEvent (event.xkey.display, &next_event); - if (next_event.type == KeyPress && - next_event.xkey.keycode == event.xkey.keycode && - next_event.xkey.time == event.xkey.time) + if ((next_event.type == KeyPress) && + (next_event.xkey.keycode == event.xkey.keycode) && + (next_event.xkey.time == event.xkey.time)) { /* Ignore the key release event */ break; diff --git a/source/Irrlicht/CIrrDeviceLinux.h b/source/Irrlicht/CIrrDeviceLinux.h index 43766556..71ddd313 100644 --- a/source/Irrlicht/CIrrDeviceLinux.h +++ b/source/Irrlicht/CIrrDeviceLinux.h @@ -294,7 +294,6 @@ namespace irr Window window; XSetWindowAttributes attributes; XSizeHints* StdHints; - XEvent event; XImage* SoftwareImage; #ifdef _IRR_LINUX_X11_VIDMODE_ XF86VidModeModeInfo oldVideoMode;