1 // Copyright 2020 The Android Open Source Project 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 17 #include "aemu/base/c_header.h" 18 19 #include <stdbool.h> 20 #include <stdint.h> 21 // #include "android/settings-agent.h" 22 // #include "android/skin/rect.h" 23 // #include "android/utils/compiler.h" 24 25 #ifndef USING_ANDROID_BP 26 ANDROID_BEGIN_HEADER 27 #endif 28 29 // Window agent's possible message types 30 typedef enum { 31 WINDOW_MESSAGE_GENERIC, 32 WINDOW_MESSAGE_INFO, 33 WINDOW_MESSAGE_WARNING, 34 WINDOW_MESSAGE_ERROR, 35 WINDOW_MESSAGE_OK, 36 } WindowMessageType; 37 38 typedef struct {} MultiDisplayPageChangeEvent; 39 typedef struct SkinLayout SkinLayout; 40 typedef struct QFrame QFrame; 41 typedef struct SkinEvent SKinEvent; 42 43 static const int kWindowMessageTimeoutInfinite = -1; 44 45 typedef struct EmulatorWindow EmulatorWindow; 46 47 typedef void (*UiUpdateFunc)(void* data); 48 49 typedef struct QAndroidEmulatorWindowAgent { 50 // Get a pointer to the emulator window structure. 51 EmulatorWindow* (*getEmulatorWindow)(void); 52 53 // Rotate the screen clockwise by 90 degrees. 54 // Returns true on success, false otherwise. 55 bool (*rotate90Clockwise)(void); 56 57 // Rotate to specific |rotation| 58 bool (*rotate)(int skinRotation); 59 60 // Returns the current rotation. 61 int (*getRotation)(void); 62 63 // Shows a message to the user. 64 void (*showMessage)(const char* message, 65 WindowMessageType type, 66 int timeoutMs); 67 68 // Shows a message to the user + custom dismiss op. 69 void (*showMessageWithDismissCallback)(const char* message, 70 WindowMessageType type, 71 const char* dismissText, 72 void* context, 73 void (*func)(void*), 74 int timeoutMs); 75 // Fold/Unfold device 76 bool (*fold)(bool is_fold); 77 // Query folded state 78 bool (*isFolded)(void); 79 bool (*getFoldedArea)(int* x, int* y, int* w, int* h); 80 81 // Update UI indicator which shows which foldable posture device is in 82 void (*updateFoldablePostureIndicator)(bool confirmFoldedArea); 83 // Set foldable device posture 84 bool (*setPosture)(int posture); 85 86 // Set the UI display region 87 void (*setUIDisplayRegion)(int, int, int, int, bool); 88 bool (*getMultiDisplay)(uint32_t, 89 int32_t*, 90 int32_t*, 91 uint32_t*, 92 uint32_t*, 93 uint32_t*, 94 uint32_t*, 95 bool*); 96 void (*setNoSkin)(void); 97 void (*restoreSkin)(void); 98 void (*updateUIMultiDisplayPage)(uint32_t); 99 bool (*addMultiDisplayWindow)(uint32_t, bool, uint32_t, uint32_t); 100 bool (*paintMultiDisplayWindow)(uint32_t, uint32_t); 101 bool (*getMonitorRect)(uint32_t*, uint32_t*); 102 // moves the extended window to the given position if the window was never displayed. This does nothing 103 // if the window has been show once during the lifetime of the avd. 104 void (*moveExtendedWindow)(uint32_t x, uint32_t y, int horizonalAnchor, int verticalAnchor); 105 // start extended window and switch to the pane specified by the index. 106 // return true if extended controls window's visibility has changed. 107 // The window is not necessarily visible when this method returns. 108 bool (*startExtendedWindow)(int index); 109 110 // Closes the extended window. At some point in time it will be gone. 111 bool (*quitExtendedWindow)(void); 112 113 // This will wait until the state of the visibility of the window has 114 // changed to the given value. Calling show or close does not make 115 // a qt frame immediately visible. Instead a series of events will be 116 // fired when the frame is actually added to, or removed from the display. 117 // so usually the pattern is showWindow, wait for visibility.. 118 // 119 // Be careful to: 120 // - Not run this on a looper thread. The ui controls can post actions 121 // to the looper thread which can result in a deadlock 122 // - Not to run this on the Qt Message pump. You will deadlock. 123 void (*waitForExtendedWindowVisibility)(bool); 124 bool (*setUiTheme)(int type); 125 void (*runOnUiThread)(UiUpdateFunc f, void* data, bool wait); 126 bool (*isRunningInUiThread)(void); 127 bool (*changeResizableDisplay)(int presetSize); 128 void* (*getLayout)(void); 129 bool (*resizableEnabled)(void); 130 void (*show_virtual_scene_controls)(bool); 131 void (*quit_request)(void); 132 void (*getWindowPosition)(int*, int*); 133 bool (*hasWindow)(); 134 135 bool (*userSettingIsDontSaveSnapshot)(void); 136 void (*setUserSettingIsDontSaveSnapshot)(bool); 137 } QAndroidEmulatorWindowAgent; 138 139 #ifndef USING_ANDROID_BP 140 ANDROID_END_HEADER 141 #endif 142