Bug 1794577 - Minor clean-up to CSD code. r=stransky

No behavior change.

Differential Revision: https://phabricator.services.mozilla.com/D171074
This commit is contained in:
Emilio Cobos Álvarez 2023-02-28 14:20:38 +00:00
Родитель 5172dc066b
Коммит c548fc1e68
2 изменённых файлов: 22 добавлений и 17 удалений

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

@ -883,29 +883,33 @@ void nsWindow::SetSizeConstraints(const SizeConstraints& aConstraints) {
ApplySizeConstraints();
}
bool nsWindow::DrawsToCSDTitlebar() const {
return mSizeMode == nsSizeMode_Normal &&
mGtkWindowDecoration == GTK_DECORATION_CLIENT && mDrawInTitlebar;
}
void nsWindow::AddCSDDecorationSize(int* aWidth, int* aHeight) {
if (mSizeMode == nsSizeMode_Normal &&
mGtkWindowDecoration == GTK_DECORATION_CLIENT && mDrawInTitlebar) {
GtkBorder decorationSize = GetCSDDecorationSize(IsPopup());
*aWidth += decorationSize.left + decorationSize.right;
*aHeight += decorationSize.top + decorationSize.bottom;
if (!DrawsToCSDTitlebar()) {
return;
}
GtkBorder decorationSize = GetCSDDecorationSize(IsPopup());
*aWidth += decorationSize.left + decorationSize.right;
*aHeight += decorationSize.top + decorationSize.bottom;
}
#ifdef MOZ_WAYLAND
bool nsWindow::GetCSDDecorationOffset(int* aDx, int* aDy) {
if (mSizeMode == nsSizeMode_Normal &&
mGtkWindowDecoration == GTK_DECORATION_CLIENT && mDrawInTitlebar) {
GtkBorder decorationSize = GetCSDDecorationSize(IsPopup());
*aDx = decorationSize.left;
*aDy = decorationSize.top;
return true;
if (!DrawsToCSDTitlebar()) {
return false;
}
return false;
GtkBorder decorationSize = GetCSDDecorationSize(IsPopup());
*aDx = decorationSize.left;
*aDy = decorationSize.top;
return true;
}
#endif
void nsWindow::ApplySizeConstraints(void) {
void nsWindow::ApplySizeConstraints() {
if (mShell) {
GdkGeometry geometry;
geometry.min_width =
@ -918,7 +922,7 @@ void nsWindow::ApplySizeConstraints(void) {
DevicePixelsToGdkCoordRoundDown(mSizeConstraints.mMaxSize.height);
uint32_t hints = 0;
if (mSizeConstraints.mMinSize != LayoutDeviceIntSize(0, 0)) {
if (mSizeConstraints.mMinSize != LayoutDeviceIntSize()) {
if (GdkIsWaylandDisplay()) {
gtk_widget_set_size_request(GTK_WIDGET(mContainer), geometry.min_width,
geometry.min_height);
@ -8726,8 +8730,8 @@ void nsWindow::SetDrawsInTitlebar(bool aState) {
}
if (mWindowType == WindowType::Dialog &&
!bool(mBorderStyle & BorderStyle::Title) &&
!bool(mBorderStyle & BorderStyle::ResizeH)) {
!(mBorderStyle & BorderStyle::Title) &&
!(mBorderStyle & BorderStyle::ResizeH)) {
gtk_window_set_decorated(GTK_WINDOW(mShell), !aState);
LOG(" set decoration for dialog with titlebar=no %d", aState);
return;
@ -9594,7 +9598,7 @@ void nsWindow::UpdateMozWindowActive() {
}
}
void nsWindow::ForceTitlebarRedraw(void) {
void nsWindow::ForceTitlebarRedraw() {
MOZ_ASSERT(mDrawInTitlebar, "We should not redraw invisible titlebar.");
if (!mWidgetListener || !mWidgetListener->GetPresShell()) {

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

@ -528,6 +528,7 @@ class nsWindow final : public nsBaseWidget {
GtkTextDirection GetTextDirection();
bool DrawsToCSDTitlebar() const;
void AddCSDDecorationSize(int* aWidth, int* aHeight);
void CreateAndPutGdkScrollEvent(mozilla::LayoutDeviceIntPoint aPoint,