mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1182665 - Use a direct JNI call to determine screen size in nsScreenManagerAndroid r=jchen
This commit is contained in:
parent
365b1b0164
commit
c90689f1b7
@ -84,6 +84,7 @@ import android.graphics.RectF;
|
||||
import android.graphics.SurfaceTexture;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
@ -110,6 +111,7 @@ import android.util.Base64;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.Display;
|
||||
import android.view.HapticFeedbackConstants;
|
||||
import android.view.Surface;
|
||||
import android.view.SurfaceView;
|
||||
@ -2740,4 +2742,10 @@ public class GeckoAppShell
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@WrapForJNI
|
||||
static Rect getScreenSize() {
|
||||
Display disp = getGeckoInterface().getActivity().getWindowManager().getDefaultDisplay();
|
||||
return new Rect(0, 0, disp.getWidth(), disp.getHeight());
|
||||
}
|
||||
}
|
||||
|
@ -393,6 +393,14 @@ auto GeckoAppShell::GetScreenOrientationWrapper() -> int16_t
|
||||
return mozilla::jni::Method<GetScreenOrientationWrapper_t>::Call(nullptr, nullptr);
|
||||
}
|
||||
|
||||
constexpr char GeckoAppShell::GetScreenSize_t::name[];
|
||||
constexpr char GeckoAppShell::GetScreenSize_t::signature[];
|
||||
|
||||
auto GeckoAppShell::GetScreenSize() -> mozilla::jni::Object::LocalRef
|
||||
{
|
||||
return mozilla::jni::Method<GetScreenSize_t>::Call(nullptr, nullptr);
|
||||
}
|
||||
|
||||
constexpr char GeckoAppShell::GetShowPasswordSetting_t::name[];
|
||||
constexpr char GeckoAppShell::GetShowPasswordSetting_t::signature[];
|
||||
|
||||
|
@ -944,6 +944,23 @@ public:
|
||||
|
||||
static auto GetScreenOrientationWrapper() -> int16_t;
|
||||
|
||||
public:
|
||||
struct GetScreenSize_t {
|
||||
typedef GeckoAppShell Owner;
|
||||
typedef mozilla::jni::Object::LocalRef ReturnType;
|
||||
typedef mozilla::jni::Object::Param SetterType;
|
||||
typedef mozilla::jni::Args<> Args;
|
||||
static constexpr char name[] = "getScreenSize";
|
||||
static constexpr char signature[] =
|
||||
"()Landroid/graphics/Rect;";
|
||||
static const bool isStatic = true;
|
||||
static const bool isMultithreaded = false;
|
||||
static const mozilla::jni::ExceptionMode exceptionMode =
|
||||
mozilla::jni::ExceptionMode::ABORT;
|
||||
};
|
||||
|
||||
static auto GetScreenSize() -> mozilla::jni::Object::LocalRef;
|
||||
|
||||
public:
|
||||
struct GetShowPasswordSetting_t {
|
||||
typedef GeckoAppShell Owner;
|
||||
|
2
widget/android/bindings/AndroidRect-classes.txt
Normal file
2
widget/android/bindings/AndroidRect-classes.txt
Normal file
@ -0,0 +1,2 @@
|
||||
android.graphics.Rect
|
||||
android.graphics.RectF
|
@ -24,6 +24,7 @@ sdk_processor := \
|
||||
|
||||
# We'd like these to be defined in a future GENERATED_EXPORTS list.
|
||||
bindings_exports_FILES := \
|
||||
AndroidRect.h \
|
||||
Bundle.h \
|
||||
MediaCodec.h \
|
||||
SurfaceTexture.h \
|
||||
|
@ -7,9 +7,10 @@
|
||||
# List of stems to generate .cpp and .h files for. To add a stem, add it to
|
||||
# this list and ensure that $(stem)-classes.txt exists in this directory.
|
||||
generated = [
|
||||
'AndroidRect',
|
||||
'Bundle',
|
||||
'MediaCodec',
|
||||
'SurfaceTexture',
|
||||
'SurfaceTexture'
|
||||
]
|
||||
|
||||
SOURCES += ['!%s.cpp' % stem for stem in generated]
|
||||
|
@ -8,6 +8,9 @@
|
||||
#include "nsScreenManagerAndroid.h"
|
||||
#include "nsWindow.h"
|
||||
#include "AndroidBridge.h"
|
||||
#include "GeneratedJNIWrappers.h"
|
||||
#include "AndroidRect.h"
|
||||
#include <mozilla/jni/Refs.h>
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
@ -29,13 +32,11 @@ nsScreenAndroid::GetId(uint32_t *outId)
|
||||
NS_IMETHODIMP
|
||||
nsScreenAndroid::GetRect(int32_t *outLeft, int32_t *outTop, int32_t *outWidth, int32_t *outHeight)
|
||||
{
|
||||
gfx::IntSize sz = nsWindow::GetAndroidScreenBounds();
|
||||
|
||||
*outLeft = 0;
|
||||
*outTop = 0;
|
||||
|
||||
*outWidth = sz.width;
|
||||
*outHeight = sz.height;
|
||||
widget::sdk::Rect::LocalRef rect = widget::GeckoAppShell::GetScreenSize();
|
||||
rect->Left(outLeft);
|
||||
rect->Top(outTop);
|
||||
rect->Width(outWidth);
|
||||
rect->Height(outHeight);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user