@@ -179,31 +179,18 @@ python_act = autoclass(JAVA_NAMESPACE + '.PythonActivity')
179
179
Rect = autoclass(' android.graphics.Rect' )
180
180
mActivity = python_act.mActivity
181
181
if mActivity:
182
- class LayoutListener (PythonJavaClass ):
183
- __javainterfaces__ = [' android/view/ViewTreeObserver$OnGlobalLayoutListener' ]
184
-
185
- height = 0
186
-
187
- @ java_method (' ()V' )
188
- def onGlobalLayout (self ):
189
- rctx = Rect()
190
- # print('rctx_bottom: {0}, top: {1}'.format(rctx.bottom, rctx.top))
191
- mActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rctx)
192
- # print('rctx_bottom: {0}, top: {1}'.format(rctx.bottom, rctx.top))
193
- # print('activity height: {0}'.format(mActivity.getWindowManager().getDefaultDisplay().getHeight()))
194
- # NOTE top should always be zero
195
- rctx.top = 0
196
- self .height = mActivity.getWindowManager().getDefaultDisplay().getHeight() - (rctx.bottom - rctx.top)
197
- # print('final height: {0}'.format(self.height))
198
-
199
- ll = LayoutListener()
200
- IF BOOTSTRAP == ' sdl2' :
201
- python_act.getLayout().getViewTreeObserver().addOnGlobalLayoutListener(ll)
202
- ELSE :
203
- python_act.mView.getViewTreeObserver().addOnGlobalLayoutListener(ll)
204
-
182
+ # PyGame backend already has the listener so adding
183
+ # one here leads to a crash/too much cpu usage.
184
+ # SDL2 now does noe need the listener so there is
185
+ # no point adding a processor intensive layout listenere here.
186
+ height = 0
205
187
def get_keyboard_height ():
206
- return ll.height
188
+ rctx = Rect()
189
+ mActivity.getWindow().getDecorView().getWindowVisibleDisplayFrame(rctx)
190
+ # NOTE top should always be zero
191
+ rctx.top = 0
192
+ height = mActivity.getWindowManager().getDefaultDisplay().getHeight() - (rctx.bottom - rctx.top)
193
+ return height
207
194
else :
208
195
def get_keyboard_height ():
209
196
return 0
0 commit comments