--- nono/wx/wxmainview.cpp 2026/04/29 17:04:30 1.1.1.2 +++ nono/wx/wxmainview.cpp 2026/04/29 17:04:33 1.1.1.3 @@ -5,6 +5,7 @@ #include "wxheader.h" #include "keyboard.h" +#include "mystring.h" #include "renderer.h" #include "scheduler.h" #include "wxmainview.h" @@ -246,6 +247,7 @@ WXMainView::OnMouse(wxMouseEvent& event) if (mousemode) { bool leaving = event.Leaving(); bool moving = event.Moving(); + bool dragging = event.Dragging(); // LeftDown() 等は押された時、LeftIsDown() 等は押されてる間 true。 bool rb = event.RightIsDown(); bool lb = event.LeftIsDown(); @@ -254,20 +256,34 @@ WXMainView::OnMouse(wxMouseEvent& event) int dx = 0; int dy = 0; - DMPRINTF( - "OnMouse Button=%d %c%c%c Leave=%d (motion=%d) Moving=%d(%d,%d)\n", - event.IsButton(), - (lb ? 'L' : '-'), - (mb ? 'M' : '-'), - (rb ? 'R' : '-'), - leaving, motion_by_warp_pointer, moving, pos.x, pos.y); +#if defined(MOUSEDEBUG) + std::string dstr = "OnMouse"; + if (moving || dragging || motion_by_warp_pointer) { + dstr += string_format(" (%d,%d)", pos.x, pos.y); + } + if (moving) + dstr += " Moving"; + if (dragging) + dstr += " Dragging"; + if (motion_by_warp_pointer) + dstr += " MotionByWarp"; + if (event.IsButton()) { + dstr += string_format(" Button(%c%c%c)", + (lb ? 'L' : '-'), + (mb ? 'M' : '-'), + (rb ? 'R' : '-')); + } + if (leaving) + dstr += " Leaving"; + printf("%s\n", dstr.c_str()); +#endif if (leaving) { // タスクスイッチした時とかのための自動リリース SetMouseMode(false); } - if (moving) { + if (moving || dragging) { // (My)WarpPointer() で自発的にマウスカーソルを移動させたことで // 来る EVT_MOTION は無視する。 if (motion_by_warp_pointer) { @@ -288,7 +304,12 @@ WXMainView::OnMouse(wxMouseEvent& event) } // VM に入力 - if (dx != 0 || dy != 0 || lb || mb || rb) { + if (dx != 0 || + dy != 0 || + lb != prevlb || + mb != prevmb || + rb != prevrb ) + { DMPRINTF(" Input dx=%d dy=%d %c%c%c\n", dx, dy, (lb ? 'L' : '-'), @@ -297,6 +318,10 @@ WXMainView::OnMouse(wxMouseEvent& event) gKeyboard->MouseInput(dx, dy, rb, lb, mb); } + + prevlb = lb; + prevmb = mb; + prevrb = rb; } // EVT_LEFT_DOWN をデフォルト処理するため