Bug 1410894 - Add decoration drawing setup to nsWindow, r=jhorak

MozReview-Commit-ID: BHtqoOdfRpS

--HG--
extra : rebase_source : 4baaebff7e86d79de833e14c9284adc22a787180
This commit is contained in:
Martin Stransky 2017-10-27 11:19:08 +02:00
Родитель d11dfce827
Коммит 6a4c5abeaf
2 изменённых файлов: 73 добавлений и 0 удалений

Просмотреть файл

@ -291,6 +291,8 @@ TimeConverter() {
return sTimeConverterSingleton;
}
nsWindow::CSDSupportLevel nsWindow::sCSDSupportLevel = CSD_SUPPORT_UNKNOWN;
namespace mozilla {
class CurrentX11TimeGetter
@ -480,6 +482,8 @@ nsWindow::nsWindow()
mLastScrollEventTime = GDK_CURRENT_TIME;
#endif
mPendingConfigures = 0;
mIsCSDAvailable = false;
mIsCSDEnabled = false;
}
nsWindow::~nsWindow()
@ -6602,6 +6606,21 @@ nsWindow::ClearCachedResources()
}
}
void
nsWindow::SetDrawsInTitlebar(bool aState)
{
if (!mIsCSDAvailable || aState == mIsCSDEnabled)
return;
if (mShell) {
gint wmd = aState ? GDK_DECOR_BORDER : ConvertBorderStyles(mBorderStyle);
gdk_window_set_decorations(gtk_widget_get_window(mShell),
(GdkWMDecoration) wmd);
}
mIsCSDEnabled = aState;
}
gint
nsWindow::GdkScaleFactor()
{
@ -6872,6 +6891,41 @@ nsWindow::SynthesizeNativeTouchPoint(uint32_t aPointerId,
}
#endif
bool
nsWindow::DoDrawTitlebar() const
{
return mIsCSDEnabled && mSizeState == nsSizeMode_Normal;
}
nsWindow::CSDSupportLevel
nsWindow::GetCSDSupportLevel() {
if (sCSDSupportLevel != CSD_SUPPORT_UNKNOWN) {
return sCSDSupportLevel;
}
// TODO: MATE
const char* currentDesktop = getenv("XDG_CURRENT_DESKTOP");
if (currentDesktop) {
if (strcmp(currentDesktop, "GNOME") == 0) {
sCSDSupportLevel = CSD_SUPPORT_FULL;
} else if (strcmp(currentDesktop, "XFCE") == 0) {
sCSDSupportLevel = CSD_SUPPORT_FULL;
} else if (strcmp(currentDesktop, "X-Cinnamon") == 0) {
sCSDSupportLevel = CSD_SUPPORT_FULL;
} else if (strcmp(currentDesktop, "KDE") == 0) {
sCSDSupportLevel = CSD_SUPPORT_FLAT;
} else if (strcmp(currentDesktop, "LXDE") == 0) {
sCSDSupportLevel = CSD_SUPPORT_FLAT;
} else if (strcmp(currentDesktop, "openbox") == 0) {
sCSDSupportLevel = CSD_SUPPORT_FLAT;
} else if (strcmp(currentDesktop, "i3") == 0) {
sCSDSupportLevel = CSD_SUPPORT_NONE;
} else {
sCSDSupportLevel = CSD_SUPPORT_NONE;
}
}
return sCSDSupportLevel;
}
int32_t
nsWindow::RoundsWidgetCoordinatesTo()
{

Просмотреть файл

@ -351,6 +351,8 @@ public:
#endif
virtual void GetCompositorWidgetInitData(mozilla::widget::CompositorWidgetInitData* aInitData) override;
void SetDrawsInTitlebar(bool aState) override;
// HiDPI scale conversion
gint GdkScaleFactor();
@ -367,6 +369,8 @@ public:
LayoutDeviceIntRect GdkRectToDevicePixels(GdkRectangle rect);
virtual bool WidgetTypeSupportsAcceleration() override;
bool DoDrawTitlebar() const;
protected:
virtual ~nsWindow();
@ -471,6 +475,10 @@ private:
// window. See bug 1225044.
unsigned int mPendingConfigures;
bool mIsCSDAvailable;
// If true, draw our own window titlebar.
bool mIsCSDEnabled;
#ifdef ACCESSIBILITY
RefPtr<mozilla::a11y::Accessible> mRootAccessible;
@ -567,6 +575,17 @@ private:
RefPtr<mozilla::widget::IMContextWrapper> mIMContext;
mozilla::UniquePtr<mozilla::CurrentX11TimeGetter> mCurrentTimeGetter;
typedef enum { CSD_SUPPORT_FULL, // CSD including shadows
CSD_SUPPORT_FLAT, // CSD without shadows
CSD_SUPPORT_NONE, // WM does not support CSD at all
CSD_SUPPORT_UNKNOWN
} CSDSupportLevel;
/**
* Get the support of Client Side Decoration by checking
* the XDG_CURRENT_DESKTOP environment variable.
*/
static CSDSupportLevel GetCSDSupportLevel();
static CSDSupportLevel sCSDSupportLevel;
};
#endif /* __nsWindow_h__ */