Re: [SOLVED] Detachable QDockWidget tabs
Continuing with the OS X tests, on that 1.2 project please replace the contents of the sendMouseMoveEvent function in the SendOSMouseEvent.mm file with the following.
The modifications to SendOSMouseEvent.mm are the header of 'ApplicationServices' and the content of 'sendMouseMoveEvent.'
Code:
#import <Cocoa/Cocoa.h>
#import <CoreFoundation/CoreFoundation.h>
#import <ApplicationServices/ApplicationServices.h>
#import "sendOSMouseEvent.h"
void sendMousePressEvent(int x, int y) {
CGPoint location = CGPointMake(x, y);
CGEventRef mouseDown = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseDown, location, kCGMouseButtonLeft);
CGEventPost(kCGHIDEventTap, mouseDown);
CFRelease(mouseDown);
}
void sendMouseReleaseEvent(int x, int y) {
CGPoint location = CGPointMake(x, y);
CGEventRef mouseUp = CGEventCreateMouseEvent(NULL, kCGEventLeftMouseUp, location, kCGMouseButtonLeft);
CGEventPost(kCGHIDEventTap, mouseUp);
CFRelease(mouseUp);
}
void sendMouseMoveEvent(int x, int y) {
CGPoint location = CGPointMake(x, y);
CGError ret = CGWarpMouseCursorPosition(location); // Move the mouse without generating a mouse move or drag event.
if (ret == kCGErrorSuccess)
CGAssociateMouseAndMouseCursorPosition(true); // If successful, re-associate mouse and cursor position to avoid a delay.
}
It uses CGWarpMouseCursorPosition, which seems like a better solution that changes the mouse location without emitting events at all.
What's left is to test this detachable dock system with a Wacom (or other brand) digitizer tablet.
Re: [SOLVED] Detachable QDockWidget tabs
It still doesn't work. Both the output and the stack trace seem same.
Does it work on your Mac?
Code:
QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)
The program has unexpectedly finished.
Re: [SOLVED] Detachable QDockWidget tabs
Hello.
I don't have a Mac, so I was infering solutions based on what you reported.
That Q_ASSERT_X in the eventFilter of project 1.2 (make sure you're using that, for information) and the CGWarpMouseCursorPosition from the modification above are all I can think of, for the moment. Thank you for testing.
Re: [SOLVED] Detachable QDockWidget tabs
For me when I drag the tab, it seems to trigger the resize event for the floated dock widget.
Anyone else have the same?
Win7
Re: [SOLVED] Detachable QDockWidget tabs
I wrote that under Windows XP and it was working there.
Now I tested under Windows 8.1 and I'm having the same as you: the widget is entering resize mode once it's detached.
The reason for that is the function "DetachableDock::centreTitle," it tries to compute the title bar height based on 'frameGeometry - geometry.' But they're both the same value, so the title bar is not being properly centered on the mouse cursor. According to the documentation it should be working, so we'll need to find a different way to estimate the title bar height.
EDIT: Alright, here's the solution (thanks to this fellow Qt user)
Inside "DetachableDock::centreTitle" in DetachableDock.cpp, add the following:
Code:
#include <QStyle> // Add this include at the top, with the other includes.
[...]
void DetachableDock
::centreTitle( QPoint here
) {
int centreTitleX = frameGeometry().width() / 2;
int centreTitleY
= style
()->pixelMetric
( QStyle::PM_TitleBarHeight,
0,
this ) / 2;
// Corrected line, it uses the standard pixel metric.
QPoint centreTitlePos
= here
- QPoint( centreTitleX, centreTitleY
);
move( centreTitlePos );
}
While this fixes the detaching, the docking back doesn't seem to work anymore under Windows 8.1.
The standard dock widgets example works fine, so it's this customisation that is broken.
Re: [SOLVED] Detachable QDockWidget tabs
I have tried implement sendOSMouseEvent() for UBUNTU 14 as below, But it DO NOT run correctly, any one please help me...
Code:
void sendOSMouseEvent( SynthMouseEvent eventType, int x, int y )
{
// Create and setting up the event
Display *display = XOpenDisplay(NULL);
// Create and setting up the event
XEvent event;
memset (&event, 0, sizeof (event));
event.xbutton.button = Button1;
event.xbutton.x = x;
event.xbutton.y = y;
event.xbutton.same_screen = True;
event.xbutton.subwindow = DefaultRootWindow (display);
while (event.xbutton.subwindow)
{
event.xbutton.window = event.xbutton.subwindow;
XQueryPointer (display, event.xbutton.window,
&event.xbutton.root, &event.xbutton.subwindow,
&event.xbutton.x_root, &event.xbutton.y_root,
&event.xbutton.x, &event.xbutton.y,
&event.xbutton.state);
}
switch ( eventType )
{
case MousePress:
// Send a Windows left mouse button press event using SendInput.
event.type = ButtonPress;
if (XSendEvent (display, PointerWindow, True, ButtonPressMask, &event) == 0)
qDebug("Error to send the event!");
XFlush (display);
break;
case MouseRelease:
// Send a Windows left mouse button release event using SendInput.
event.type = ButtonRelease;
if (XSendEvent (display, PointerWindow, True, ButtonReleaseMask, &event) == 0)
qDebug("Error to send the event!");
XFlush (display);
break;
case MouseMove:
// Not used right now.
break;
}
}