mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-03 23:30:46 +00:00
Bug 29856 *nix only : Window Class the same for all mozilla windows
original patch from arik devens / rob ginda r=akkana sr=alecf
This commit is contained in:
parent
7a582d2388
commit
6b932868e6
@ -452,7 +452,7 @@ class nsIWidget : public nsISupports {
|
||||
*/
|
||||
NS_IMETHOD Enable(PRBool aState) = 0;
|
||||
|
||||
/*
|
||||
/**
|
||||
* Ask whether the widget is enabled
|
||||
* @param aState returns PR_TRUE if the widget is enabled
|
||||
*/
|
||||
@ -484,7 +484,7 @@ class nsIWidget : public nsISupports {
|
||||
NS_IMETHOD GetScreenBounds(nsRect &aRect) = 0;
|
||||
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get this widget's client area dimensions, if the window has a 3D border appearance
|
||||
* this returns the area inside the border, The x and y are always zero
|
||||
*
|
||||
@ -761,7 +761,7 @@ class nsIWidget : public nsISupports {
|
||||
|
||||
NS_IMETHOD ShowMenuBar(PRBool aShow) = 0;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Convert from this widget coordinates to screen coordinates.
|
||||
*
|
||||
* @param aOldRect widget coordinates stored in the x,y members
|
||||
@ -838,38 +838,50 @@ class nsIWidget : public nsISupports {
|
||||
*/
|
||||
NS_IMETHOD CaptureMouse(PRBool aCapture) = 0;
|
||||
|
||||
/**
|
||||
* Enables/Disables system capture of any and all events that would cause a
|
||||
* dropdown to be rolled up, This method ignores the aConsumeRollupEvent
|
||||
* parameter when aDoCapture is FALSE
|
||||
* @param aCapture PR_TRUE enables capture, PR_FALSE disables capture
|
||||
* @param aConsumeRollupEvent PR_TRUE consumes the rollup event, PR_FALSE dispatches rollup event
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* Gets the window class
|
||||
* implemented in gtk
|
||||
*/
|
||||
NS_IMETHOD GetWindowClass(char *aClass) = 0;
|
||||
|
||||
/**
|
||||
* Sets the window class
|
||||
* implemented in gtk
|
||||
*/
|
||||
NS_IMETHOD SetWindowClass(char *aClass) = 0;
|
||||
|
||||
/**
|
||||
* Enables/Disables system capture of any and all events that would cause a
|
||||
* dropdown to be rolled up, This method ignores the aConsumeRollupEvent
|
||||
* parameter when aDoCapture is FALSE
|
||||
* @param aCapture PR_TRUE enables capture, PR_FALSE disables capture
|
||||
* @param aConsumeRollupEvent PR_TRUE consumes the rollup event, PR_FALSE dispatches rollup event
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent) = 0;
|
||||
|
||||
/**
|
||||
* Determine whether a given event should be processed assuming we are
|
||||
* the currently active modal window.
|
||||
* Note that the exact semantics of this method are platform-dependent.
|
||||
* The Macintosh, for instance, cares deeply that this method do exactly
|
||||
* as advertised. Gtk, for instance, handles modality in a completely
|
||||
* different fashion and does little if anything with this method.
|
||||
* @param aRealEvent event is real or a null placeholder (Macintosh)
|
||||
* @param aEvent void pointer to native event structure
|
||||
* @param aForWindow return value. PR_TRUE iff event should be processed.
|
||||
*/
|
||||
NS_IMETHOD ModalEventFilter(PRBool aRealEvent, void *aEvent, PRBool *aForWindow) = 0;
|
||||
/**
|
||||
* Determine whether a given event should be processed assuming we are
|
||||
* the currently active modal window.
|
||||
* Note that the exact semantics of this method are platform-dependent.
|
||||
* The Macintosh, for instance, cares deeply that this method do exactly
|
||||
* as advertised. Gtk, for instance, handles modality in a completely
|
||||
* different fashion and does little if anything with this method.
|
||||
* @param aRealEvent event is real or a null placeholder (Macintosh)
|
||||
* @param aEvent void pointer to native event structure
|
||||
* @param aForWindow return value. PR_TRUE iff event should be processed.
|
||||
*/
|
||||
NS_IMETHOD ModalEventFilter(PRBool aRealEvent, void *aEvent, PRBool *aForWindow) = 0;
|
||||
|
||||
/**
|
||||
* Bring this window to the user's attention. This is intended to be a more
|
||||
* gentle notification than popping the window to the top or putting up an
|
||||
* alert. See, for example, Win32 FlashWindow or the NotificationManager on
|
||||
* the Mac. The notification should be suppressed if the window is already
|
||||
* in the foreground and should be dismissed when the user brings this window
|
||||
* to the foreground.
|
||||
*/
|
||||
NS_IMETHOD GetAttention() = 0;
|
||||
/**
|
||||
* Bring this window to the user's attention. This is intended to be a more
|
||||
* gentle notification than popping the window to the top or putting up an
|
||||
* alert. See, for example, Win32 FlashWindow or the NotificationManager on
|
||||
* the Mac. The notification should be suppressed if the window is already
|
||||
* in the foreground and should be dismissed when the user brings this window
|
||||
* to the foreground.
|
||||
*/
|
||||
NS_IMETHOD GetAttention() = 0;
|
||||
|
||||
};
|
||||
|
||||
|
@ -468,6 +468,58 @@ NS_IMETHODIMP nsWidget::IsVisible(PRBool &aState)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWidget::GetWindowClass(char *aClass)
|
||||
{
|
||||
//nsWidget's base impl will throw a failure
|
||||
//to find out that this toolkit supports this function pass null.
|
||||
if (!aClass)
|
||||
return NS_OK;
|
||||
|
||||
*aClass = nsnull;
|
||||
|
||||
if (mWindowType != eWindowType_toplevel)
|
||||
return NS_OK;
|
||||
|
||||
GtkWindow *topWindow;
|
||||
topWindow = GetTopLevelWindow();
|
||||
|
||||
if (!topWindow)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
XClassHint *class_hint = XAllocClassHint();
|
||||
|
||||
if (XGetClassHint(GDK_DISPLAY(),
|
||||
GDK_WINDOW_XWINDOW(GTK_WIDGET(topWindow)->window),
|
||||
class_hint))
|
||||
aClass = strdup(class_hint->res_class);
|
||||
|
||||
XFree(class_hint);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWidget::SetWindowClass(char *aClass)
|
||||
{
|
||||
if (mWindowType != eWindowType_toplevel)
|
||||
return NS_OK;
|
||||
|
||||
GtkWindow *topWindow;
|
||||
topWindow = GetTopLevelWindow();
|
||||
|
||||
if (!topWindow)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
XClassHint *class_hint = XAllocClassHint();
|
||||
|
||||
class_hint->res_name = "Mozilla";
|
||||
class_hint->res_class = aClass;
|
||||
|
||||
XSetClassHint(GDK_DISPLAY(),
|
||||
GDK_WINDOW_XWINDOW(GTK_WIDGET(topWindow)->window),
|
||||
class_hint);
|
||||
XFree(class_hint);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Move this component
|
||||
|
@ -161,6 +161,8 @@ public:
|
||||
// *could* be done on a widget, but that would be silly wouldn't it?
|
||||
NS_IMETHOD CaptureMouse(PRBool aCapture) { return NS_ERROR_FAILURE; }
|
||||
|
||||
NS_IMETHOD GetWindowClass(char *aClass);
|
||||
NS_IMETHOD SetWindowClass(char *aClass);
|
||||
|
||||
NS_IMETHOD Validate();
|
||||
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
|
||||
|
@ -558,6 +558,15 @@ void nsBaseWidget::OnDestroy()
|
||||
mAppShell = nsnull; // clear out nsCOMPtr
|
||||
}
|
||||
|
||||
NS_METHOD nsBaseWidget::GetWindowClass(char *aClass)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_METHOD nsBaseWidget::SetWindowClass(char *aClass)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_METHOD nsBaseWidget::SetBorderStyle(nsBorderStyle aBorderStyle)
|
||||
{
|
||||
|
@ -106,6 +106,8 @@ public:
|
||||
NS_IMETHOD SetModal(PRBool aModal);
|
||||
NS_IMETHOD ModalEventFilter(PRBool aRealEvent, void *aEvent,
|
||||
PRBool *aForWindow);
|
||||
NS_IMETHOD GetWindowClass(char *aClass);
|
||||
NS_IMETHOD SetWindowClass(char *aClass);
|
||||
NS_IMETHOD SetBorderStyle(nsBorderStyle aBorderStyle);
|
||||
NS_IMETHOD AddMouseListener(nsIMouseListener * aListener);
|
||||
NS_IMETHOD AddEventListener(nsIEventListener * aListener);
|
||||
|
@ -37,6 +37,13 @@
|
||||
#include "nsIAuthPrompt.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsIWindowMediator.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIDOMXULElement.h"
|
||||
#include "nsIXULBrowserWindow.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
|
||||
// CIDs
|
||||
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
|
||||
@ -189,12 +196,49 @@ NS_IMETHODIMP nsChromeTreeOwner::SizeShellTo(nsIDocShellTreeItem* aShellItem,
|
||||
return mXULWindow->SizeShellTo(aShellItem, aCX, aCY);
|
||||
}
|
||||
|
||||
NS_NAMED_LITERAL_STRING(gLiteralPersist,"persist");
|
||||
NS_NAMED_LITERAL_STRING(gLiteralScreenX,"screenX");
|
||||
NS_NAMED_LITERAL_STRING(gLiteralScreenY,"screenY");
|
||||
NS_NAMED_LITERAL_STRING(gLiteralWidth,"width");
|
||||
NS_NAMED_LITERAL_STRING(gLiteralHeight,"height");
|
||||
NS_NAMED_LITERAL_STRING(gLiteralSizemode,"sizemode");
|
||||
NS_NAMED_LITERAL_STRING(gLiteralSpace," ");
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeTreeOwner::SetPersistence(PRBool aPersistPosition,
|
||||
PRBool aPersistSize,
|
||||
PRBool aPersistSizeMode)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
nsCOMPtr<nsIDOMElement> docShellElement;
|
||||
mXULWindow->GetWindowDOMElement(getter_AddRefs(docShellElement));
|
||||
if (!docShellElement)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsAutoString persistString;
|
||||
docShellElement->GetAttribute(gLiteralPersist, persistString);
|
||||
|
||||
PRBool saveString = PR_FALSE;
|
||||
PRInt32 index;
|
||||
|
||||
#define FIND_PERSIST_STRING(aString, aCond) \
|
||||
index = persistString.Find(aString); \
|
||||
if (!aCond && index > kNotFound) { \
|
||||
persistString.Cut(index, aString.Length()); \
|
||||
saveString = PR_TRUE; \
|
||||
} else if (aCond && index == kNotFound) { \
|
||||
persistString.Append(gLiteralSpace+aString); \
|
||||
saveString = PR_TRUE; \
|
||||
}
|
||||
FIND_PERSIST_STRING(gLiteralScreenX, aPersistPosition);
|
||||
FIND_PERSIST_STRING(gLiteralScreenY, aPersistPosition);
|
||||
FIND_PERSIST_STRING(gLiteralWidth, aPersistSize);
|
||||
FIND_PERSIST_STRING(gLiteralHeight, aPersistSize);
|
||||
FIND_PERSIST_STRING(gLiteralSizemode, aPersistSizeMode);
|
||||
|
||||
if (saveString)
|
||||
docShellElement->SetAttribute(gLiteralPersist, persistString);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -202,7 +246,26 @@ nsChromeTreeOwner::GetPersistence(PRBool* aPersistPosition,
|
||||
PRBool* aPersistSize,
|
||||
PRBool* aPersistSizeMode)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
nsCOMPtr<nsIDOMElement> docShellElement;
|
||||
mXULWindow->GetWindowDOMElement(getter_AddRefs(docShellElement));
|
||||
if (!docShellElement)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsAutoString persistString;
|
||||
docShellElement->GetAttribute(gLiteralPersist, persistString);
|
||||
|
||||
// data structure doesn't quite match the question, but it's close enough
|
||||
// for what we want (since this method is never actually called...)
|
||||
if (aPersistPosition)
|
||||
*aPersistPosition = persistString.Find(gLiteralScreenX) > kNotFound ||
|
||||
persistString.Find(gLiteralScreenY) > kNotFound;
|
||||
if (aPersistSize)
|
||||
*aPersistSize = persistString.Find(gLiteralWidth) > kNotFound ||
|
||||
persistString.Find(gLiteralHeight) > kNotFound;
|
||||
if (aPersistSizeMode)
|
||||
*aPersistSizeMode = persistString.Find(gLiteralSizemode) > kNotFound;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
|
@ -65,7 +65,7 @@
|
||||
#include "nsIDOMViewCSS.h"
|
||||
#include "nsIDOMCSSStyleDeclaration.h"
|
||||
#include "nsITimelineService.h"
|
||||
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsStyleConsts.h"
|
||||
|
||||
// XXX Get rid of this
|
||||
@ -800,6 +800,7 @@ void nsXULWindow::OnChromeLoaded()
|
||||
mContentTreeOwner->ApplyChromeFlags();
|
||||
|
||||
LoadTitleFromXUL();
|
||||
LoadWindowClassFromXUL();
|
||||
LoadIconFromXUL();
|
||||
LoadSizeFromXUL();
|
||||
if(mIntrinsicallySized) {
|
||||
@ -1111,6 +1112,40 @@ NS_IMETHODIMP nsXULWindow::LoadTitleFromXUL()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::LoadWindowClassFromXUL()
|
||||
{
|
||||
if (mWindow->GetWindowClass(nsnull)==NS_ERROR_NOT_IMPLEMENTED)
|
||||
return NS_OK;
|
||||
|
||||
nsCOMPtr<nsIDOMElement> docShellElement;
|
||||
GetWindowDOMElement(getter_AddRefs(docShellElement));
|
||||
NS_ENSURE_TRUE(docShellElement, NS_ERROR_FAILURE);
|
||||
|
||||
nsAutoString windowClass;
|
||||
|
||||
docShellElement->GetAttribute(NS_LITERAL_STRING("windowtype"),
|
||||
windowClass);
|
||||
|
||||
if (!windowClass.IsEmpty())
|
||||
{
|
||||
PRBool persistPosition;
|
||||
PRBool persistSize;
|
||||
PRBool persistSizeMode;
|
||||
|
||||
if (NS_SUCCEEDED(
|
||||
mContentTreeOwner->
|
||||
GetPersistence(&persistPosition, &persistSize, &persistSizeMode)
|
||||
) && !persistPosition && !persistSize && !persistSizeMode)
|
||||
windowClass.Append(NS_LITERAL_STRING("-jsSpamPopupCrap"));
|
||||
|
||||
char *windowClass_cstr = ToNewCString(windowClass);
|
||||
mWindow->SetWindowClass(windowClass_cstr);
|
||||
nsMemory::Free(windowClass_cstr);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULWindow::LoadIconFromXUL()
|
||||
{
|
||||
NS_ENSURE_STATE(mWindow);
|
||||
|
@ -81,6 +81,7 @@ protected:
|
||||
PRBool LoadSizeFromXUL();
|
||||
PRBool LoadSizeStateFromXUL();
|
||||
NS_IMETHOD LoadTitleFromXUL();
|
||||
NS_IMETHOD LoadWindowClassFromXUL();
|
||||
NS_IMETHOD LoadIconFromXUL();
|
||||
NS_IMETHOD PersistPositionAndSize(PRBool aPosition, PRBool aSize, PRBool aSizeMode);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user