Bug 1351630 - Override BaseWidget::GetWidgetScreen r=karlt
GetScreenBounds() is slow for the GTK port so we override and use
mBounds directly in nsWindow::GetWidgetScreen()
MozReview-Commit-ID: ICElOCEzswf
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -4884,16 +4884,40 @@ nsWindow::PerformFullscreenTransition(Fu
auto transitionData = new FullscreenTransitionData(aStage, aDuration,
aCallback, data);
g_timeout_add_full(G_PRIORITY_HIGH,
FullscreenTransitionData::sInterval,
FullscreenTransitionData::TimeoutCallback,
transitionData, nullptr);
}
+already_AddRefed<nsIScreen>
+nsWindow::GetWidgetScreen()
+{
+ nsCOMPtr<nsIScreenManager> screenManager;
+ screenManager = do_GetService("@mozilla.org/gfx/screenmanager;1");
+ if (!screenManager) {
+ return nullptr;
+ }
+
+ // GetScreenBounds() is slow for the GTK port so we override and use
+ // mBounds directly.
+ LayoutDeviceIntRect bounds = mBounds;
+ if (!mIsTopLevel) {
+ bounds.MoveTo(WidgetToScreenOffset());
+ }
+
+ DesktopIntRect deskBounds = RoundedToInt(bounds / GetDesktopToDeviceScale());
+ nsCOMPtr<nsIScreen> screen;
+ screenManager->ScreenForRect(deskBounds.x, deskBounds.y,
+ deskBounds.width, deskBounds.height,
+ getter_AddRefs(screen));
+ return screen.forget();
+}
+
static bool
IsFullscreenSupported(GtkWidget* aShell)
{
#ifdef MOZ_X11
GdkScreen* screen = gtk_widget_get_screen(aShell);
GdkAtom atom = gdk_atom_intern("_NET_WM_STATE_FULLSCREEN", FALSE);
if (!gdk_x11_screen_supports_net_wm_hint(screen, atom)) {
return false;
--- a/widget/gtk/nsWindow.h
+++ b/widget/gtk/nsWindow.h
@@ -151,16 +151,17 @@ public:
bool aIntersectWithExisting) override;
virtual bool HasPendingInputEvent() override;
virtual bool PrepareForFullscreenTransition(nsISupports** aData) override;
virtual void PerformFullscreenTransition(FullscreenTransitionStage aStage,
uint16_t aDuration,
nsISupports* aData,
nsIRunnable* aCallback) override;
+ virtual already_AddRefed<nsIScreen> GetWidgetScreen() override;
virtual nsresult MakeFullScreen(bool aFullScreen,
nsIScreen* aTargetScreen = nullptr) override;
virtual void HideWindowChrome(bool aShouldHide) override;
/**
* GetLastUserInputTime returns a timestamp for the most recent user input
* event. This is intended for pointer grab requests (including drags).
*/