Touchpad behavior changed on a Dell Venue

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
djwdg
In need of some credit
In need of some credit
Posts: 9
Joined: Wed Jul 01, 2020 12:23 am

Touchpad behavior changed on a Dell Venue

Post by djwdg »

Hello all, I have been experiencing recent issues using the touchpad with wxWidgets on a Dell Venue. Specifically, for left button down, left button up, or mouse motion, when touching, i see the event triggered, but the x/y location reported is where the actual mouse is pointing, not where the window is touched. This behavior is new, changing about 1 year ago after an update. I wasn't tracking updates too carefully at the time, so not sure exactly which package is responsible.
  • Dell Venue-11-Pro-7140
  • Linux version 5.15.0-49-generic
  • running with ubuntu jammy, 22.04 LTS
  • currently installed wxWidgets version: 3.0.5.1+dfsg-4
  • also pulled and built the latest wxWidgets from github, version 3.2.0, same behavior
  • currently installed gtk version: 3.24.33-1ubuntu2
  • gtk's example program, example-4, build against installed gtk 3.0, does not show this behavior, ie, screen touches show the proper coordinates
  • a program that uses X11 directly does not show this behavior (code available if needed)
  • wxWidget's example, examples/samples/drawing/drawing.cpp shows yet a different behavior. The touch scrolls the window and does not return a coordinate. A long press does return the proper coordinate. For this case, the drawing area is derived from wxScrolledWindow (vs wxPanel in my case)
I realize that this may not be a wxWidget issue, but I'm not sure where to start and could use the direction if such is the case.
Thanks for your help.

This is the code condensed to minimal that I used to test:

Code: Select all

// wxWidgets testmouse implementation

// For compilers that support precompilation, includes "wx/wx.h".
// This one is generic across platforms.
#include <wx/wxprec.h>

// Precompiled headers speeds up the header include.  If not done, need this include.
#ifndef WX_PRECOMP
    #include <wx/wx.h>
#endif

#include <iostream>
using namespace std;

// Most all apps need this.
// OnInit typically creates and initializes the main window.
class TestMouse : public wxApp
{
 public:
   virtual bool OnInit();
};

class TestMouseFrame;

class TestMouseCanvas : public wxPanel {
 public:
   TestMouseCanvas( TestMouseFrame* parent );
   void dumpMouseData( const char* title, wxMouseEvent& event );
   void OnMouseLeftDownEvent(wxMouseEvent& event);
   void OnMouseLeftUpEvent(wxMouseEvent& event);
   void OnMouseMotionEvent(wxMouseEvent& event);
   TestMouseFrame* parent() { return _parent; }
 private:
   friend class TestMouseFrame;
   TestMouseFrame* _parent;
   wxDECLARE_EVENT_TABLE();
};

// This defines/creates the main window.  OnInit creates one of these.
class TestMouseFrame : public wxFrame
{
 public:
   TestMouseFrame();
   TestMouseCanvas* ncCanvas();
 private:
   friend class TestMouseCanvas;
   TestMouseCanvas* _canvas;
   void OnExit(wxCommandEvent& event);

   // Following needed in order to handle mouse, key, or menu button actions
   wxDECLARE_EVENT_TABLE();
};

wxDEFINE_EVENT( EVT_COMMAND_REFRESH, wxCommandEvent );


// Define which events are associated with which handlers.
wxBEGIN_EVENT_TABLE(TestMouseFrame, wxFrame)
    EVT_MENU(wxID_EXIT, TestMouseFrame::OnExit)
wxEND_EVENT_TABLE()

// Does the "main", starts the program
wxIMPLEMENT_APP(TestMouse);


bool TestMouse::OnInit()
{
   // Creates the main window
   // OnInit is called upon startup.
   TestMouseFrame *frame = new TestMouseFrame();
   frame->Show( true );

   // Above doesnt return until the program ends

   return true;
}

// The TestMouseFrame constructor has all the guts of defining the main window.
TestMouseFrame::TestMouseFrame()
        : wxFrame(NULL, wxID_ANY, "TestMouse", wxDefaultPosition, wxSize(400,400))
{
    _canvas = new TestMouseCanvas(this);
}

TestMouseCanvas* TestMouseFrame::ncCanvas() { return _canvas; }

// Handler for when "Quit" is selected from the menus
void TestMouseFrame::OnExit(wxCommandEvent& event)
{
    Close( true );
}

BEGIN_EVENT_TABLE(TestMouseCanvas, wxPanel)
    EVT_LEFT_DOWN(TestMouseCanvas::OnMouseLeftDownEvent)
    EVT_LEFT_UP(TestMouseCanvas::OnMouseLeftUpEvent)
    EVT_MOTION(TestMouseCanvas::OnMouseMotionEvent)
END_EVENT_TABLE()

TestMouseCanvas::TestMouseCanvas(TestMouseFrame* parent) : wxPanel(parent,wxID_ANY) {
   _parent = parent;
};

void TestMouseCanvas::dumpMouseData( const char* title, wxMouseEvent& event ) {
   int x1 = GetScreenPosition().x;
   int y1 = GetScreenPosition().y;
   wxMouseState mstate = wxGetMouseState();
   int x2 = mstate.GetX();
   int y2 = mstate.GetY();
   const wxPoint point = wxGetMousePosition();
   int x3 = point.x;
   int y3 = point.y;
   cout << title << ' '
        << x1 << ' ' << y1 << ' '
        << x2 << ' ' << y2 << ' '
        << x3 << ' ' << y3 << ' '
        << endl;
}

void TestMouseCanvas::OnMouseMotionEvent(wxMouseEvent& event) {
   // Used to move the volume level with the mouse movement.
   dumpMouseData( "Mouse Move", event );
}
void TestMouseCanvas::OnMouseLeftDownEvent(wxMouseEvent& event) {
   dumpMouseData( "Left Down", event );
}
void TestMouseCanvas::OnMouseLeftUpEvent(wxMouseEvent& event) {
   dumpMouseData( "Left Up", event );
}
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Touchpad behavior changed on a Dell Venue

Post by doublemax »

Code: Select all

void TestMouseCanvas::dumpMouseData( const char* title, wxMouseEvent& event ) {
   int x1 = GetScreenPosition().x;
   int y1 = GetScreenPosition().y;
   wxMouseState mstate = wxGetMouseState();
   int x2 = mstate.GetX();
   int y2 = mstate.GetY();
   const wxPoint point = wxGetMousePosition();
   int x3 = point.x;
   int y3 = point.y;
   cout << title << ' '
        << x1 << ' ' << y1 << ' '
        << x2 << ' ' << y2 << ' '
        << x3 << ' ' << y3 << ' '
        << endl;
}
You are not even using the data from the event. You are explicitly getting the mouse position.

And you should call event.Skip() in the mouse event handlers.
Use the source, Luke!
djwdg
In need of some credit
In need of some credit
Posts: 9
Joined: Wed Jul 01, 2020 12:23 am

Re: Touchpad behavior changed on a Dell Venue

Post by djwdg »

That did it, thanks. If you dont mind a follow-on question, is there a convenient way to tell if, eg, a EVT_LEFT_DOWN is from a mouse click or a screen touch?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Touchpad behavior changed on a Dell Venue

Post by doublemax »

djwdg wrote: Tue Jul 05, 2022 7:44 pm That did it, thanks. If you dont mind a follow-on question, is there a convenient way to tell if, eg, a EVT_LEFT_DOWN is from a mouse click or a screen touch?
I'm not sure. You could try wxGetMouseState(), the mouse button should not be down if it was from a touch event.

You could also enable wxGestureEvents and check if one gets triggered:
https://docs.wxwidgets.org/trunk/classw ... event.html
(I'm also not sure how well this is implemented on the various platforms)
Use the source, Luke!
djwdg
In need of some credit
In need of some credit
Posts: 9
Joined: Wed Jul 01, 2020 12:23 am

Re: Touchpad behavior changed on a Dell Venue

Post by djwdg »

The LeftIsDown() trick you mentioned worked.

Thanks for all your help.
Post Reply