зеркало из https://github.com/mozilla/gecko-dev.git
Bug 552982, Part 9, support close buttons on popups with titlebars, r=neil
This commit is contained in:
Родитель
0033285038
Коммит
f9a7385f55
|
@ -468,6 +468,11 @@ public:
|
|||
PRBool aAsynchronous,
|
||||
nsIContent* aLastPopup = nsnull);
|
||||
|
||||
/**
|
||||
* Hide the popup associated the view aView
|
||||
*/
|
||||
void HidePopup(nsIView* aView);
|
||||
|
||||
/**
|
||||
* Hide a popup after a short delay. This is used when rolling over menu items.
|
||||
* This timer is stored in mCloseTimer. The timer may be cancelled and the popup
|
||||
|
|
|
@ -280,6 +280,12 @@ nsMenuPopupFrame::CreateWidgetForView(nsIView* aView)
|
|||
widgetData.mBorderStyle = eBorderStyle_title;
|
||||
|
||||
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::label, title);
|
||||
|
||||
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::close,
|
||||
nsGkAtoms::_true, eCaseMatters)) {
|
||||
widgetData.mBorderStyle =
|
||||
static_cast<enum nsBorderStyle>(widgetData.mBorderStyle | eBorderStyle_close);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -906,6 +906,16 @@ nsXULPopupManager::HidePopupCallback(nsIContent* aPopup,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsXULPopupManager::HidePopup(nsIView* aView)
|
||||
{
|
||||
nsIFrame *frame = static_cast<nsIFrame *>(aView->GetClientData());
|
||||
if (!frame || frame->GetType() != nsGkAtoms::menuPopupFrame)
|
||||
return;
|
||||
|
||||
HidePopup(frame->GetContent(), PR_FALSE, PR_TRUE, PR_FALSE);
|
||||
}
|
||||
|
||||
void
|
||||
nsXULPopupManager::HidePopupAfterDelay(nsMenuPopupFrame* aPopup)
|
||||
{
|
||||
|
|
|
@ -790,6 +790,25 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
|
|||
break;
|
||||
}
|
||||
|
||||
case NS_XUL_CLOSE:
|
||||
{
|
||||
// if this is a popup, make a request to hide it. Note that a popuphidden
|
||||
// event listener may cancel the event and the popup will not be hidden.
|
||||
nsIWidget* widget = aView->GetWidget();
|
||||
if (widget) {
|
||||
nsWindowType type;
|
||||
widget->GetWindowType(type);
|
||||
if (type == eWindowType_popup) {
|
||||
nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
|
||||
if (pm) {
|
||||
pm->HidePopup(aView);
|
||||
*aStatus = nsEventStatus_eConsumeNoDefault;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case NS_WILL_PAINT:
|
||||
case NS_PAINT:
|
||||
{
|
||||
|
|
|
@ -330,6 +330,9 @@ nsresult nsCocoaWindow::CreateNativeWindow(const NSRect &aRect,
|
|||
case eWindowType_popup:
|
||||
if (aBorderStyle != eBorderStyle_default && mBorderStyle & eBorderStyle_title) {
|
||||
features |= NSTitledWindowMask;
|
||||
if (aBorderStyle & eBorderStyle_close) {
|
||||
features |= NSClosableWindowMask;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case eWindowType_toplevel:
|
||||
|
|
|
@ -4055,9 +4055,16 @@ nsWindow::Create(nsIWidget *aParent,
|
|||
GtkWindow* gtkWin = GTK_WINDOW(mShell);
|
||||
// ... but the window manager does not decorate this window,
|
||||
// nor provide a separate taskbar icon.
|
||||
PRBool decorated =
|
||||
(mBorderStyle != eBorderStyle_default && (mBorderStyle & eBorderStyle_title));
|
||||
gtk_window_set_decorated(GTK_WINDOW(mShell), decorated);
|
||||
if (mBorderStyle == eBorderStyle_default) {
|
||||
gtk_window_set_decorated(GTK_WINDOW(mShell), FALSE);
|
||||
}
|
||||
else {
|
||||
PRBool decorate = mBorderStyle & eBorderStyle_title;
|
||||
gtk_window_set_decorated(GTK_WINDOW(mShell), decorate);
|
||||
if (decorate) {
|
||||
gtk_window_set_deletable(GTK_WINDOW(mShell), mBorderStyle & eBorderStyle_close);
|
||||
}
|
||||
}
|
||||
gtk_window_set_skip_taskbar_hint(gtkWin, TRUE);
|
||||
// Element focus is managed by the parent window so the
|
||||
// WM_HINTS input field is set to False to tell the window
|
||||
|
|
|
@ -876,6 +876,9 @@ DWORD nsWindow::WindowStyle()
|
|||
|
||||
if (IsPopupWithTitleBar()) {
|
||||
style |= WS_CAPTION;
|
||||
if (mBorderStyle & eBorderStyle_close) {
|
||||
style |= WS_SYSMENU;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче