Browse Source

Android windowing fix.

tags/2021-05-28
jules 13 years ago
parent
commit
151ec34375
1 changed files with 15 additions and 11 deletions
  1. +15
    -11
      modules/juce_gui_basics/native/juce_android_Windowing.cpp

+ 15
- 11
modules/juce_gui_basics/native/juce_android_Windowing.cpp View File

@@ -86,11 +86,15 @@ class AndroidComponentPeer : public ComponentPeer
public: public:
AndroidComponentPeer (Component* const component, const int windowStyleFlags) AndroidComponentPeer (Component* const component, const int windowStyleFlags)
: ComponentPeer (component, windowStyleFlags), : ComponentPeer (component, windowStyleFlags),
view (android.activity.callObjectMethod (JuceAppActivity.createNewView, component->isOpaque())),
usingAndroidGraphics (false), usingAndroidGraphics (false),
fullScreen (false), fullScreen (false),
sizeAllocated (0) sizeAllocated (0)
{ {
// NB: must not put this in the initialiser list, as it invokes a callback,
// which will fail if the peer is only half-constructed.
view = GlobalRef (android.activity.callObjectMethod (JuceAppActivity.createNewView,
component->isOpaque()));
if (isFocused()) if (isFocused())
handleFocusGain(); handleFocusGain();
} }
@@ -474,14 +478,14 @@ public:
#endif #endif
//============================================================================== //==============================================================================
static AndroidComponentPeer* findPeerForJavaView (jobject viewToFind)
static AndroidComponentPeer* findPeerForJavaView (JNIEnv* env, jobject viewToFind)
{ {
for (int i = getNumPeers(); --i >= 0;) for (int i = getNumPeers(); --i >= 0;)
{ {
AndroidComponentPeer* const ap = static_cast <AndroidComponentPeer*> (getPeer(i)); AndroidComponentPeer* const ap = static_cast <AndroidComponentPeer*> (getPeer(i));
jassert (dynamic_cast <AndroidComponentPeer*> (getPeer(i)) != 0);
jassert (dynamic_cast <AndroidComponentPeer*> (getPeer(i)) != nullptr);
if (ap->view == viewToFind)
if (env->IsSameObject (ap->view.get(), viewToFind))
return ap; return ap;
} }
@@ -560,17 +564,17 @@ Point<int> AndroidComponentPeer::lastMousePos;
#define JUCE_VIEW_CALLBACK(returnType, javaMethodName, params, juceMethodInvocation) \ #define JUCE_VIEW_CALLBACK(returnType, javaMethodName, params, juceMethodInvocation) \
JUCE_JNI_CALLBACK (ComponentPeerView, javaMethodName, returnType, params) \ JUCE_JNI_CALLBACK (ComponentPeerView, javaMethodName, returnType, params) \
{ \ { \
AndroidComponentPeer* const peer = AndroidComponentPeer::findPeerForJavaView (view); \
AndroidComponentPeer* const peer = AndroidComponentPeer::findPeerForJavaView (env, view); \
if (peer != nullptr) \ if (peer != nullptr) \
peer->juceMethodInvocation; \ peer->juceMethodInvocation; \
} }
JUCE_VIEW_CALLBACK (void, handlePaint, (JNIEnv* env, jobject view, jobject canvas), handlePaintCallback (env, canvas))
JUCE_VIEW_CALLBACK (void, handleMouseDown, (JNIEnv*, jobject view, jfloat x, jfloat y, jlong time), handleMouseDownCallback ((float) x, (float) y, (int64) time))
JUCE_VIEW_CALLBACK (void, handleMouseDrag, (JNIEnv*, jobject view, jfloat x, jfloat y, jlong time), handleMouseDragCallback ((float) x, (float) y, (int64) time))
JUCE_VIEW_CALLBACK (void, handleMouseUp, (JNIEnv*, jobject view, jfloat x, jfloat y, jlong time), handleMouseUpCallback ((float) x, (float) y, (int64) time))
JUCE_VIEW_CALLBACK (void, viewSizeChanged, (JNIEnv*, jobject view), handleMovedOrResized())
JUCE_VIEW_CALLBACK (void, focusChanged, (JNIEnv*, jobject view, jboolean hasFocus), handleFocusChangeCallback (hasFocus))
JUCE_VIEW_CALLBACK (void, handlePaint, (JNIEnv* env, jobject view, jobject canvas), handlePaintCallback (env, canvas))
JUCE_VIEW_CALLBACK (void, handleMouseDown, (JNIEnv* env, jobject view, jfloat x, jfloat y, jlong time), handleMouseDownCallback ((float) x, (float) y, (int64) time))
JUCE_VIEW_CALLBACK (void, handleMouseDrag, (JNIEnv* env, jobject view, jfloat x, jfloat y, jlong time), handleMouseDragCallback ((float) x, (float) y, (int64) time))
JUCE_VIEW_CALLBACK (void, handleMouseUp, (JNIEnv* env, jobject view, jfloat x, jfloat y, jlong time), handleMouseUpCallback ((float) x, (float) y, (int64) time))
JUCE_VIEW_CALLBACK (void, viewSizeChanged, (JNIEnv* env, jobject view), handleMovedOrResized())
JUCE_VIEW_CALLBACK (void, focusChanged, (JNIEnv* env, jobject view, jboolean hasFocus), handleFocusChangeCallback (hasFocus))
//============================================================================== //==============================================================================
ComponentPeer* Component::createNewPeer (int styleFlags, void*) ComponentPeer* Component::createNewPeer (int styleFlags, void*)


Loading…
Cancel
Save