зеркало из https://github.com/mozilla/gecko-dev.git
New approach, better approach, popups disappearing after a click, just cooler...
Like it still won't get me chicks but is closer to that goal (i got into mozilla because of false promises of women)
This commit is contained in:
Родитель
ee1db06bac
Коммит
8ab3d601bb
|
@ -43,7 +43,7 @@ REQUIRES = xpcom \
|
|||
appshell \
|
||||
pref \
|
||||
uconv \
|
||||
necko \
|
||||
necko \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
|
@ -60,16 +60,18 @@ CPPSRCS = \
|
|||
nsSound.cpp \
|
||||
nsToolkit.cpp \
|
||||
nsWidgetFactory.cpp \
|
||||
nsScrollbar.cpp \
|
||||
nsWindow.cpp \
|
||||
nsFilePicker.cpp \
|
||||
nsScrollbar.cpp \
|
||||
nsWindow.cpp \
|
||||
nsFilePicker.cpp \
|
||||
mozqwidget.cpp \
|
||||
$(NULL)
|
||||
|
||||
MOCSRCS = \
|
||||
moc_nsMime.cpp \
|
||||
moc_nsEventQueueWatcher.cpp \
|
||||
moc_nsQtEventDispatcher.cpp \
|
||||
moc_nsScrollbar.cpp \
|
||||
moc_nsQtEventDispatcher.cpp \
|
||||
moc_nsScrollbar.cpp \
|
||||
moc_mozqwidget.cpp \
|
||||
$(NULL)
|
||||
|
||||
SHARED_LIBRARY_LIBS = $(DIST)/lib/libxpwidgets_s.a
|
||||
|
@ -98,7 +100,7 @@ DEFINES += -D_IMPL_NS_WIDGET
|
|||
ifeq ($(OS_ARCH), Linux)
|
||||
DEFINES += -D_BSD_SOURCE
|
||||
endif
|
||||
ifeq ($(OS_ARCH), SunOS)
|
||||
ifeq ($(OS_ARCH), SunOS)
|
||||
ifndef GNU_CC
|
||||
# When using Sun's WorkShop compiler, including
|
||||
# /wherever/workshop-5.0/SC5.0/include/CC/std/time.h
|
||||
|
|
|
@ -0,0 +1,180 @@
|
|||
#include "mozqwidget.h"
|
||||
|
||||
#include "nsCommonWidget.h"
|
||||
|
||||
#include <qevent.h>
|
||||
|
||||
MozQWidget::MozQWidget(nsCommonWidget *receiver, QWidget *parent,
|
||||
const char *name, WFlags f)
|
||||
: QWidget(parent, name, f),
|
||||
mReceiver(receiver)
|
||||
{
|
||||
}
|
||||
|
||||
bool MozQWidget::event(QEvent *e)
|
||||
{
|
||||
bool ignore = false;
|
||||
switch(e->type()) {
|
||||
case QEvent::Accessibility:
|
||||
{
|
||||
qDebug("accessibility event received");
|
||||
}
|
||||
break;
|
||||
case QEvent::MouseButtonPress:
|
||||
{
|
||||
QMouseEvent *ms = (QMouseEvent*)(e);
|
||||
ignore = mReceiver->mousePressEvent(ms);
|
||||
}
|
||||
break;
|
||||
case QEvent::MouseButtonRelease:
|
||||
{
|
||||
QMouseEvent *ms = (QMouseEvent*)(e);
|
||||
ignore = mReceiver->mouseReleaseEvent(ms);
|
||||
}
|
||||
break;
|
||||
case QEvent::MouseButtonDblClick:
|
||||
{
|
||||
QMouseEvent *ms = (QMouseEvent*)(e);
|
||||
ignore = mReceiver->mouseDoubleClickEvent(ms);
|
||||
}
|
||||
break;
|
||||
case QEvent::MouseMove:
|
||||
{
|
||||
QMouseEvent *ms = (QMouseEvent*)(e);
|
||||
ignore = mReceiver->mouseMoveEvent(ms);
|
||||
}
|
||||
break;
|
||||
case QEvent::KeyPress:
|
||||
{
|
||||
QKeyEvent *kev = (QKeyEvent*)(e);
|
||||
ignore = mReceiver->keyPressEvent(kev);
|
||||
}
|
||||
break;
|
||||
case QEvent::KeyRelease:
|
||||
{
|
||||
QKeyEvent *kev = (QKeyEvent*)(e);
|
||||
ignore = mReceiver->keyReleaseEvent(kev);
|
||||
}
|
||||
break;
|
||||
case QEvent::IMStart:
|
||||
{
|
||||
QIMEvent *iev = (QIMEvent*)(e);
|
||||
ignore = mReceiver->imStartEvent(iev);
|
||||
}
|
||||
break;
|
||||
case QEvent::IMCompose:
|
||||
{
|
||||
QIMEvent *iev = (QIMEvent*)(e);
|
||||
ignore = mReceiver->imComposeEvent(iev);
|
||||
}
|
||||
break;
|
||||
case QEvent::IMEnd:
|
||||
{
|
||||
QIMEvent *iev = (QIMEvent*)(e);
|
||||
ignore = mReceiver->imEndEvent(iev);
|
||||
}
|
||||
break;
|
||||
case QEvent::FocusIn:
|
||||
{
|
||||
QFocusEvent *fev = (QFocusEvent*)(e);
|
||||
mReceiver->focusInEvent(fev);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
case QEvent::FocusOut:
|
||||
{
|
||||
QFocusEvent *fev = (QFocusEvent*)(e);
|
||||
mReceiver->focusOutEvent(fev);
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
case QEvent::Enter:
|
||||
{
|
||||
ignore = mReceiver->enterEvent(e);
|
||||
}
|
||||
break;
|
||||
case QEvent::Leave:
|
||||
{
|
||||
ignore = mReceiver->enterEvent(e);
|
||||
}
|
||||
break;
|
||||
case QEvent::Paint:
|
||||
{
|
||||
QPaintEvent *ev = (QPaintEvent*)(e);
|
||||
mReceiver->paintEvent(ev);
|
||||
}
|
||||
break;
|
||||
case QEvent::Move:
|
||||
{
|
||||
QMoveEvent *mev = (QMoveEvent*)(e);
|
||||
ignore = mReceiver->moveEvent(mev);
|
||||
}
|
||||
break;
|
||||
case QEvent::Resize:
|
||||
{
|
||||
QResizeEvent *rev = (QResizeEvent*)(e);
|
||||
ignore = mReceiver->resizeEvent(rev);
|
||||
}
|
||||
break;
|
||||
case QEvent::Show:
|
||||
{
|
||||
QShowEvent *sev = (QShowEvent*)(e);
|
||||
mReceiver->showEvent(sev);
|
||||
}
|
||||
break;
|
||||
case QEvent::Hide:
|
||||
{
|
||||
QHideEvent *hev = (QHideEvent*)(e);
|
||||
ignore = mReceiver->hideEvent(hev);
|
||||
}
|
||||
break;
|
||||
case QEvent::Close:
|
||||
{
|
||||
QCloseEvent *cev = (QCloseEvent*)(e);
|
||||
ignore = mReceiver->closeEvent(cev);
|
||||
}
|
||||
break;
|
||||
case QEvent::Wheel:
|
||||
{
|
||||
QWheelEvent *wev = (QWheelEvent*)(e);
|
||||
ignore = mReceiver->wheelEvent(wev);
|
||||
}
|
||||
break;
|
||||
case QEvent::ContextMenu:
|
||||
{
|
||||
QContextMenuEvent *cev = (QContextMenuEvent*)(e);
|
||||
ignore = mReceiver->contextMenuEvent(cev);
|
||||
}
|
||||
break;
|
||||
case QEvent::DragEnter:
|
||||
{
|
||||
QDragEnterEvent *dev = (QDragEnterEvent*)(e);
|
||||
ignore = mReceiver->dragEnterEvent(dev);
|
||||
}
|
||||
break;
|
||||
case QEvent::DragMove:
|
||||
{
|
||||
QDragMoveEvent *dev = (QDragMoveEvent*)(e);
|
||||
ignore = mReceiver->dragMoveEvent(dev);
|
||||
}
|
||||
break;
|
||||
case QEvent::DragLeave:
|
||||
{
|
||||
QDragLeaveEvent *dev = (QDragLeaveEvent*)(e);
|
||||
ignore = mReceiver->dragLeaveEvent(dev);
|
||||
}
|
||||
break;
|
||||
case QEvent::Drop:
|
||||
{
|
||||
QDropEvent *dev = (QDropEvent*)(e);
|
||||
ignore = mReceiver->dropEvent(dev);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
QWidget::event(e);
|
||||
|
||||
return !ignore;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
#ifndef MOZQWIDGET_H
|
||||
#define MOZQWIDGET_H
|
||||
|
||||
#include <qwidget.h>
|
||||
|
||||
class QEvent;
|
||||
class nsCommonWidget;
|
||||
|
||||
class MozQWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MozQWidget(nsCommonWidget *receiver, QWidget *parent,
|
||||
const char *name, WFlags f);
|
||||
protected:
|
||||
virtual bool event(QEvent *ev);
|
||||
private:
|
||||
nsCommonWidget *mReceiver;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -282,7 +282,8 @@ nsCommonWidget::Show(PRBool aState)
|
|||
|
||||
if (mContainer)
|
||||
mContainer->setShown(aState);
|
||||
mWidget->setShown(aState);
|
||||
else
|
||||
mWidget->setShown(aState);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -461,8 +462,12 @@ nsCommonWidget::IsEnabled(PRBool *aState)
|
|||
NS_IMETHODIMP
|
||||
nsCommonWidget::SetFocus(PRBool aSet)
|
||||
{
|
||||
if (mWidget && aSet)
|
||||
mWidget->setFocus();
|
||||
if (mWidget) {
|
||||
if (aSet)
|
||||
mWidget->setFocus();
|
||||
else
|
||||
mWidget->clearFocus();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -753,7 +758,7 @@ nsCommonWidget::DispatchResizeEvent(nsRect &aRect, nsEventStatus &aStatus)
|
|||
bool
|
||||
nsCommonWidget::mousePressEvent(QMouseEvent *e)
|
||||
{
|
||||
//qDebug("mousePressEvent mWidget=%p", (void*)mWidget);
|
||||
qDebug("mousePressEvent mWidget=%p", (void*)mWidget);
|
||||
// backTrace();
|
||||
PRUint32 eventType;
|
||||
|
||||
|
@ -783,13 +788,13 @@ nsCommonWidget::mousePressEvent(QMouseEvent *e)
|
|||
DispatchEvent(&contextMenuEvent, status);
|
||||
}
|
||||
|
||||
return TRUE;//ignoreEvent(status);
|
||||
return ignoreEvent(status);
|
||||
}
|
||||
|
||||
bool
|
||||
nsCommonWidget::mouseReleaseEvent(QMouseEvent *e)
|
||||
{
|
||||
//qDebug("mouseReleaseEvent mWidget=%p", (void*)mWidget);
|
||||
qDebug("mouseReleaseEvent mWidget=%p", (void*)mWidget);
|
||||
PRUint32 eventType;
|
||||
|
||||
switch (e->button()) {
|
||||
|
@ -811,7 +816,7 @@ nsCommonWidget::mouseReleaseEvent(QMouseEvent *e)
|
|||
//not pressed
|
||||
nsEventStatus status;
|
||||
DispatchEvent(&event, status);
|
||||
return TRUE;//ignoreEvent(status);
|
||||
return ignoreEvent(status);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -837,7 +842,7 @@ nsCommonWidget::mouseDoubleClickEvent(QMouseEvent *e)
|
|||
//pressed
|
||||
nsEventStatus status;
|
||||
DispatchEvent(&event, status);
|
||||
return TRUE;//ignoreEvent(status);
|
||||
return ignoreEvent(status);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -848,7 +853,7 @@ nsCommonWidget::mouseMoveEvent(QMouseEvent *e)
|
|||
InitMouseEvent(&event, e, 0);
|
||||
nsEventStatus status;
|
||||
DispatchEvent(&event, status);
|
||||
return TRUE;//ignoreEvent(status);
|
||||
return ignoreEvent(status);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -860,7 +865,7 @@ nsCommonWidget::wheelEvent(QWheelEvent *e)
|
|||
|
||||
nsEventStatus status;
|
||||
DispatchEvent(&nsEvent, status);
|
||||
return TRUE;//ignoreEvent(status);
|
||||
return ignoreEvent(status);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -900,7 +905,7 @@ nsCommonWidget::keyPressEvent(QKeyEvent *e)
|
|||
DispatchEvent(&event, status);
|
||||
}
|
||||
|
||||
return TRUE;//ignoreEvent(status);
|
||||
return ignoreEvent(status);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -912,7 +917,7 @@ nsCommonWidget::keyReleaseEvent(QKeyEvent *e)
|
|||
|
||||
nsEventStatus status;
|
||||
DispatchEvent(&event, status);
|
||||
return TRUE;//ignoreEvent(status);
|
||||
return ignoreEvent(status);
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -933,7 +938,7 @@ nsCommonWidget::focusInEvent(QFocusEvent *)
|
|||
bool
|
||||
nsCommonWidget::focusOutEvent(QFocusEvent *)
|
||||
{
|
||||
//qDebug("focusOutEvent mWidget=%p", (void*)mWidget);
|
||||
qDebug("focusOutEvent mWidget=%p", (void*)mWidget);
|
||||
DispatchLostFocusEvent();
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -943,6 +948,11 @@ nsCommonWidget::enterEvent(QEvent *)
|
|||
{
|
||||
nsMouseEvent event(NS_MOUSE_ENTER, this);
|
||||
|
||||
QPoint pt = QCursor::pos();
|
||||
|
||||
event.point.x = nscoord(pt.x());
|
||||
event.point.y = nscoord(pt.y());
|
||||
|
||||
nsEventStatus status;
|
||||
DispatchEvent(&event, status);
|
||||
return FALSE;
|
||||
|
@ -953,6 +963,11 @@ nsCommonWidget::leaveEvent(QEvent *aEvent)
|
|||
{
|
||||
nsMouseEvent event(NS_MOUSE_EXIT, this);
|
||||
|
||||
QPoint pt = QCursor::pos();
|
||||
|
||||
event.point.x = nscoord(pt.x());
|
||||
event.point.y = nscoord(pt.y());
|
||||
|
||||
nsEventStatus status;
|
||||
DispatchEvent(&event, status);
|
||||
return FALSE;
|
||||
|
@ -961,8 +976,8 @@ nsCommonWidget::leaveEvent(QEvent *aEvent)
|
|||
bool
|
||||
nsCommonWidget::paintEvent(QPaintEvent *e)
|
||||
{
|
||||
//qDebug("paintEvent: mWidget=%p x = %d, y = %d, width = %d, height = %d", (void*)mWidget,
|
||||
//e->rect().x(), e->rect().y(), e->rect().width(), e->rect().height());
|
||||
qDebug("paintEvent: mWidget=%p x = %d, y = %d, width = %d, height = %d", (void*)mWidget,
|
||||
e->rect().x(), e->rect().y(), e->rect().width(), e->rect().height());
|
||||
// qDebug("paintEvent: Widgetrect %d %d %d %d", mWidget->x(), mWidget->y(),
|
||||
// mWidget->width(), mWidget->height());
|
||||
|
||||
|
|
|
@ -133,6 +133,8 @@ protected:
|
|||
* They follow normal Qt widget semantics.
|
||||
*/
|
||||
friend class nsQtEventDispatcher;
|
||||
friend class InterceptContainer;
|
||||
friend class MozQWidget;
|
||||
|
||||
virtual bool mousePressEvent(QMouseEvent *);
|
||||
virtual bool mouseReleaseEvent(QMouseEvent *);
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsWindow.h"
|
||||
|
||||
#include "nsQtEventDispatcher.h"
|
||||
#include "mozqwidget.h"
|
||||
|
||||
#include <qvbox.h>
|
||||
#include <qwidget.h>
|
||||
|
@ -60,9 +60,8 @@ QWidget*
|
|||
nsWindow::createQWidget(QWidget *parent, nsWidgetInitData *aInitData)
|
||||
{
|
||||
Qt::WFlags flags = Qt::WNoAutoErase|Qt::WStaticContents;
|
||||
qDebug("\tparent is %p", (void*)parent);
|
||||
if (parent)
|
||||
parent->dumpObjectInfo();
|
||||
qDebug("NEW WIDGET\n\tparent is %p (%s)", (void*)parent,
|
||||
parent ? parent->name() : "null");
|
||||
// ok, create our windows
|
||||
switch (mWindowType) {
|
||||
case eWindowType_dialog:
|
||||
|
@ -72,32 +71,27 @@ nsWindow::createQWidget(QWidget *parent, nsWidgetInitData *aInitData)
|
|||
if (mWindowType == eWindowType_dialog) {
|
||||
flags |= Qt::WType_Dialog;
|
||||
qDebug("\t\t#### dialog");
|
||||
mContainer = new QWidget(parent, "topLevelDialog", flags);
|
||||
mContainer = new MozQWidget(this, parent, "topLevelDialog", flags);
|
||||
//SetDefaultIcon();
|
||||
}
|
||||
else if (mWindowType == eWindowType_popup) {
|
||||
flags |= Qt::WType_Popup;
|
||||
mContainer = new QWidget(parent, "topLevelPopup", flags);
|
||||
mContainer = new MozQWidget(this, parent, "topLevelPopup", flags);
|
||||
qDebug("\t\t#### popup");
|
||||
mContainer->setFocusPolicy(QWidget::WheelFocus);
|
||||
}
|
||||
else { // must be eWindowType_toplevel
|
||||
flags |= Qt::WType_TopLevel;
|
||||
qDebug("\t\t#### toplevel");
|
||||
mContainer = new QWidget(parent, "topLevelWindow", flags);
|
||||
mContainer = new MozQWidget(this, parent, "topLevelWindow", flags);
|
||||
//SetDefaultIcon();
|
||||
}
|
||||
|
||||
//QBoxLayout *l = new QVBoxLayout(mContainer);
|
||||
// and the drawing area
|
||||
//mWidget = new QWidget(mContainer, "paintArea");
|
||||
//l->addWidget(mWidget);
|
||||
mWidget = mContainer;
|
||||
}
|
||||
break;
|
||||
case eWindowType_child: {
|
||||
qDebug("\t\t#### child");
|
||||
mWidget = new QWidget(parent, "paintArea");
|
||||
mWidget = new MozQWidget(this, parent, "paintArea", 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -106,9 +100,6 @@ nsWindow::createQWidget(QWidget *parent, nsWidgetInitData *aInitData)
|
|||
|
||||
mWidget->setBackgroundMode(Qt::NoBackground);
|
||||
|
||||
// attach listeners for events
|
||||
mDispatcher = new nsQtEventDispatcher(this, mWidget, "xxxdispatcher", true);
|
||||
|
||||
return mWidget;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче