Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Fix not throttled events and errors when pointing the remote on the background. #666

Merged
merged 1 commit into from
Oct 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions app/src/common/shared/org/mozilla/vrbrowser/VRBrowserActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public void run() {
LinkedList<UpdateListener> mWidgetUpdateListeners;
LinkedList<PermissionListener> mPermissionListeners;
LinkedList<FocusChangeListener> mFocusChangeListeners;
LinkedList<WorldClickListener> mWorldClickListeners;
LinkedList<Runnable> mBackHandlers;
private boolean mIsPresentingImmersive = false;
private Thread mUiThread;
Expand Down Expand Up @@ -139,6 +140,7 @@ protected void onCreate(Bundle savedInstanceState) {
mWidgetUpdateListeners = new LinkedList<>();
mPermissionListeners = new LinkedList<>();
mFocusChangeListeners = new LinkedList<>();
mWorldClickListeners = new LinkedList<>();
mBackHandlers = new LinkedList<>();

mWidgets = new HashMap<>();
Expand Down Expand Up @@ -192,6 +194,11 @@ protected void initializeWorld() {

// Empty widget just for handling focus on empty space
mRootWidget = new RootWidget(this);
mRootWidget.setClickCallback(() -> {
for (WorldClickListener listener: mWorldClickListeners) {
listener.onWorldClick();
}
});

// Create Tray
mTray = new TrayWidget(this);
Expand Down Expand Up @@ -707,6 +714,19 @@ public void removeFocusChangeListener(FocusChangeListener aListener) {
mFocusChangeListeners.remove(aListener);
}


@Override
public void addWorldClickListener(WorldClickListener aListener) {
if (!mWorldClickListeners.contains(aListener)) {
mWorldClickListeners.add(aListener);
}
}

@Override
public void removeWorldClickListener(WorldClickListener aListener) {
mWorldClickListeners.remove(aListener);
}

@Override
public void pushBackHandler(Runnable aRunnable) {
mBackHandlers.addLast(aRunnable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.view.View;

public class RootWidget extends UIWidget {
private Runnable mOnClickCallback;

public RootWidget(Context aContext) {
super(aContext);
Expand All @@ -23,19 +24,24 @@ public RootWidget(Context aContext, AttributeSet aAttrs, int aDefStyle) {

@Override
protected void initializeWidgetPlacement(WidgetPlacement aPlacement) {

aPlacement.width = 8;
aPlacement.height = 8;
}

private void initialize(Context aContext) {
setFocusable(true);
setSoundEffectsEnabled(false);

setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
requestFocus();
requestFocusFromTouch();
setOnClickListener(v -> {
requestFocus();
requestFocusFromTouch();
if (mOnClickCallback != null) {
mOnClickCallback.run();
}
});
}

public void setClickCallback(Runnable aRunnable) {
mOnClickCallback = aRunnable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ interface PermissionListener {
interface FocusChangeListener {
void onGlobalFocusChanged(View oldFocus, View newFocus);
}
interface WorldClickListener {
// Indicates that the user has clicked on the world, outside of any UI widgets
void onWorldClick();
}
int newWidgetHandle();
void addWidget(@NonNull Widget aWidget);
void updateWidget(@NonNull Widget aWidget);
Expand All @@ -36,6 +40,8 @@ interface FocusChangeListener {
void removeFocusChangeListener(@NonNull FocusChangeListener aListener);
void addPermissionListener(PermissionListener aListener);
void removePermissionListener(PermissionListener aListener);
void addWorldClickListener(WorldClickListener aListener);
void removeWorldClickListener(WorldClickListener aListener);
boolean isPermissionGranted(@NonNull String permission);
void requestPermission(@NonNull String uri, @NonNull String permission, GeckoSession.PermissionDelegate.Callback aCallback);
}
2 changes: 1 addition & 1 deletion app/src/main/cpp/BrowserWorld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ BrowserWorld::State::UpdateControllers(bool& aRelayoutWidgets) {
VRBrowser::HandleMotionEvent(0, controller.index, pressed, 0.0f, 0.0f);
controller.widget = 0;

} else {
} else if (wasPressed != pressed) {
VRBrowser::HandleMotionEvent(0, controller.index, pressed, 0.0f, 0.0f);
}
controller.lastButtonState = controller.buttonState;
Expand Down