Skip to content

Commit

Permalink
Bump up to version v1.1.1
Browse files Browse the repository at this point in the history
1.Fix _NET_WM_WINDOW_TYPE_DND window used for moving labels in some browsers
2.Create a white background window in the window manager to workaround certain shapes of floating views
3.Change activity title to FDE-X11 and adapt it to the BoringdroidSystemUI taskbar
  • Loading branch information
foryoung2018 committed Sep 3, 2024
1 parent 9c4288e commit 39dc6a2
Show file tree
Hide file tree
Showing 21 changed files with 121 additions and 173 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion 26
targetSdkVersion 33
versionCode 5
versionName "1.1.0"
versionName "1.1.1"
buildConfigField "String", "COMMIT", "\"" + ("git rev-parse HEAD\n".execute().getText().trim() ?: (System.getenv('CURRENT_COMMIT') ?: "NO_COMMIT")) + "\""
manifestPlaceholders = [MainActivityMinHeight: "50dp",
MainActivityMinWidth: "50dp",
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
</queries>

<application
android:persistent="true"
android:name=".App"
android:allowBackup="false"
android:hardwareAccelerated="true"
Expand Down Expand Up @@ -61,8 +62,11 @@
android:screenOrientation="unspecified"
android:windowSoftInputMode="stateHidden|adjustResize">
<layout
android:minHeight="420dp"
android:minWidth="560dp" />
android:defaultHeight="760dp"
android:defaultWidth="920dp"
android:minHeight="540dp"
android:minWidth="480dp"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down Expand Up @@ -116,7 +120,6 @@
android:resizeableActivity="true"
android:supportsPictureInPicture="true"
android:documentLaunchMode="always"
android:taskAffinity=".taskx11"
android:windowSoftInputMode="stateHidden">
<layout
android:minHeight="${MainActivityMinHeight}"
Expand All @@ -136,7 +139,6 @@
</activity>
<activity
android:name=".LoriePreferences"
android:excludeFromRecents="true"
android:exported="true"
android:resizeableActivity="true"
android:supportsPictureInPicture="false"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/cpp/lorie/InitInput.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ from The Open Group.
#include "exevents.h"
#include "renderer.h"
#include <android/log.h>
#define PRINT_LOG 0
extern Bool LOG_ENABLE;
#define PRINT_LOG (1 && LOG_ENABLE)
#define log(...) if(PRINT_LOG){ __android_log_print(ANDROID_LOG_DEBUG, "huyang_initinput", __VA_ARGS__);}
#define loge(...) if(PRINT_LOG){ __android_log_print(ANDROID_LOG_ERROR, "huyang_initinput", __VA_ARGS__);}

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/cpp/lorie/InitOutput.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ from The Open Group.
#define unwrap(priv, real, mem) { real->mem = priv->mem; }
#define USAGE (AHARDWAREBUFFER_USAGE_CPU_WRITE_OFTEN | AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN)

#define PRINT_LOG 0
extern Bool LOG_ENABLE;
#define PRINT_LOG (1 && LOG_ENABLE)
#define log(prio, ...) if(PRINT_LOG){ __android_log_print(ANDROID_LOG_ ## prio, "huyang_InitOutput", __VA_ARGS__);}
#define logh(...) if(PRINT_LOG){__android_log_print(ANDROID_LOG_ERROR, "huyang_InitOutput", __VA_ARGS__);}

Expand Down
101 changes: 57 additions & 44 deletions app/src/main/cpp/lorie/android.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ const Atom _NET_WM_WINDOW_TYPE_NORMAL = 273;
const Atom _NET_WM_WINDOW_TYPE_POPUP_MENU = 274;
const Atom _NET_WM_WINDOW_TYPE_TOOLTIP = 275;
const Atom _NET_WM_WINDOW_TYPE_UTILITY = 276;

#define PRINT_LOG 0
Bool LOG_ENABLE;
#define PRINT_LOG (1 && LOG_ENABLE)
#define log(prio, ...) if(PRINT_LOG){__android_log_print(ANDROID_LOG_ ## prio, "huyang_android", __VA_ARGS__);}

static int argc = 0;
Expand Down Expand Up @@ -82,19 +82,16 @@ bool IfRealizedWindow(WindowPtr widget);

#define CHECK_WITH_PROP if(!pWin){log(ERROR, "LOG_PROPERTIES pWin null");return;}\
if(!pWin->optional){log(ERROR, "LOG_PROPERTIES optional null");return;}\
if(!pWin->optional->userProps){log(ERROR, "LOG_PROPERTIES userProps null");return;} \

if(!pWin->optional->userProps){log(ERROR, "LOG_PROPERTIES userProps null");return;}
#define CHECK_CHILD pWin = pWin->firstChild; CHECK_WITH_PROP

#define STRCPY char * atom_value = (char *)calloc(pProper->size + 1, sizeof(char));strncpy(atom_value, propData, pProper->size);

#define STRING_EQUAL(str1, str2) (strcmp((str1), (str2)) == 0 ? 1 : 0)

bool android_check_bounds(WindowPtr pWindow, WindAttribute *attr);

bool check_bounds(int x, int y, int w, int h, int x1, int y1, int w1, int h1);

void xserver_get_window_property(WindowPtr pWindow, WindProperty *aProperty);
void xserver_get_window_property(WindowPtr pWindow, WindProperty *prop);

static inline JNIEnv *GetJavaEnv(void) {
if (!jniVM) {
Expand Down Expand Up @@ -140,13 +137,13 @@ void android_destroy_window(Window window) {
log(DEBUG,"android_destroy_window textureId:%d", attr->texture_id);
} else if(_surface_count_widget(sfWraper, window)){
log(DEBUG, "destroy widget");
// Widget *widget = _surface_find_widget(sfWraper, window);
Widget *widget = _surface_find_widget(sfWraper, window);
// if(!widget->inbounds){
// android_destroy_view(0, widget->pWin, widget->task_to, widget->window, ACTION_DISMISS);
// }
// widget->discard = 1;
// glDeleteTextures(1, &widget->texture_id);
// _surface_remove_widget(sfWraper, window);
widget->discard = 1;
glDeleteTextures(1, &widget->texture_id);
_surface_remove_widget(sfWraper, window);
}
}

Expand Down Expand Up @@ -225,7 +222,7 @@ void android_redirect_window(WindowPtr pWin) {
.aProperty = aProperty
};
_surface_redirect_window(sfWraper, pWin->drawable.id, &windAttribute, win_type);
android_create_window(windAttribute, aProperty, 0, false);
android_create_window(windAttribute, aProperty, 0, false);
return;
}
}
Expand Down Expand Up @@ -268,99 +265,115 @@ void android_icon_convert_bitmap(int* data, int width, int height, WindProperty
}


void xserver_get_window_property(WindowPtr pWin, WindProperty *pProperty) {
void xserver_get_window_property(WindowPtr pWin, WindProperty *prop) {
CHECK_WITH_PROP;
PropertyPtr pProper = pWin->optional->userProps;
unsigned char *propData = NULL;
pProperty->window = pWin->drawable.id;
unsigned char *propData;
prop->window = pWin->drawable.id;
bool overrideRedirect = pWin->overrideRedirect;
log(ERROR, "prop start================================>");
log(ERROR, "prop window:%x realized:%d", pWin->drawable.id, pWin->realized);
log(ERROR, "prop window:%x overrideRedirect:%d", pWin->drawable.id, overrideRedirect);
while (pProper) {
ATOM name = pProper->propertyName;
propData = pProper->data;
if (STRING_EQUAL(NameForAtom(name), WINDOW_TYPE)) {
Atom *atoms = (Atom *) propData;
for (int i = 0; i < pProper->size; i++) {
char* type = NameForAtom(atoms[i]);
log(ERROR, "prop window:%x type:%s", pWin->drawable.id, type);
if (STRING_EQUAL(NameForAtom(atoms[i]), WINDOW_TYPE_NORMAL)) {
pProperty->window_type = _NET_WM_WINDOW_TYPE_NORMAL;
prop->window_type = _NET_WM_WINDOW_TYPE_NORMAL;
if(!overrideRedirect){
break;
} else {
pProperty->window_type = _NET_WM_WINDOW_TYPE_MENU;
prop->window_type = _NET_WM_WINDOW_TYPE_MENU;
}
} else if (STRING_EQUAL(NameForAtom(atoms[i]), WINDOW_TYPE_DIALOG) ) {
pProperty->window_type = _NET_WM_WINDOW_TYPE_DIALOG;
prop->window_type = _NET_WM_WINDOW_TYPE_DIALOG;
if(!overrideRedirect){
break;
} else {
pProperty->window_type = _NET_WM_WINDOW_TYPE_MENU;
prop->window_type = _NET_WM_WINDOW_TYPE_MENU;
}
} else if (STRING_EQUAL(NameForAtom(atoms[i]), WINDOW_TYPE_UTILITY)){
pProperty->window_type = _NET_WM_WINDOW_TYPE_UTILITY;
prop->window_type = _NET_WM_WINDOW_TYPE_UTILITY;
if(overrideRedirect){
break;
}
} else if (STRING_EQUAL(NameForAtom(atoms[i]), WINDOW_TYPE_POPUP)){
pProperty->window_type = _NET_WM_WINDOW_TYPE_POPUP_MENU;
prop->window_type = _NET_WM_WINDOW_TYPE_POPUP_MENU;
if(overrideRedirect){
break;
}
} else if (STRING_EQUAL(NameForAtom(atoms[i]), WINDOW_TYPE_MENU)){
pProperty->window_type = _NET_WM_WINDOW_TYPE_MENU;
prop->window_type = _NET_WM_WINDOW_TYPE_MENU;
if(overrideRedirect){
break;
}
} else if (STRING_EQUAL(NameForAtom(atoms[i]), WINDOW_TYPE_TOOLTIP)){
pProperty->window_type = _NET_WM_WINDOW_TYPE_TOOLTIP;
prop->window_type = _NET_WM_WINDOW_TYPE_TOOLTIP;
if(overrideRedirect){
break;
}
} else if (STRING_EQUAL(NameForAtom(atoms[i]), WINDOW_TYPE_COMBO)){
prop->window_type = _NET_WM_WINDOW_TYPE_COMBO;
if(overrideRedirect){
break;
}
} else {
prop->window_type = atoms[i];
}

const char *atomValue = NameForAtom(atoms[i]);
}
} else if (STRING_EQUAL(NameForAtom(name), WINDWO_TRANSIENT_FOR)) {
pProperty->transient = ((Window *) propData)[0];
}
else if (STRING_EQUAL(NameForAtom(name), WINDWO_TRANSIENT_FOR)) {
prop->transient = ((Window *) propData)[0];
log(ERROR, "prop window:%x transient:%x", pWin->drawable.id, prop->transient);
} else if (STRING_EQUAL(NameForAtom(name), WINDOW_CLIENT_LEADER)) {
pProperty->leader = ((Window *) propData)[0];
prop->leader = ((Window *) propData)[0];
log(ERROR, "prop window:%x leader:%x", pWin->drawable.id, prop->leader);
} else if (STRING_EQUAL(NameForAtom(name), NET_WINDOW_NAME)) {
STRCPY;
pProperty->net_wm_name = atom_value;
// log(DEBUG, "%s:%s size:%d", NET_WINDOW_NAME, atom_value, pProper->size);
prop->net_wm_name = atom_value;
log(ERROR, "prop window:%x net_wm_name:%s", pWin->drawable.id, prop->net_wm_name);
} else if (STRING_EQUAL(NameForAtom(name), WINDOW_CLASS)){
STRCPY;
pProperty->wm_class = atom_value;
// log(DEBUG, "%s:%s size:%d", WINDOW_CLASS, atom_value, pProper->size);
prop->wm_class = atom_value;
log(ERROR, "prop window:%x wm_class:%s", pWin->drawable.id, prop->wm_class);
} else if (STRING_EQUAL(NameForAtom(name), WINDOW_NAME)) {
STRCPY;
pProperty->wm_name = atom_value;
// log(DEBUG, "%s:%s size:%d", WINDOW_NAME, atom_value, pProper->size);
prop->wm_name = atom_value;
log(ERROR, "prop window:%x wm_name:%s", pWin->drawable.id, prop->wm_name);
} else if (STRING_EQUAL(NameForAtom(name), WINDOW_ICON)) {
int *icon_data = (int *)propData;
int width = *icon_data;
int height = *(icon_data+1);
int * imageData = ( int*) (icon_data + 2);
android_icon_convert_bitmap(imageData, width, height, pProperty);
android_icon_convert_bitmap(imageData, width, height, prop);
} else if (STRING_EQUAL(NameForAtom(name), WINDOW_PROTOCOLS)) {
Atom *atoms = (Atom *)propData;
for (int i = 0; i < pProper->size; i++) {
if(STRING_EQUAL(NameForAtom(atoms[i]), WINDOW_DELETE_WINDOW)){
pProperty->support_wm_delete = TRUE;
prop->support_wm_delete = TRUE;
}
log(ERROR, "prop window:%x protocol:%s", pWin->drawable.id, NameForAtom(atoms[i]));
}
}
pProper = pProper->next;
}
if(pProperty->window_type == 0){
pProperty->window_type = _NET_WM_WINDOW_TYPE_NORMAL;
if(prop->window_type == 0){
prop->window_type = _NET_WM_WINDOW_TYPE_NORMAL;
}
log(ERROR, "prop end================================>");

}

bool check_bounds(int x, int y, int w, int h, int x1, int y1, int w1, int h1) {
log(DEBUG, "check_bounds x:%d y:%d w:%d h:%d x1:%d y1:%d w1:%d h1:%d ",
x, y, w, h, x1, y1, w1, h1);
if(w < 30 || h < 30 ){
return TRUE;
}
// if(w < 30 && h < 30 ){
// return TRUE;
// }
if (x < x1 || y < y1 || (x + w) > (x1 + w1) || (y + h) > (y1 + h1)) {
return FALSE;
}
Expand All @@ -387,7 +400,7 @@ void android_redirect_widget(WindowPtr pWin, WindProperty prop, Window window)
GLuint id = renderer_gen_bind_texture(pWin->drawable.x, pWin->drawable.y,
pixmap->drawable.width,
pixmap->drawable.height, pixmap->devPrivate.ptr, 0);
bool inBound = android_check_bounds(pWin, attr);
bool inBound = android_check_bounds(pWin, attr) && prop.window_type != _NET_WM_WINDOW_TYPE_DND;
Widget widget = {
.texture_id = id,
.offset_x = pWin->drawable.x,
Expand Down Expand Up @@ -559,13 +572,13 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
}

JNIEXPORT jboolean JNICALL
Java_com_termux_x11_Xserver_start(JNIEnv *env, unused jobject thiz, jobjectArray args) {
Java_com_termux_x11_Xserver_start(JNIEnv *env, unused jobject thiz, jobjectArray args, jboolean logEnable) {
pthread_t t;
JavaVM *vm = NULL;
// execv's argv array is a bit incompatible with Java's String[], so we do some converting here...
argc = (*env)->GetArrayLength(env, args) + 1; // Leading executable path
argv = (char **) calloc(argc, sizeof(char *));

LOG_ENABLE = logEnable;

JNIEnv *JavaEnv = env;
JavaCmdEntryPointClass = (*JavaEnv)->NewGlobalRef(JavaEnv, thiz);
Expand Down
1 change: 1 addition & 0 deletions app/src/main/cpp/lorie/c_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define WINDOW_TYPE_NORMAL "_NET_WM_WINDOW_TYPE_NORMAL"
#define WINDOW_TYPE_MENU "_NET_WM_WINDOW_TYPE_MENU"
#define WINDOW_TYPE_TOOLTIP "_NET_WM_WINDOW_TYPE_TOOLTIP"
#define WINDOW_TYPE_COMBO "_NET_WM_WINDOW_TYPE_COMBO"
#define WINDOW_TYPE_DIALOG "_NET_WM_WINDOW_TYPE_DIALOG"
#define WINDOW_TYPE_POPUP "_NET_WM_WINDOW_TYPE_POPUP_MENU"
#define WINDOW_TYPE_UTILITY "_NET_WM_WINDOW_TYPE_UTILITY"
Expand Down
69 changes: 0 additions & 69 deletions app/src/main/cpp/lorie/ewmh_icccm.h

This file was deleted.

7 changes: 4 additions & 3 deletions app/src/main/cpp/lorie/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
#include <globals.h>
#include "c_interface.h"
#include <android/log.h>
#define PRINT_LOG 0
extern Bool LOG_ENABLE;
#define PRINT_LOG (1 && LOG_ENABLE)
#define log(...) if(PRINT_LOG){ __android_log_print(ANDROID_LOG_DEBUG, "huyang_renderer", __VA_ARGS__);}
#define loge(...) if(PRINT_LOG){ __android_log_print(ANDROID_LOG_ERROR, "huyang_renderer", __VA_ARGS__);}

Expand Down Expand Up @@ -1005,8 +1006,8 @@ int renderer_redraw_traversal_1(JNIEnv *env, uint8_t flip, int index, Window win
return FALSE;
}

log("renderer_redraw_traversal eglSurface:%p index:%d width:%f height:%f id:%d", eglSurface,
index, width, height, id);
log("renderer_redraw_traversal eglSurface:%p index:%d width:%.f height:%.f x:%.f y:%.f id:%d", eglSurface,
index, width, height, attr->offset_x, attr->offset_y, id);
glViewport(0, 0, width, height);
checkGlError();
if (eglMakeCurrent(global_egl_display, eglSurface, eglSurface, global_ctx) != EGL_TRUE) {
Expand Down
Loading

0 comments on commit 39dc6a2

Please sign in to comment.