summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-04-07 10:47:43 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-04-07 10:47:43 (GMT)
commit5a8aaf2df9f92e08e73bfb0d197461355b8dafed (patch)
treed0d76fbc808416d6fbba6af873fd32c89066ae33 /src
parent19a566f82a7c684423331a8caab70ec594afd1ce (diff)
parentb73f1b11bdf953cd1452989b57b24ccc442de111 (diff)
downloadQt-5a8aaf2df9f92e08e73bfb0d197461355b8dafed.zip
Qt-5a8aaf2df9f92e08e73bfb0d197461355b8dafed.tar.gz
Qt-5a8aaf2df9f92e08e73bfb0d197461355b8dafed.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: fix non-bootstrapped qmake build comment out variable which is used only by commented out debug code Cocoa: remove hackish code that is no longer needed Cocoa: mouse release event reports wrong button state Autotest: added more tests to macnativeevents (2) Cocoa: send mouse move event upon a mouse enter Autotest: added more tests to macnativeevents qdoc: Added many png, js, and css files for new format. Test case for QMenu::popup() QMenu::popup() code style fixes fix QMenu::popup() qdoc: Added <div> elements to some html output for Fake nodes.
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qcocoasharedwindowmethods_mac_p.h25
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm30
-rw-r--r--src/gui/kernel/qeventdispatcher_mac.mm34
-rw-r--r--src/gui/kernel/qeventdispatcher_mac_p.h1
-rw-r--r--src/gui/kernel/qt_cocoa_helpers_mac.mm10
-rw-r--r--src/gui/widgets/qmenu.cpp57
6 files changed, 60 insertions, 97 deletions
diff --git a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
index 129e0a5..ec00915 100644
--- a/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
+++ b/src/gui/kernel/qcocoasharedwindowmethods_mac_p.h
@@ -58,7 +58,6 @@ QT_BEGIN_NAMESPACE
extern Qt::MouseButton cocoaButton2QtButton(NSInteger buttonNum); // qcocoaview.mm
extern QPointer<QWidget> qt_button_down; //qapplication_mac.cpp
extern const QStringList& qEnabledDraggedTypes(); // qmime_mac.cpp
-extern bool qt_blockCocoaSettingModalWindowLevel; // qeventdispatcher_mac_p.h
Q_GLOBAL_STATIC(QPointer<QWidget>, currentDragTarget);
@@ -102,30 +101,6 @@ QT_END_NAMESPACE
return !(isPopup || isToolTip || isTool);
}
-- (void)orderWindow:(NSWindowOrderingMode)orderingMode relativeTo:(NSInteger)otherWindowNumber
-{
- if (qt_blockCocoaSettingModalWindowLevel) {
- // To avoid windows popping in front while restoring modal sessions
- // in the event dispatcher, we block cocoa from ordering this window
- // to front. The result of not doing this can be seen if executing
- // a native color dialog on top of another executing dialog.
- return;
- }
- [super orderWindow:orderingMode relativeTo:otherWindowNumber];
-}
-
-- (void)setLevel:(NSInteger)windowLevel
-{
- if (qt_blockCocoaSettingModalWindowLevel) {
- // To avoid windows popping in front while restoring modal sessions
- // in the event dispatcher, we block cocoa from ordering this window
- // to front. The result of not doing this can be seen if executing
- // a native color dialog on top of another executing dialog.
- return;
- }
- [super setLevel:windowLevel];
-}
-
- (void)toggleToolbarShown:(id)sender
{
macSendToolbarChangeEvent([self QT_MANGLE_NAMESPACE(qt_qwidget)]);
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 06eb7ff..9c5380b 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -657,23 +657,33 @@ static int qCocoaViewCount = 0;
{
if (!qwidget)
return;
-
if (qwidgetprivate->data.in_destructor)
return;
- QEvent enterEvent(QEvent::Enter);
- NSPoint windowPoint = [event locationInWindow];
- NSPoint globalPoint = [[event window] convertBaseToScreen:windowPoint];
- NSPoint viewPoint = [self convertPoint:windowPoint fromView:nil];
+
if (!qAppInstance()->activeModalWidget() || QApplicationPrivate::tryModalHelper(qwidget, 0)) {
+ QEvent enterEvent(QEvent::Enter);
+ NSPoint windowPoint = [event locationInWindow];
+ NSPoint globalPoint = [[event window] convertBaseToScreen:windowPoint];
+ NSPoint viewPoint = [self convertPoint:windowPoint fromView:nil];
QApplication::sendEvent(qwidget, &enterEvent);
qt_mouseover = qwidget;
- // Update cursor and dispatch hover events.
+ // Update cursor icon:
qt_mac_update_cursor_at_global_pos(flipPoint(globalPoint).toPoint());
- if (qwidget->testAttribute(Qt::WA_Hover) &&
- (!qAppInstance()->activePopupWidget() || qAppInstance()->activePopupWidget() == qwidget->window())) {
- QHoverEvent he(QEvent::HoverEnter, QPoint(viewPoint.x, viewPoint.y), QPoint(-1, -1));
- QApplicationPrivate::instance()->notify_helper(qwidget, &he);
+
+ // Send mouse move and hover events as well:
+ if (!qAppInstance()->activePopupWidget() || qAppInstance()->activePopupWidget() == qwidget->window()) {
+ if (qwidget->testAttribute(Qt::WA_MouseTracking)) {
+ NSEvent *mouseEvent = [NSEvent mouseEventWithType:NSMouseMoved
+ location:windowPoint modifierFlags:[event modifierFlags] timestamp:[event timestamp]
+ windowNumber:[event windowNumber] context:[event context] eventNumber:[event eventNumber]
+ clickCount:0 pressure:0];
+ qt_mac_handleMouseEvent(self, mouseEvent, QEvent::MouseMove, Qt::NoButton);
+ }
+ if (qwidget->testAttribute(Qt::WA_Hover)) {
+ QHoverEvent he(QEvent::HoverEnter, QPoint(viewPoint.x, viewPoint.y), QPoint(-1, -1));
+ QApplicationPrivate::instance()->notify_helper(qwidget, &he);
+ }
}
}
}
diff --git a/src/gui/kernel/qeventdispatcher_mac.mm b/src/gui/kernel/qeventdispatcher_mac.mm
index a7f1224..0d93b9f 100644
--- a/src/gui/kernel/qeventdispatcher_mac.mm
+++ b/src/gui/kernel/qeventdispatcher_mac.mm
@@ -97,11 +97,6 @@ QT_BEGIN_NAMESPACE
QT_USE_NAMESPACE
/*****************************************************************************
- Internal variables and functions
- *****************************************************************************/
-bool qt_blockCocoaSettingModalWindowLevel = false;
-
-/*****************************************************************************
Externals
*****************************************************************************/
extern void qt_event_request_timer(MacTimerInfo *); //qapplication_mac.cpp
@@ -752,7 +747,6 @@ bool QEventDispatcherMacPrivate::interrupt = false;
#ifdef QT_MAC_USE_COCOA
QStack<QCocoaModalSessionInfo> QEventDispatcherMacPrivate::cocoaModalSessionStack;
bool QEventDispatcherMacPrivate::currentExecIsNSAppRun = false;
-bool QEventDispatcherMacPrivate::modalSessionsTemporarilyStopped = false;
bool QEventDispatcherMacPrivate::nsAppRunCalledByQt = false;
bool QEventDispatcherMacPrivate::cleanupModalSessionsNeeded = false;
NSModalSession QEventDispatcherMacPrivate::currentModalSessionCached = 0;
@@ -788,19 +782,14 @@ void QEventDispatcherMacPrivate::temporarilyStopAllModalSessions()
// we need to stop all the modal session first. To avoid changing
// the stacking order of the windows while doing so, we put
// up a block that is used in QCocoaWindow and QCocoaPanel:
- QBoolBlocker block1(blockSendPostedEvents, true);
- QBoolBlocker block2(qt_blockCocoaSettingModalWindowLevel, true);
-
int stackSize = cocoaModalSessionStack.size();
for (int i=stackSize-1; i>=0; --i) {
QCocoaModalSessionInfo &info = cocoaModalSessionStack[i];
if (info.session) {
- [NSApp runModalSession:info.session];
[NSApp endModalSession:info.session];
info.session = 0;
}
}
- modalSessionsTemporarilyStopped = true;
currentModalSessionCached = 0;
}
@@ -834,29 +823,12 @@ NSModalSession QEventDispatcherMacPrivate::currentModalSession()
// When creating a modal session cocoa will rearrange the windows.
// In order to avoid windows to be put behind another we need to
// keep the window level.
- {
- int level = [window level];
- info.session = [NSApp beginModalSessionForWindow:window];
- [window setLevel:level];
- }
+ int level = [window level];
+ info.session = [NSApp beginModalSessionForWindow:window];
+ [window setLevel:level];
}
currentModalSessionCached = info.session;
}
-
- if (modalSessionsTemporarilyStopped && currentModalSessionCached) {
- // After a call to temporarilyStopAllModalSessions, cocoa have
- // now posted events to restore ended modal session windows to
- // the correct window level. Those events will be processed
- // _after_ our new calls to beginModalSessionForWindow have
- // taken effect, which will end up stacking the windows wrong on
- // screen. To work around this, we block cocoa from changing the
- // stacking order of the windows, and flush out the pending events
- // (the block is used in QCocoaWindow and QCocoaPanel):
- QBoolBlocker block1(blockSendPostedEvents, true);
- QBoolBlocker block2(qt_blockCocoaSettingModalWindowLevel, true);
- [NSApp runModalSession:currentModalSessionCached];
- }
- modalSessionsTemporarilyStopped = false;
return currentModalSessionCached;
}
diff --git a/src/gui/kernel/qeventdispatcher_mac_p.h b/src/gui/kernel/qeventdispatcher_mac_p.h
index 8ac7c65..a0afb84 100644
--- a/src/gui/kernel/qeventdispatcher_mac_p.h
+++ b/src/gui/kernel/qeventdispatcher_mac_p.h
@@ -176,7 +176,6 @@ public:
static bool currentExecIsNSAppRun;
static bool nsAppRunCalledByQt;
static bool cleanupModalSessionsNeeded;
- static bool modalSessionsTemporarilyStopped;
static NSModalSession currentModalSessionCached;
static NSModalSession currentModalSession();
static void updateChildrenWorksWhenModal();
diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm
index b1e4c94..a05c7d5 100644
--- a/src/gui/kernel/qt_cocoa_helpers_mac.mm
+++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm
@@ -882,7 +882,15 @@ void qt_mac_dispatchNCMouseMessage(void * /* NSWindow* */eventWindow, void * /*
}
}
- QMouseEvent qme(eventType, qlocalPoint, qglobalPoint, button, button, keyMods);
+ Qt::MouseButtons buttons = 0;
+ {
+ UInt32 mac_buttons;
+ if (GetEventParameter((EventRef)[event eventRef], kEventParamMouseChord, typeUInt32, 0,
+ sizeof(mac_buttons), 0, &mac_buttons) == noErr)
+ buttons = qt_mac_get_buttons(mac_buttons);
+ }
+
+ QMouseEvent qme(eventType, qlocalPoint, qglobalPoint, button, buttons, keyMods);
qt_sendSpontaneousEvent(widgetToGetEvent, &qme);
// We don't need to set the implicit grab widget here because we won't
diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index 404d46e..b752ae2 100644
--- a/src/gui/widgets/qmenu.cpp
+++ b/src/gui/widgets/qmenu.cpp
@@ -1803,7 +1803,7 @@ QSize QMenu::sizeHint() const
void QMenu::popup(const QPoint &p, QAction *atAction)
{
Q_D(QMenu);
- if (d->scroll) { //reset scroll state from last popup
+ if (d->scroll) { // reset scroll state from last popup
d->scroll->scrollOffset = 0;
d->scroll->scrollFlags = QMenuPrivate::QMenuScroller::ScrollNone;
}
@@ -1858,9 +1858,9 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
}
#endif
if (d->ncols > 1) {
- pos.setY(screen.top()+desktopFrame);
+ pos.setY(screen.top() + desktopFrame);
} else if (atAction) {
- for(int i = 0, above_height = 0; i < d->actions.count(); i++) {
+ for (int i = 0, above_height = 0; i < d->actions.count(); i++) {
QAction *action = d->actions.at(i);
if (action == atAction) {
int newY = pos.y() - above_height;
@@ -1875,7 +1875,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
if (d->scroll && d->scroll->scrollFlags != QMenuPrivate::QMenuScroller::ScrollNone
&& !style()->styleHint(QStyle::SH_Menu_FillScreenWithScroll, 0, this)) {
int below_height = above_height + d->scroll->scrollOffset;
- for(int i2 = i; i2 < d->actionRects.count(); i2++)
+ for (int i2 = i; i2 < d->actionRects.count(); i2++)
below_height += d->actionRects.at(i2).height();
size.setHeight(below_height);
}
@@ -1888,49 +1888,48 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
QPoint mouse = QCursor::pos();
d->mousePopupPos = mouse;
- const bool snapToMouse = (QRect(p.x()-3, p.y()-3, 6, 6).contains(mouse));
+ const bool snapToMouse = (QRect(p.x() - 3, p.y() - 3, 6, 6).contains(mouse));
if (adjustToDesktop) {
- //handle popup falling "off screen"
+ // handle popup falling "off screen"
if (isRightToLeft()) {
- if(snapToMouse) //position flowing left from the mouse
- pos.setX(mouse.x()-size.width());
+ if (snapToMouse) // position flowing left from the mouse
+ pos.setX(mouse.x() - size.width());
#ifndef QT_NO_MENUBAR
- //if in a menubar, it should be right-aligned
+ // if in a menubar, it should be right-aligned
if (qobject_cast<QMenuBar*>(d->causedPopup.widget))
pos.rx() -= size.width();
#endif //QT_NO_MENUBAR
- if (pos.x() < screen.left()+desktopFrame)
- pos.setX(qMax(p.x(), screen.left()+desktopFrame));
- if (pos.x()+size.width()-1 > screen.right()-desktopFrame)
- pos.setX(qMax(p.x()-size.width(), screen.right()-desktopFrame-size.width()+1));
+ if (pos.x() < screen.left() + desktopFrame)
+ pos.setX(qMax(p.x(), screen.left() + desktopFrame));
+ if (pos.x() + size.width() - 1 > screen.right() - desktopFrame)
+ pos.setX(qMax(p.x() - size.width(), screen.right() - desktopFrame - size.width() + 1));
} else {
- if (pos.x()+size.width()-1 > screen.right()-desktopFrame)
- pos.setX(screen.right()-desktopFrame-size.width()+1);
- if (pos.x() < screen.left()+desktopFrame)
+ if (pos.x() + size.width() - 1 > screen.right() - desktopFrame)
+ pos.setX(screen.right() - desktopFrame - size.width() + 1);
+ if (pos.x() < screen.left() + desktopFrame)
pos.setX(screen.left() + desktopFrame);
}
if (pos.y() + size.height() - 1 > screen.bottom() - desktopFrame) {
- if(snapToMouse)
- pos.setY(qMin(mouse.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1));
- else
- pos.setY(qMax(p.y() - (size.height() + desktopFrame), screen.bottom()-desktopFrame-size.height()+1));
+ const int bestPos = (snapToMouse ? mouse.y() : p.y()) - desktopFrame - size.height() + 1;
+ const int fallbackPos = screen.bottom() - desktopFrame - size.height() + 1;
+ pos.setY(qMin(bestPos, fallbackPos));
} else if (pos.y() < screen.top() + desktopFrame) {
pos.setY(screen.top() + desktopFrame);
}
if (pos.y() < screen.top() + desktopFrame)
pos.setY(screen.top() + desktopFrame);
- if (pos.y()+size.height()-1 > screen.bottom() - desktopFrame) {
+ if (pos.y() + size.height() - 1 > screen.bottom() - desktopFrame) {
if (d->scroll) {
d->scroll->scrollFlags |= uint(QMenuPrivate::QMenuScroller::ScrollDown);
int y = qMax(screen.y(),pos.y());
- size.setHeight(screen.bottom()-(desktopFrame*2)-y);
+ size.setHeight(screen.bottom() - (desktopFrame * 2) - y);
} else {
// Too big for screen, bias to see bottom of menu (for some reason)
- pos.setY(screen.bottom()-size.height()+1);
+ pos.setY(screen.bottom() - size.height() + 1);
}
}
}
@@ -1939,19 +1938,19 @@ void QMenu::popup(const QPoint &p, QAction *atAction)
int hGuess = isRightToLeft() ? QEffects::LeftScroll : QEffects::RightScroll;
int vGuess = QEffects::DownScroll;
if (isRightToLeft()) {
- if ((snapToMouse && (pos.x() + size.width()/2 > mouse.x())) ||
- (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width()/2 > d->causedPopup.widget->x()))
+ if ((snapToMouse && (pos.x() + size.width() / 2 > mouse.x())) ||
+ (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() / 2 > d->causedPopup.widget->x()))
hGuess = QEffects::RightScroll;
} else {
- if ((snapToMouse && (pos.x() + size.width()/2 < mouse.x())) ||
- (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width()/2 < d->causedPopup.widget->x()))
+ if ((snapToMouse && (pos.x() + size.width() / 2 < mouse.x())) ||
+ (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width() / 2 < d->causedPopup.widget->x()))
hGuess = QEffects::LeftScroll;
}
#ifndef QT_NO_MENUBAR
- if ((snapToMouse && (pos.y() + size.height()/2 < mouse.y())) ||
+ if ((snapToMouse && (pos.y() + size.height() / 2 < mouse.y())) ||
(qobject_cast<QMenuBar*>(d->causedPopup.widget) &&
- pos.y() + size.width()/2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y()))
+ pos.y() + size.width() / 2 < d->causedPopup.widget->mapToGlobal(d->causedPopup.widget->pos()).y()))
vGuess = QEffects::UpScroll;
#endif
if (QApplication::isEffectEnabled(Qt::UI_AnimateMenu)) {