diff options
author | YuutaW <17158086+Trumeet@users.noreply.github.com> | 2019-06-29 11:40:14 -0700 |
---|---|---|
committer | Trumeet <17158086+Trumeet@users.noreply.github.com> | 2019-06-29 11:40:14 -0700 |
commit | 3466e043e1bbbb174f7b9fb8c2524a3444fccc47 (patch) | |
tree | 3ab6bed083c39bb40b9a59d3c702fba88045ab31 | |
download | Aero-3466e043e1bbbb174f7b9fb8c2524a3444fccc47.tar Aero-3466e043e1bbbb174f7b9fb8c2524a3444fccc47.tar.gz Aero-3466e043e1bbbb174f7b9fb8c2524a3444fccc47.tar.bz2 Aero-3466e043e1bbbb174f7b9fb8c2524a3444fccc47.zip |
First Commit
Signed-off-by: Trumeet <17158086+Trumeet@users.noreply.github.com>
-rw-r--r-- | .github/FUNDING.yml | 12 | ||||
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .travis.yml | 33 | ||||
-rw-r--r-- | LICENSE | 13 | ||||
-rw-r--r-- | README.md | 15 | ||||
-rw-r--r-- | build.gradle | 31 | ||||
-rw-r--r-- | gradle.properties | 2 | ||||
-rw-r--r-- | gradle/wrapper/gradle-wrapper.jar | bin | 0 -> 54413 bytes | |||
-rw-r--r-- | gradle/wrapper/gradle-wrapper.properties | 5 | ||||
-rw-r--r-- | gradlew | 172 | ||||
-rw-r--r-- | gradlew.bat | 84 | ||||
-rw-r--r-- | settings.gradle | 2 | ||||
-rw-r--r-- | src/mingwMain/kotlin/moe/yuuta/aero/Aero.kt | 68 | ||||
-rw-r--r-- | src/nativeInterop/cinterop/aero.def | 2 | ||||
-rw-r--r-- | src/nativeInterop/cinterop/aero.h | 62 |
15 files changed, 503 insertions, 0 deletions
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..e0f5a65 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,12 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: # Replace with a single Patreon username +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +liberapay: # Replace with a single Liberapay username +issuehunt: # Replace with a single IssueHunt username +otechie: # Replace with a single Otechie username +custom: https://yuuta.moe/#donate
\ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2388c53 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +build/
\ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ea819b2 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,33 @@ +language: shell +os: windows +git: + depth: false +if: branch = master +before_cache: + - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock + - rm -rf $HOME/.gradle/caches/*/plugin-resolution/ +cache: + directories: + - "$HOME/.gradle/caches/" + - "$HOME/.gradle/wrapper/" + - "$HOME/.konan/kotlin-native-windows-1.3" +script: + - choco install jdk8 + - export JAVA_HOME='C:\Program Files\Java\jdk1.8.0_211\' + - export GRADLE_OPTS="-Dorg.gradle.daemon=false" + - "./gradlew.bat :build" +before_deploy: + # TODO: Add this part to the Gradle + - export VERSION=$(git rev-list --count HEAD) + - git tag $VERSION + - mv "build/bin/mingwX64/releaseExecutable/Aero.exe" "./Aero-$VERSION.exe" +deploy: + name: ${VERSION} + prerelease: true + provider: releases + skip_cleanup: true + api_key: $GITHUB_RELEASE_KEY + file: + - Aero-$VERSION.exe + on: + repo: Trumeet/Desktop
\ No newline at end of file @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2019 Sam Hocevar <sam@hocevar.net> + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO.
\ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..3f4ad09 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# Aero + +It is an demo of enabling Aero on Windows 10 using hidden APIs and it's written in Kotlin Native. + +## Acknowledgements + +* [https://gist.github.com/ysc3839/b08d2bff1c7dacde529bed1d37e85ccf](https://gist.github.com/ysc3839/b08d2bff1c7dacde529bed1d37e85ccf) + +* [@ysc3839](https://github.com/ysc3839) + +* [https://blog.ysc3839.com/archives/2017/10/win10-aero-undocumented-api.html](https://blog.ysc3839.com/archives/2017/10/win10-aero-undocumented-api.html) + +# Licenses + +WTFPL
\ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..6317036 --- /dev/null +++ b/build.gradle @@ -0,0 +1,31 @@ +plugins { + id 'org.jetbrains.kotlin.multiplatform' version '1.3.40' +} +repositories { + jcenter() + mavenCentral() +} + +kotlin { + mingwX64() + sourceSets { + mingwX64Main { + mingwX64Main.kotlin.srcDirs += file("src/mingwMain/kotlin") + } + } + mingwX64 { + binaries { + executable { + entryPoint 'moe.yuuta.aero.main' + linkerOpts "-Wl,--subsystem,windows" + } + } + compilations.main.cinterops { + aero { + includeDirs { + allHeaders 'src/nativeInterop/cinterop' + } + } + } + } +}
\ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..de16ded --- /dev/null +++ b/gradle.properties @@ -0,0 +1,2 @@ +kotlin.code.style=official +kotlin.import.noCommonSourceSets=true
\ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar Binary files differnew file mode 100644 index 0000000..91ca28c --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..16d2805 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.7-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..7c07b6e --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'Aero' + diff --git a/src/mingwMain/kotlin/moe/yuuta/aero/Aero.kt b/src/mingwMain/kotlin/moe/yuuta/aero/Aero.kt new file mode 100644 index 0000000..6f5f5d3 --- /dev/null +++ b/src/mingwMain/kotlin/moe/yuuta/aero/Aero.kt @@ -0,0 +1,68 @@ +package moe.yuuta.aero + +import aero.* +import kotlinx.cinterop.* +import platform.windows.* + +fun main() { + SetProcessDPIAware() + val dlgImpl = cValue<DLGTEMPLATE> { + style = (WS_OVERLAPPEDWINDOW or + DS_CENTER or + DS_MODALFRAME).convert() + dwExtendedStyle = 0.convert() + cdit = 0.convert() + x = 0 + y = 0 + cx = 400 + cy = 200 + } + memScoped { + return@memScoped DialogBoxIndirectParamW(GetModuleHandleA(null), + dlgImpl.ptr, + null, + staticCFunction(::dlgProc) as DLGPROC, + 0) + } +} + +fun dlgProc(hDlg: HWND, + message: UINT, + wParam: WPARAM, + lParam: LPARAM): INT_PTR { + when (message.convert<Int>()) { + WM_INITDIALOG -> { + val hUser = GetModuleHandleW("user32.dll") + if (hUser != null) { + val setWindowCompositionAttribute = GetProcAddress(hUser, "SetWindowCompositionAttribute") as pfnSetWindowCompositionAttribute? + if (setWindowCompositionAttribute != null) { + val accent = cValue<ACCENT_POLICY> { + AccentState = ACCENT_ENABLE_BLURBEHIND + AccentFlags = 0.convert() + GradientColor = 0.convert() + AnimationId = 0.convert() + } + memScoped { + val data = cValue<WINDOWCOMPOSITIONATTRIBDATA> { + Attrib = WCA_ACCENT_POLICY + pvData = accent.ptr + cbData = accent.size.convert() + } + setWindowCompositionAttribute(hDlg, data.ptr) + } + } + } + return true.toByte().toLong() + } + WM_COMMAND -> { + EndDialog(hDlg, wParam.convert()) + return true.toByte().toLong() + } + WM_CTLCOLORDLG -> { + return GetStockObject(BLACK_BRUSH).rawValue.toLong() + } + else -> { + return false.toByte().toLong() + } + } +}
\ No newline at end of file diff --git a/src/nativeInterop/cinterop/aero.def b/src/nativeInterop/cinterop/aero.def new file mode 100644 index 0000000..4032443 --- /dev/null +++ b/src/nativeInterop/cinterop/aero.def @@ -0,0 +1,2 @@ +headers = aero.h +package = aero
\ No newline at end of file diff --git a/src/nativeInterop/cinterop/aero.h b/src/nativeInterop/cinterop/aero.h new file mode 100644 index 0000000..639d6c3 --- /dev/null +++ b/src/nativeInterop/cinterop/aero.h @@ -0,0 +1,62 @@ +#pragma once +#include <windows.h> +typedef enum _WINDOWCOMPOSITIONATTRIB +{ + WCA_UNDEFINED = 0, + WCA_NCRENDERING_ENABLED = 1, + WCA_NCRENDERING_POLICY = 2, + WCA_TRANSITIONS_FORCEDISABLED = 3, + WCA_ALLOW_NCPAINT = 4, + WCA_CAPTION_BUTTON_BOUNDS = 5, + WCA_NONCLIENT_RTL_LAYOUT = 6, + WCA_FORCE_ICONIC_REPRESENTATION = 7, + WCA_EXTENDED_FRAME_BOUNDS = 8, + WCA_HAS_ICONIC_BITMAP = 9, + WCA_THEME_ATTRIBUTES = 10, + WCA_NCRENDERING_EXILED = 11, + WCA_NCADORNMENTINFO = 12, + WCA_EXCLUDED_FROM_LIVEPREVIEW = 13, + WCA_VIDEO_OVERLAY_ACTIVE = 14, + WCA_FORCE_ACTIVEWINDOW_APPEARANCE = 15, + WCA_DISALLOW_PEEK = 16, + WCA_CLOAK = 17, + WCA_CLOAKED = 18, + WCA_ACCENT_POLICY = 19, + WCA_FREEZE_REPRESENTATION = 20, + WCA_EVER_UNCLOAKED = 21, + WCA_VISUAL_OWNER = 22, + WCA_HOLOGRAPHIC = 23, + WCA_EXCLUDED_FROM_DDA = 24, + WCA_PASSIVEUPDATEMODE = 25, + WCA_LAST = 26 +} WINDOWCOMPOSITIONATTRIB; + +typedef struct _WINDOWCOMPOSITIONATTRIBDATA +{ + WINDOWCOMPOSITIONATTRIB Attrib; + PVOID pvData; + SIZE_T cbData; +} WINDOWCOMPOSITIONATTRIBDATA; + +typedef enum _ACCENT_STATE +{ + ACCENT_DISABLED = 0, + ACCENT_ENABLE_GRADIENT = 1, + ACCENT_ENABLE_TRANSPARENTGRADIENT = 2, + ACCENT_ENABLE_BLURBEHIND = 3, + ACCENT_ENABLE_ACRYLICBLURBEHIND = 4, // RS4 1803 + ACCENT_ENABLE_HOSTBACKDROP = 5, // RS5 1809 + ACCENT_INVALID_STATE = 6 +} ACCENT_STATE; + +typedef struct _ACCENT_POLICY +{ + ACCENT_STATE AccentState; + DWORD AccentFlags; + DWORD GradientColor; + DWORD AnimationId; +} ACCENT_POLICY; + +typedef BOOL (WINAPI *pfnGetWindowCompositionAttribute)(HWND, WINDOWCOMPOSITIONATTRIBDATA*); + +typedef BOOL (WINAPI *pfnSetWindowCompositionAttribute)(HWND, WINDOWCOMPOSITIONATTRIBDATA*);
\ No newline at end of file |