From af8c2a8313a8d41086c1b74b25670183d423b2df Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Thu, 16 Aug 2012 18:21:04 +0200 Subject: [PATCH] Windows abstarction run now nearly corectly --- Build | 2 +- Java/ewolAndroidAbstraction.cpp | 2 +- Sources/libetk/etk/Stream.h | 36 ++- Sources/libewol/ewol/base/MainThread.cpp | 7 +- Sources/libewol/ewol/base/MainThread.h | 4 +- .../ewol/base/eventInputManagement.cpp | 25 +- Sources/libewol/ewol/base/gui.cpp | 9 +- Sources/libewol/ewol/base/guiAndroid.cpp | 10 +- Sources/libewol/ewol/base/guiWindows.cpp | 223 +++++++++++++++--- Sources/libewol/ewol/base/guiX11.cpp | 24 +- Sources/libewol/ewol/ewol.h | 7 +- 11 files changed, 265 insertions(+), 84 deletions(-) diff --git a/Build b/Build index d51a2118..d54c5265 160000 --- a/Build +++ b/Build @@ -1 +1 @@ -Subproject commit d51a211876127e44d0618683d0aeff154f87d64f +Subproject commit d54c52656490040b3d79c2d9bd9cd17ecedb855b diff --git a/Java/ewolAndroidAbstraction.cpp b/Java/ewolAndroidAbstraction.cpp index e5c57d8f..32078dd8 100644 --- a/Java/ewolAndroidAbstraction.cpp +++ b/Java/ewolAndroidAbstraction.cpp @@ -414,7 +414,7 @@ extern "C" void Java_org_ewol_interfaceJNI_RenderDraw( JNIEnv* env ) { - guiSystem::Draw(); + guiSystem::Draw(true); } void Java_org_ewol_interfaceJNI_IOAudioPlayback(JNIEnv* env, void* reserved, jshortArray location, jint frameRate, jint nbChannels) diff --git a/Sources/libetk/etk/Stream.h b/Sources/libetk/etk/Stream.h index 8268aaab..1a223528 100644 --- a/Sources/libetk/etk/Stream.h +++ b/Sources/libetk/etk/Stream.h @@ -105,14 +105,20 @@ namespace etk{ }; + CCout& operator << (CHex t) { + hex = true; + return *this; + } CCout& operator << (int t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", t); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; return *this; } CCout& operator << (unsigned int t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; return *this; } /* @@ -123,38 +129,55 @@ namespace etk{ } */ CCout& operator << (long t) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "%ld", t); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + if (true == hex) { + snprintf(tmp, MAX_LOG_SIZE_TMP, "0x%08X", (unsigned int)t); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; + } else { + snprintf(tmp, MAX_LOG_SIZE_TMP, "%ld", t); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + } return *this; } CCout& operator << (long long t) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", t); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + if (true == hex) { + snprintf(tmp, MAX_LOG_SIZE_TMP, "0x%08X%08X", (unsigned int)(t>>32), (unsigned int)(t)); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; + } else { + snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", t); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + } return *this; } CCout& operator << (double t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; return *this; } CCout& operator << (float t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; return *this; } CCout& operator << (char * t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; return *this; } CCout& operator << (const char * t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; return *this; } CCout& operator << (char t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%c", t); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; return *this; } CCout& operator << (bool t) { @@ -169,26 +192,31 @@ namespace etk{ CCout& operator << (Vector2D t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f)", t.x, t.y); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; return *this; } CCout& operator << (Vector2D t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "(%i,%i)", t.x, t.y); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; return *this; } CCout& operator << (Vector3D t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f,%f)", t.x, t.y, t.z); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; return *this; } CCout& operator << (Vector3D t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "(%i,%i,%i)", t.x, t.y, t.z); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; return *this; } CCout& operator << (clipping_ts t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "origin=(%f,%f) size=(%f,%f)", t.x, t.y, t.w, t.h); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); + hex = false; return *this; } CCout& operator << (CStart ccc) { diff --git a/Sources/libewol/ewol/base/MainThread.cpp b/Sources/libewol/ewol/base/MainThread.cpp index d97fc51c..f10faff6 100644 --- a/Sources/libewol/ewol/base/MainThread.cpp +++ b/Sources/libewol/ewol/base/MainThread.cpp @@ -357,18 +357,19 @@ void guiSystem::event::Show(void) } } -void guiSystem::Draw(void) +bool guiSystem::Draw(bool displayEveryTime) { if (true == isGlobalSystemInit) { ewolProcessEvents(); - int64_t localTime = GetCurrentTime(); + int64_t localTime = ewol::GetTime(); ewol::widgetManager::PeriodicCall(localTime); EWOL_NativeRegenerateDisplay(); ewol::texture::UpdateContext(); - EWOL_NativeRender(); + EWOL_GenericDraw(true); } + return true; } diff --git a/Sources/libewol/ewol/base/MainThread.h b/Sources/libewol/ewol/base/MainThread.h index 4794b0f1..901078e0 100644 --- a/Sources/libewol/ewol/base/MainThread.h +++ b/Sources/libewol/ewol/base/MainThread.h @@ -75,8 +75,8 @@ namespace guiSystem void Hide(void); void Show(void); }; - - void Draw(void); + // return true if a flush is needed + bool Draw(bool displayEveryTime); }; #endif diff --git a/Sources/libewol/ewol/base/eventInputManagement.cpp b/Sources/libewol/ewol/base/eventInputManagement.cpp index 6044199f..e792eb32 100644 --- a/Sources/libewol/ewol/base/eventInputManagement.cpp +++ b/Sources/libewol/ewol/base/eventInputManagement.cpp @@ -182,7 +182,8 @@ static int32_t localGetDestinationId(ewol::inputType_te type, ewol::Widget* dest return realInputId; } - +#define EVENT_DEBUG EWOL_VERBOSE +//#define EVENT_DEBUG EWOL_DEBUG // defined by the platform specific file : extern int32_t separateClickTime; @@ -221,7 +222,7 @@ void ewol::eventInput::Motion(ewol::inputType_te type, int pointerID, Vector2D" << eventTable[pointerID].destinationInputId << " [LEAVE] " << pos); + EVENT_DEBUG("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [LEAVE] " << pos); localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_LEAVE, pos); } if (false == eventTable[pointerID].isInside) { @@ -241,10 +242,10 @@ void ewol::eventInput::Motion(ewol::inputType_te type, int pointerID, Vector2DGetSize(); } eventTable[pointerID].destinationInputId = 0; - EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [ENTER] " << pos); + EVENT_DEBUG("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [ENTER] " << pos); localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_ENTER, pos); } - EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [MOVE] " << pos); + EVENT_DEBUG("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [MOVE] " << pos); localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_MOVE, pos); } else if (true == eventTable[pointerID].isUsed) { if (true == eventTable[pointerID].isInside) { @@ -253,7 +254,7 @@ void ewol::eventInput::Motion(ewol::inputType_te type, int pointerID, Vector2D" << eventTable[pointerID].destinationInputId << " [LEAVE] " << pos); + EVENT_DEBUG("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [LEAVE] " << pos); localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_LEAVE, pos); } } else { @@ -262,11 +263,11 @@ void ewol::eventInput::Motion(ewol::inputType_te type, int pointerID, Vector2D= pos.y ) ) { eventTable[pointerID].isInside = true; - EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [ENTER] " << pos); + EVENT_DEBUG("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [ENTER] " << pos); localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_ENTER, pos); } } - EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [MOVE] " << pos); + EVENT_DEBUG("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [MOVE] " << pos); localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_MOVE, pos); } } @@ -290,7 +291,7 @@ void ewol::eventInput::State(ewol::inputType_te type, int pointerID, bool isDown return; } // get the curent time ... - int64_t currentTime = GetCurrentTime(); + int64_t currentTime = ewol::GetTime(); if (true == isDown) { EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [DOWN] " << pos); @@ -307,7 +308,7 @@ void ewol::eventInput::State(ewol::inputType_te type, int pointerID, bool isDown // save start time eventTable[pointerID].lastTimeEvent = currentTime; // generate DOWN Event - EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [DOWN] " << pos); + EVENT_DEBUG("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [DOWN] " << pos); localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_DOWN, pos); } else { // Mark it used : @@ -332,7 +333,7 @@ void ewol::eventInput::State(ewol::inputType_te type, int pointerID, bool isDown eventTable[pointerID].destinationInputId = -1; } // generate DOWN Event - EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [DOWN] " << pos); + EVENT_DEBUG("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [DOWN] " << pos); localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_DOWN, pos); } } else { @@ -346,7 +347,7 @@ void ewol::eventInput::State(ewol::inputType_te type, int pointerID, bool isDown eventTable[pointerID].curentWidgetEvent = NULL; } else { // generate UP Event - EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [UP] " << pos); + EVENT_DEBUG("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [UP] " << pos); localEventInput(type, eventTable[pointerID].curentWidgetEvent, pointerID, ewol::EVENT_INPUT_TYPE_UP, pos); // generate event (single) if( abs(eventTable[pointerID].downStart.x - pos.x) < offsetMoveClicked @@ -365,7 +366,7 @@ void ewol::eventInput::State(ewol::inputType_te type, int pointerID, bool isDown if(eventTable[pointerID].nbClickEvent < nbClickMax) { // generate event SINGLE : eventTable[pointerID].nbClickEvent++; - EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [SINGLE] " << pos); + EVENT_DEBUG("GUI : Input ID=" << pointerID << "==>" << eventTable[pointerID].destinationInputId << " [" << eventTable[pointerID].nbClickEvent << "] " << pos); localEventInput(type, eventTable[pointerID].curentWidgetEvent, eventTable[pointerID].destinationInputId, diff --git a/Sources/libewol/ewol/base/gui.cpp b/Sources/libewol/ewol/base/gui.cpp index fa889a24..dd8ecc77 100644 --- a/Sources/libewol/ewol/base/gui.cpp +++ b/Sources/libewol/ewol/base/gui.cpp @@ -246,14 +246,14 @@ void EWOL_GenericDraw(bool everyTime) bool display = false; nbCallTime++; if (startTime<0) { - startTime = GetCurrentTime(); + startTime = ewol::GetTime(); } - int64_t currentTime = GetCurrentTime(); + int64_t currentTime = ewol::GetTime(); //EWOL_DEBUG("current : " << currentTime << "time diff : " << (currentTime - startTime)); if ( (currentTime - startTime) > DISPLAY_PERIODE_US) { display = true; } - int64_t currentTime3 = GetCurrentTime(); + int64_t currentTime3 = ewol::GetTime(); // check if the regenerate is needed ... if( true == ewol::widgetManager::IsDrawingNeeded() || true == everyTime) { @@ -263,7 +263,7 @@ void EWOL_GenericDraw(bool everyTime) } // send Message that we just finished a display ... //EWOL_ThreadEventHasJustDisplay(); - int64_t currentTime2 = GetCurrentTime(); + int64_t currentTime2 = ewol::GetTime(); int64_t processTimeLocal = (currentTime2 - currentTime); min = etk_min(min, processTimeLocal); max = etk_max(max, processTimeLocal); @@ -292,6 +292,7 @@ void EWOL_GenericDraw(bool everyTime) startTime = -1; } } + glFlush(); } void EWOL_NativeGLDestroy(void) diff --git a/Sources/libewol/ewol/base/guiAndroid.cpp b/Sources/libewol/ewol/base/guiAndroid.cpp index 835c8abc..e4ebe2f3 100644 --- a/Sources/libewol/ewol/base/guiAndroid.cpp +++ b/Sources/libewol/ewol/base/guiAndroid.cpp @@ -49,7 +49,7 @@ extern float gui_width; extern float gui_height; extern ewol::Windows* gui_uniqueWindows; -int64_t GetCurrentTime(void) +int64_t ewol::GetTime(void) { struct timeval now; gettimeofday(&now, NULL); @@ -79,14 +79,6 @@ static etk::UString l_clipBoardStd(""); // local copy of the clipboard -void EWOL_NativeRender(void) -{ - EWOL_GenericDraw(true); - glFlush(); -} - - - void ewol::SetTitle(etk::UString title) { // can not set the title in Android ... diff --git a/Sources/libewol/ewol/base/guiWindows.cpp b/Sources/libewol/ewol/base/guiWindows.cpp index ad9beefb..cf2d3aa3 100644 --- a/Sources/libewol/ewol/base/guiWindows.cpp +++ b/Sources/libewol/ewol/base/guiWindows.cpp @@ -37,6 +37,16 @@ #include #include +#include + +int64_t ewol::GetTime(void) +{ + struct timeval now; + gettimeofday(&now, NULL); + //EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us"); + return (int64_t)((int64_t)now.tv_sec*(int64_t)1000000 + (int64_t)now.tv_usec); +} + int32_t separateClickTime = 300000; int32_t offsetMoveClicked = 10000; @@ -44,6 +54,8 @@ int32_t offsetMoveClickedDouble = 20000; bool inputIsPressed[20]; +static guiSystem::event::specialKey_ts guiKeyBoardMode; + void ewol::SetTitle(etk::UString title) { @@ -51,16 +63,6 @@ void ewol::SetTitle(etk::UString title) } -void EWOL_NativeRender(void) -{ - EWOL_GenericDraw(true); - glFlush(); -} - - - - - static etk::Vector listArgs; int32_t ewol::CmdLineNb(void) @@ -88,6 +90,8 @@ bool m_run = true; void guiAbstraction::Stop(void) { m_run = false; + // To exit program ... + PostQuitMessage(0); } @@ -227,6 +231,14 @@ int main(int argc, char *argv[]) for (int32_t iii=0; iii pos; + // to know all message : http://wiki.winehq.org/List_Of_Windows_Messages switch (message) { /* ************************************************************************** @@ -344,53 +356,197 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) return 0; case WM_SIZE: EWOL_DEBUG("WM_SIZE"); - return 0; + /* + case WM_GETMINMAXINFO: + { + MINMAXINFO* tmpVal = (MINMAXINFO*)lParam; + EWOL_DEBUG("WM_GETMINMAXINFO : "); + EWOL_DEBUG(" ptMaxSize : " << tmpVal->ptMaxSize.x << "," << tmpVal->ptMaxSize.y << ")"); + EWOL_DEBUG(" ptMaxPosition : " << tmpVal->ptMaxPosition.x << "," << tmpVal->ptMaxPosition.y << ")"); + EWOL_DEBUG(" ptMinTrackSize : " << tmpVal->ptMinTrackSize.x << "," << tmpVal->ptMinTrackSize.y << ")"); + EWOL_DEBUG(" ptMaxTrackSize : " << tmpVal->ptMaxTrackSize.x << "," << tmpVal->ptMaxTrackSize.y << ")"); + } + return 0; + */ + case WM_WINDOWPOSCHANGING: + { + WINDOWPOS* tmpVal = (WINDOWPOS*)lParam; + if (NULL != tmpVal) { + //EWOL_DEBUG("WM_WINDOWPOSCHANGING : : (" << tmpVal->x << "," << tmpVal->y << ") ( " << tmpVal->cx << "," << tmpVal->cy << ")"); + guiSystem::event::Resize(tmpVal->cx-8, tmpVal->cy - 28); + } + } + return 0; + // these message are not parse by us ... + case WM_SETCURSOR: // Call the windows if we want the mouse event : + case WM_NCHITTEST: // inform the application the position of the mouse is moving + return DefWindowProc( hWnd, message, wParam, lParam ); + /* ************************************************************************** * Keyboard management * **************************************************************************/ + case WM_KEYUP: + buttonIsDown = false; case WM_KEYDOWN: - EWOL_DEBUG("WM_KEYDOWN"); - switch ( wParam ) { - case VK_ESCAPE: - PostQuitMessage(0); - return 0; + { + uniChar_t tmpChar = 0; + ewol::eventKbMoveType_te keyInput; + switch (wParam) { + //case 80: // keypad + case VK_UP: keyInput = ewol::EVENT_KB_MOVE_TYPE_UP; break; + //case 83: // keypad + case VK_LEFT: keyInput = ewol::EVENT_KB_MOVE_TYPE_LEFT; break; + //case 85: // keypad + case VK_RIGHT: keyInput = ewol::EVENT_KB_MOVE_TYPE_RIGHT; break; + //case 88: // keypad + case VK_DOWN: keyInput = ewol::EVENT_KB_MOVE_TYPE_DOWN; break; + //case 81: // keypad + case VK_PRIOR: keyInput = ewol::EVENT_KB_MOVE_TYPE_PAGE_UP; break; + //case 89: // keypad + case VK_NEXT: keyInput = ewol::EVENT_KB_MOVE_TYPE_PAGE_DOWN; break; + //case 79: // keypad + case VK_HOME: keyInput = ewol::EVENT_KB_MOVE_TYPE_START; break; + //case 87: // keypad + case VK_END: keyInput = ewol::EVENT_KB_MOVE_TYPE_END; break; + //case VK_: keyInput = ewol::EVENT_KB_MOVE_TYPE_ARRET_DEFIL; break; + case VK_PAUSE: keyInput = ewol::EVENT_KB_MOVE_TYPE_WAIT; break; + //case 90: // keypad + case VK_INSERT: + keyInput = ewol::EVENT_KB_MOVE_TYPE_INSERT; + guiKeyBoardMode.insert = buttonIsDown; + break; + case VK_F1: keyInput = ewol::EVENT_KB_MOVE_TYPE_F1; break; + case VK_F2: keyInput = ewol::EVENT_KB_MOVE_TYPE_F2; break; + case VK_F3: keyInput = ewol::EVENT_KB_MOVE_TYPE_F3; break; + case VK_F4: keyInput = ewol::EVENT_KB_MOVE_TYPE_F4; break; + case VK_F5: keyInput = ewol::EVENT_KB_MOVE_TYPE_F5; break; + case VK_F6: keyInput = ewol::EVENT_KB_MOVE_TYPE_F6; break; + case VK_F7: keyInput = ewol::EVENT_KB_MOVE_TYPE_F7; break; + case VK_F8: keyInput = ewol::EVENT_KB_MOVE_TYPE_F8; break; + case VK_F9: keyInput = ewol::EVENT_KB_MOVE_TYPE_F9; break; + case VK_F10: keyInput = ewol::EVENT_KB_MOVE_TYPE_F10; break; + case VK_F11: keyInput = ewol::EVENT_KB_MOVE_TYPE_F11; break; + case VK_F12: + case VK_F13: + case VK_F14: + case VK_F15: + case VK_F16: + case VK_F17: + case VK_F18: + case VK_F19: + case VK_F20: + case VK_F21: + case VK_F22: + case VK_F23: + case VK_F24: keyInput = ewol::EVENT_KB_MOVE_TYPE_F12; break; + case VK_CAPITAL: keyInput = ewol::EVENT_KB_MOVE_TYPE_CAPLOCK; guiKeyBoardMode.capLock = buttonIsDown; break; + + case VK_SHIFT: + case VK_LSHIFT: keyInput = ewol::EVENT_KB_MOVE_TYPE_SHIFT_LEFT; guiKeyBoardMode.shift = buttonIsDown; break; + case VK_RSHIFT: keyInput = ewol::EVENT_KB_MOVE_TYPE_SHIFT_RIGHT; guiKeyBoardMode.shift = buttonIsDown; break; + + case VK_CONTROL: + case VK_LCONTROL: keyInput = ewol::EVENT_KB_MOVE_TYPE_CTRL_LEFT; guiKeyBoardMode.ctrl = buttonIsDown; break; + case VK_RCONTROL: keyInput = ewol::EVENT_KB_MOVE_TYPE_CTRL_RIGHT; guiKeyBoardMode.ctrl = buttonIsDown; break; + + case VK_LWIN: keyInput = ewol::EVENT_KB_MOVE_TYPE_META_LEFT; guiKeyBoardMode.meta = buttonIsDown; break; + case VK_RWIN: keyInput = ewol::EVENT_KB_MOVE_TYPE_META_RIGHT; guiKeyBoardMode.meta = buttonIsDown; break; + + case VK_MENU: + case VK_LMENU: keyInput = ewol::EVENT_KB_MOVE_TYPE_ALT; guiKeyBoardMode.alt = buttonIsDown; break; + case VK_RMENU: keyInput = ewol::EVENT_KB_MOVE_TYPE_ALT_GR; guiKeyBoardMode.altGr = buttonIsDown; break; + //case : keyInput = ewol::EVENT_KB_MOVE_TYPE_CONTEXT_MENU; break; + case VK_NUMLOCK: keyInput = ewol::EVENT_KB_MOVE_TYPE_VER_NUM; guiKeyBoardMode.verNum = buttonIsDown; break; + case VK_BACK: // DEL + tmpChar = 0x00000008; + break; + // TODO : Really strang, need to understand why ... + case 46: // Suppr + tmpChar = 0x0000007F; + break; + case VK_TAB: // special case for TAB + tmpChar = 0x00000009; + break; + case VK_RETURN: // special case for TAB + tmpChar = '\n'; + break; + default: + { + BYTE kbd[256]; + GetKeyboardState(kbd); + const int BUFFER_LENGTH = 8; //Length of the buffer + WCHAR chars[BUFFER_LENGTH]; + + ToUnicode(wParam,lParam,kbd,chars,BUFFER_LENGTH,0); + unicode::convertUtf8ToUnicode((char*)chars, tmpChar); + } + break; + } + EWOL_DEBUG("kjhkjhkjhkjhkj = " << wParam); + if (tmpChar == 0) { + //EWOL_DEBUG("eventKey Move type : " << GetCharTypeMoveEvent(keyInput) ); + guiSystem::event::keyboardMove_ts specialEvent; + specialEvent.special = guiKeyBoardMode; + specialEvent.move = keyInput; + specialEvent.isDown = buttonIsDown; + guiSystem::event::SetKeyboardMove(specialEvent); + } else { + guiSystem::event::keyboardKey_ts specialEvent; + specialEvent.special = guiKeyBoardMode; + specialEvent.myChar = tmpChar; + specialEvent.isDown = buttonIsDown; + guiSystem::event::SetKeyboard(specialEvent); + } } return 0; /* ************************************************************************** * Mouse management * **************************************************************************/ case WM_LBUTTONUP: - mouseButtonIsDown = false; + buttonIsDown = false; case WM_LBUTTONDOWN: mouseButtonId = 1; pos.x = GET_X_LPARAM(lParam); pos.y = GET_Y_LPARAM(lParam); - inputIsPressed[mouseButtonId] = mouseButtonIsDown; - guiSystem::event::SetMouseState(mouseButtonId, mouseButtonIsDown, (float)pos.x, (float)pos.y); + inputIsPressed[mouseButtonId] = buttonIsDown; + guiSystem::event::SetMouseState(mouseButtonId, buttonIsDown, (float)pos.x, (float)pos.y); return 0; + case WM_MBUTTONUP: - mouseButtonIsDown = false; + buttonIsDown = false; case WM_MBUTTONDOWN: mouseButtonId = 2; pos.x = GET_X_LPARAM(lParam); pos.y = GET_Y_LPARAM(lParam); - inputIsPressed[mouseButtonId] = mouseButtonIsDown; - guiSystem::event::SetMouseState(mouseButtonId, mouseButtonIsDown, (float)pos.x, (float)pos.y); + inputIsPressed[mouseButtonId] = buttonIsDown; + guiSystem::event::SetMouseState(mouseButtonId, buttonIsDown, (float)pos.x, (float)pos.y); return 0; - + case WM_RBUTTONUP: - mouseButtonIsDown = false; + buttonIsDown = false; case WM_RBUTTONDOWN: mouseButtonId = 3; pos.x = GET_X_LPARAM(lParam); pos.y = GET_Y_LPARAM(lParam); - inputIsPressed[mouseButtonId] = mouseButtonIsDown; - guiSystem::event::SetMouseState(mouseButtonId, mouseButtonIsDown, (float)pos.x, (float)pos.y); + inputIsPressed[mouseButtonId] = buttonIsDown; + guiSystem::event::SetMouseState(mouseButtonId, buttonIsDown, (float)pos.x, (float)pos.y); return 0; - - // TODO : Set the other bt ... - + + case WM_MOUSEWHEEL: + if (wParam & 0x200000) { + EWOL_DEBUG("event SCROOL UP"); + mouseButtonId = 4; + } else{ + EWOL_DEBUG("event SCROOL DOWN"); + mouseButtonId = 5; + } + pos.x = GET_X_LPARAM(lParam); + pos.y = GET_Y_LPARAM(lParam); + guiSystem::event::SetMouseState(mouseButtonId, true, (float)pos.x, (float)pos.y); + guiSystem::event::SetMouseState(mouseButtonId, false, (float)pos.x, (float)pos.y); + return 0; + case WM_MOUSEHOVER: case WM_MOUSEMOVE: pos.x = GET_X_LPARAM(lParam); @@ -405,8 +561,9 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) EWOL_VERBOSE("Windows event: bt=" << 0 << " " << message << " = \"WM_MOUSEMOVE\" " << pos ); guiSystem::event::SetMouseMotion(0, (float)pos.x, (float)pos.y); return 0; + default: - EWOL_VERBOSE("event ..." << message ); + EWOL_DEBUG("event ..." << message ); return DefWindowProc( hWnd, message, wParam, lParam ); } diff --git a/Sources/libewol/ewol/base/guiX11.cpp b/Sources/libewol/ewol/base/guiX11.cpp index 23ee31b7..4402cc4e 100644 --- a/Sources/libewol/ewol/base/guiX11.cpp +++ b/Sources/libewol/ewol/base/guiX11.cpp @@ -50,7 +50,7 @@ //#define DEBUG_X11_EVENT -int64_t GetCurrentTime(void) +int64_t ewol::GetTime(void) { struct timespec now; int ret = clock_gettime(CLOCK_REALTIME, &now); @@ -422,15 +422,6 @@ bool CreateOGlContext(void) return true; } -void EWOL_NativeRender(void) -{ - EWOL_GenericDraw(false); - glFlush(); - if (m_doubleBuffered) { - glXSwapBuffers(m_display, WindowHandle); - } -} - void X11_Init(void) { #ifdef DEBUG_X11_EVENT @@ -996,7 +987,10 @@ void X11_Run(void) } } if(true == m_run) { - guiSystem::Draw(); + (void)guiSystem::Draw(false); + if (m_doubleBuffered) { + glXSwapBuffers(m_display, WindowHandle); + } } #ifdef DEBUG_X11_EVENT EWOL_INFO("X11 endEvent --- "); @@ -1231,6 +1225,14 @@ int main(int argc, char *argv[]) for (int32_t iii=0; iii