Compare commits

...

38 commits

Author SHA1 Message Date
4e2c270908 ok
Some checks are pending
pyrite-dev/milsko/pipeline/head Build started...
2026-09-22 11:16:12 +09:00
cdf7657b19 ok 2026-09-22 11:16:12 +09:00
7d2b5a17a4 o 2026-09-22 11:16:12 +09:00
9bdd80b421 fix watcom 2026-09-22 11:16:12 +09:00
dfa8c22f1a fix 2026-09-22 11:16:12 +09:00
21911dd899 Update examples/dxdemos/CMakeLists.txt 2026-09-22 11:16:12 +09:00
e7dc38175f experiment with cmake not trying to find directx 2026-09-22 11:16:12 +09:00
7f361b9d15 correct names 2026-09-22 11:16:12 +09:00
ec45c8828d rename 2026-09-22 11:16:12 +09:00
83eb8c8dc4 ok 2026-09-22 11:16:12 +09:00
c5330cc184 direct3d9 2026-09-22 11:16:11 +09:00
12b89aab9b Update Jenkinsfile 2026-09-22 11:15:58 +09:00
e967523063 Update pl/rules.pl 2026-09-22 11:15:58 +09:00
aef5fe03a9 Update configure 2026-09-22 11:15:58 +09:00
a0da41210a Update configure 2026-09-22 11:15:58 +09:00
fb9919de2a oh wait the jenkinsfile can at least use enable-d3d 2026-09-22 11:15:58 +09:00
a18ca58f18 xml 2026-09-22 11:15:57 +09:00
f89eaf6901 put nul in gitignore for watcom cross compile 2026-09-22 11:15:01 +09:00
2f3b8f2417 error handling for d3d8 and d3d9 2026-09-22 11:15:01 +09:00
5872c43539 have watcom check for d3d8.h/d3d9.h 2026-09-22 11:15:01 +09:00
2a19c5e5cf genmk 2026-09-22 11:15:01 +09:00
87cbb582f7 perl 2026-09-22 11:15:01 +09:00
47c9f8df4e d3d8 too 2026-09-22 11:15:00 +09:00
bc326491b5 dx9 2026-09-22 11:15:00 +09:00
960db8d3e3 some fix
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
2026-09-22 10:13:08 +09:00
c2f8fb3f82 wayland: actual subsurface type for the one widget that needs it (vulkan)
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
2026-09-21 17:22:15 -07:00
e43a5291f5 combobox fix
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
2026-09-21 16:55:27 -07:00
58027c095f snapshot previous buffer so that we don't have ghosting anymore on rotate (this also makes resizing A Bit better)
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
2026-09-21 16:51:46 -07:00
cb5efd9224 wayland: got resizing looking good enough
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
2026-09-21 15:49:01 -07:00
954a4a8e15 disable dnd on X11 for now
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
2026-09-21 14:27:03 -07:00
9420878b93 oops! fix csd not working
Some checks are pending
pyrite-dev/milsko/pipeline/head Build started...
2026-09-21 12:01:23 -07:00
e8d692f05a remove the unneeded 'wayland event start/end' macros
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
2026-09-21 11:54:07 -07:00
4cb88fdc05 wayland: remove our widget from parent's currently held widgets on destroy
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
2026-09-21 11:40:51 -07:00
b1a2d4d549 wayland fixes
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
2026-09-21 11:36:08 -07:00
f8c678ac53 ok
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
2026-09-21 12:41:56 +09:00
2858679cc4 optimize
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
2026-09-21 11:57:37 +09:00
39dd112f2b improve callback
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good
2026-09-21 11:47:44 +09:00
2b15e7e0a3 introducde underline and strikethrough
Some checks are pending
pyrite-dev/milsko/pipeline/head Build started...
2026-09-18 13:11:42 +09:00
33 changed files with 1131 additions and 166 deletions

2
.gitignore vendored
View file

@ -33,3 +33,5 @@ compile_flags.txt
flamegraph.svg
perf.*
nul

View file

@ -33,6 +33,13 @@ else()
option(MW_TRY_VULKAN "Try to compile Vulkan widget or not" ON)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES Windows)
option(MW_TRY_DIRECT3D9 "Try to compile Direct3D9 widget or not" ON)
else()
option(MW_TRY_DIRECT3D9 "Try to compile Direct3D9 widget or not" OFF)
endif()
option(MW_INSTALL_HEADERS "Install headers" ON)
if( ${CMAKE_SYSTEM_NAME} STREQUAL Darwin
@ -90,6 +97,11 @@ if(MW_TRY_VULKAN)
endif()
endif()
if(MW_TRY_DIRECT3D9)
set(MW_BUILD_DIRECT3D9 ON)
message(STATUS "Direct3D9 widget has been enabled")
endif()
if(MW_BUILD_STATIC)
message(STATUS "Building Milsko as a static library")
add_library(
@ -467,7 +479,7 @@ if(MW_BUILD_VULKAN)
)
endif()
check_include_files(vulkan/VULKAN.h HAS_VK_HEADER)
check_include_files(vulkan/vulkan.h HAS_VK_HEADER)
if(HAS_VK_HEADER)
target_compile_definitions(
Mw
@ -477,6 +489,14 @@ if(MW_BUILD_VULKAN)
endif()
endif()
if(MW_BUILD_DIRECT3D9)
target_compile_definitions(
Mw
PUBLIC
MW_DIRECT3D9
)
endif()
target_compile_definitions(
Mw
PRIVATE

2
Jenkinsfile vendored
View file

@ -80,7 +80,7 @@ pipeline {
}
environment {
WATCOM = "/usr/watcom"
INCLUDE = "/usr/watcom/h:/usr/watcom/h/nt"
INCLUDE = "/usr/watcom/h:/usr/watcom/h/nt:/usr/watcom/h/nt/directx"
PATH = "/usr/watcom/binl64:${env.PATH}"
}
steps {

21
NTMakefile generated
View file

@ -1,7 +1,20 @@
CC = cl /TC /c /nologo
LD = link /nologo
MW_CFLAGS = /Iinclude /Iexternal\libz\include /D_MILSKO /D_MILSKO_BUILD /DUSE_GDI /DUSE_STB_IMAGE /DSTBI_NO_SIMD /DUSE_GDI_TEXT /DMW_OPENGL
!if [where /R "%DXSDK_DIR%\\Include" /Q d3d9.h] == 0
!if [echo DX9_FLAGS = /DMW_DIRECT3D9 /I"%DXSDK_DIR%\\Include">d3d9flags.mk]
!endif
!else
!if [echo DX9_FLAGS =>d3d9flags.mk]
!endif
!endif
!if exist("d3d9flags.mk")
!include "d3d9flags.mk"
!else
DX9_FLAGS =
!endif
MW_CFLAGS = /Iinclude /Iexternal\libz\include /D_MILSKO /D_MILSKO_BUILD /DUSE_GDI /DUSE_STB_IMAGE /DSTBI_NO_SIMD /DUSE_GDI_TEXT /DMW_OPENGL $(DX9_FLAGS)
MW_LDFLAGS = /DLL
EXE_CFLAGS = /Iinclude
EXE_LDFLAGS =
@ -86,6 +99,7 @@ clean:
del /f /q src\widget\checkbox.obj
del /f /q src\widget\clock.obj
del /f /q src\widget\combobox.obj
del /f /q src\widget\direct3d9.obj
del /f /q src\widget\document.obj
del /f /q src\widget\entry.obj
del /f /q src\widget\frame.obj
@ -108,6 +122,7 @@ clean:
del /f /q src\widget\window.obj
del /f /q src\Mw.dll
del /f /q src\Mw.lib
del /f /q d3d9flags.mk
del /f /q examples\basic\box.obj
del /f /q examples\basic\calculator.obj
del /f /q examples\basic\checkbox.obj
@ -342,8 +357,8 @@ examples\gldemos\tripaint.obj: examples/gldemos/tripaint.c
$(CC) $(EXE_CFLAGS) /Fo$@ examples/gldemos/tripaint.c
src\Mw.dll: external\libz\src\adler32.obj external\libz\src\compress.obj external\libz\src\crc32.obj external\libz\src\deflate.obj external\libz\src\gzclose.obj external\libz\src\gzlib.obj external\libz\src\gzread.obj external\libz\src\gzwrite.obj external\libz\src\infback.obj external\libz\src\inffast.obj external\libz\src\inflate.obj external\libz\src\inftrees.obj external\libz\src\trees.obj external\libz\src\uncompr.obj external\libz\src\zutil.obj external\md4c.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\charset.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\center.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hand.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text\font\boldfont.obj src\text\font\boldmonottf.obj src\text\font\boldttf.obj src\text\font\font.obj src\text\font\monottf.obj src\text\font\ttf.obj src\text\ft2.obj src\text\gdi.obj src\text\stbtt.obj src\text\text.obj src\truetype.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\calendar.obj src\widget\chart.obj src\widget\checkbox.obj src\widget\clock.obj src\widget\combobox.obj src\widget\document.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\subwindow.obj src\widget\tab.obj src\widget\table.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj
$(LD) $(MW_LDFLAGS) /OUT:$@ external\libz\src\adler32.obj external\libz\src\compress.obj external\libz\src\crc32.obj external\libz\src\deflate.obj external\libz\src\gzclose.obj external\libz\src\gzlib.obj external\libz\src\gzread.obj external\libz\src\gzwrite.obj external\libz\src\infback.obj external\libz\src\inffast.obj external\libz\src\inflate.obj external\libz\src\inftrees.obj external\libz\src\trees.obj external\libz\src\uncompr.obj external\libz\src\zutil.obj external\md4c.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\charset.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\center.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hand.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text\font\boldfont.obj src\text\font\boldmonottf.obj src\text\font\boldttf.obj src\text\font\font.obj src\text\font\monottf.obj src\text\font\ttf.obj src\text\ft2.obj src\text\gdi.obj src\text\stbtt.obj src\text\text.obj src\truetype.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\calendar.obj src\widget\chart.obj src\widget\checkbox.obj src\widget\clock.obj src\widget\combobox.obj src\widget\document.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\subwindow.obj src\widget\tab.obj src\widget\table.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj opengl32.lib gdi32.lib ole32.lib uuid.lib user32.lib advapi32.lib
src\Mw.dll: external\libz\src\adler32.obj external\libz\src\compress.obj external\libz\src\crc32.obj external\libz\src\deflate.obj external\libz\src\gzclose.obj external\libz\src\gzlib.obj external\libz\src\gzread.obj external\libz\src\gzwrite.obj external\libz\src\infback.obj external\libz\src\inffast.obj external\libz\src\inflate.obj external\libz\src\inftrees.obj external\libz\src\trees.obj external\libz\src\uncompr.obj external\libz\src\zutil.obj external\md4c.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\charset.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\center.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hand.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text\font\boldfont.obj src\text\font\boldmonottf.obj src\text\font\boldttf.obj src\text\font\font.obj src\text\font\monottf.obj src\text\font\ttf.obj src\text\ft2.obj src\text\gdi.obj src\text\stbtt.obj src\text\text.obj src\truetype.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\calendar.obj src\widget\chart.obj src\widget\checkbox.obj src\widget\clock.obj src\widget\combobox.obj src\widget\direct3d9.obj src\widget\document.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\subwindow.obj src\widget\tab.obj src\widget\table.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj
$(LD) $(MW_LDFLAGS) /OUT:$@ external\libz\src\adler32.obj external\libz\src\compress.obj external\libz\src\crc32.obj external\libz\src\deflate.obj external\libz\src\gzclose.obj external\libz\src\gzlib.obj external\libz\src\gzread.obj external\libz\src\gzwrite.obj external\libz\src\infback.obj external\libz\src\inffast.obj external\libz\src\inflate.obj external\libz\src\inftrees.obj external\libz\src\trees.obj external\libz\src\uncompr.obj external\libz\src\zutil.obj external\md4c.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\charset.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\center.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hand.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text\font\boldfont.obj src\text\font\boldmonottf.obj src\text\font\boldttf.obj src\text\font\font.obj src\text\font\monottf.obj src\text\font\ttf.obj src\text\ft2.obj src\text\gdi.obj src\text\stbtt.obj src\text\text.obj src\truetype.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\calendar.obj src\widget\chart.obj src\widget\checkbox.obj src\widget\clock.obj src\widget\combobox.obj src\widget\direct3d9.obj src\widget\document.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\subwindow.obj src\widget\tab.obj src\widget\table.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj opengl32.lib gdi32.lib ole32.lib uuid.lib user32.lib advapi32.lib
.c.obj:

23
WatMakefile generated
View file

@ -1,13 +1,13 @@
CC = wcc386 -bt=nt -q
CC = wcc386 -bt=nt -q -fr
LD = wlink option quiet
MW_CFLAGS = -bd -i=include -i=external/libz/include -d_MILSKO -d_MILSKO_BUILD -dUSE_GDI -dUSE_STB_IMAGE -dSTBI_NO_SIMD -dUSE_GDI_TEXT -dMW_OPENGL
MW_CFLAGS = -bd -i=include -i=external/libz/include -d_MILSKO -d_MILSKO_BUILD -dUSE_GDI -dUSE_STB_IMAGE -dSTBI_NO_SIMD -dUSE_GDI_TEXT -dMW_OPENGL -dMW_DIRECT3D9
MW_LDFLAGS = system nt_dll
EXE_CFLAGS = -i=include
EXE_LDFLAGS = system nt
all: src/Mw.dll examples/basic/box.exe examples/basic/calculator.exe examples/basic/checkbox.exe examples/basic/clipboard.exe examples/basic/colorpicker.exe examples/basic/combobox.exe examples/basic/dnd.exe examples/basic/document.exe examples/basic/example.exe examples/basic/filechooser.exe examples/basic/image.exe examples/basic/listbox.exe examples/basic/messagebox.exe examples/basic/periodic.exe examples/basic/progressbar.exe examples/basic/radiobox.exe examples/basic/rotate.exe examples/basic/scrollbar.exe examples/basic/sevensegment.exe examples/basic/subwindow.exe examples/basic/tab.exe examples/basic/treeview.exe examples/basic/viewport.exe examples/gldemos/boing.exe examples/gldemos/clock.exe examples/gldemos/cube.exe examples/gldemos/gears.exe examples/gldemos/triangle.exe examples/gldemos/tripaint.exe
all: src/Mw.dll examples/basic/box.exe examples/basic/calculator.exe examples/basic/checkbox.exe examples/basic/clipboard.exe examples/basic/colorpicker.exe examples/basic/combobox.exe examples/basic/dnd.exe examples/basic/document.exe examples/basic/example.exe examples/basic/filechooser.exe examples/basic/image.exe examples/basic/listbox.exe examples/basic/messagebox.exe examples/basic/periodic.exe examples/basic/progressbar.exe examples/basic/radiobox.exe examples/basic/rotate.exe examples/basic/scrollbar.exe examples/basic/sevensegment.exe examples/basic/subwindow.exe examples/basic/tab.exe examples/basic/treeview.exe examples/basic/viewport.exe examples/dxdemos/direct3d9.exe examples/gldemos/boing.exe examples/gldemos/clock.exe examples/gldemos/cube.exe examples/gldemos/gears.exe examples/gldemos/triangle.exe examples/gldemos/tripaint.exe
lib: src/Mw.dll
examples: examples/basic/box.exe examples/basic/calculator.exe examples/basic/checkbox.exe examples/basic/clipboard.exe examples/basic/colorpicker.exe examples/basic/combobox.exe examples/basic/dnd.exe examples/basic/document.exe examples/basic/example.exe examples/basic/filechooser.exe examples/basic/image.exe examples/basic/listbox.exe examples/basic/messagebox.exe examples/basic/periodic.exe examples/basic/progressbar.exe examples/basic/radiobox.exe examples/basic/rotate.exe examples/basic/scrollbar.exe examples/basic/sevensegment.exe examples/basic/subwindow.exe examples/basic/tab.exe examples/basic/treeview.exe examples/basic/viewport.exe examples/gldemos/boing.exe examples/gldemos/clock.exe examples/gldemos/cube.exe examples/gldemos/gears.exe examples/gldemos/triangle.exe examples/gldemos/tripaint.exe
examples: examples/basic/box.exe examples/basic/calculator.exe examples/basic/checkbox.exe examples/basic/clipboard.exe examples/basic/colorpicker.exe examples/basic/combobox.exe examples/basic/dnd.exe examples/basic/document.exe examples/basic/example.exe examples/basic/filechooser.exe examples/basic/image.exe examples/basic/listbox.exe examples/basic/messagebox.exe examples/basic/periodic.exe examples/basic/progressbar.exe examples/basic/radiobox.exe examples/basic/rotate.exe examples/basic/scrollbar.exe examples/basic/sevensegment.exe examples/basic/subwindow.exe examples/basic/tab.exe examples/basic/treeview.exe examples/basic/viewport.exe examples/dxdemos/direct3d9.exe examples/gldemos/boing.exe examples/gldemos/clock.exe examples/gldemos/cube.exe examples/gldemos/gears.exe examples/gldemos/triangle.exe examples/gldemos/tripaint.exe
clean: .SYMBOLIC
%erase external/libz/src/adler32.obj
%erase external/libz/src/compress.obj
@ -85,6 +85,7 @@ clean: .SYMBOLIC
%erase src/widget/checkbox.obj
%erase src/widget/clock.obj
%erase src/widget/combobox.obj
%erase src/widget/direct3d9.obj
%erase src/widget/document.obj
%erase src/widget/entry.obj
%erase src/widget/frame.obj
@ -130,6 +131,7 @@ clean: .SYMBOLIC
%erase examples/basic/tab.obj
%erase examples/basic/treeview.obj
%erase examples/basic/viewport.obj
%erase examples/dxdemos/direct3d9.obj
%erase examples/gldemos/boing.obj
%erase examples/gldemos/clock.obj
%erase examples/gldemos/cube.obj
@ -159,6 +161,7 @@ clean: .SYMBOLIC
%erase examples/basic/tab.exe
%erase examples/basic/treeview.exe
%erase examples/basic/viewport.exe
%erase examples/dxdemos/direct3d9.exe
%erase examples/gldemos/boing.exe
%erase examples/gldemos/clock.exe
%erase examples/gldemos/cube.exe
@ -304,6 +307,12 @@ examples/basic/viewport.exe: examples/basic/viewport.obj src/Mw.dll
examples/basic/viewport.obj: examples/basic/viewport.c
$(CC) $(EXE_CFLAGS) -fo=$@ examples/basic/viewport.c
examples/dxdemos/direct3d9.exe: examples/dxdemos/direct3d9.obj src/Mw.dll
$(LD) $(EXE_LDFLAGS) name $@ file examples/dxdemos/direct3d9.obj library clib3r.lib library src/Mw.lib
examples/dxdemos/direct3d9.obj: examples/dxdemos/direct3d9.c
$(CC) $(EXE_CFLAGS) -fo=$@ examples/dxdemos/direct3d9.c
examples/gldemos/boing.exe: examples/gldemos/boing.obj src/Mw.dll
$(LD) $(EXE_LDFLAGS) name $@ file examples/gldemos/boing.obj library clib3r.lib library src/Mw.lib library opengl32.lib library glu32.lib
@ -341,8 +350,8 @@ examples/gldemos/tripaint.obj: examples/gldemos/tripaint.c
$(CC) $(EXE_CFLAGS) -fo=$@ examples/gldemos/tripaint.c
src/Mw.dll: external/libz/src/adler32.obj external/libz/src/compress.obj external/libz/src/crc32.obj external/libz/src/deflate.obj external/libz/src/gzclose.obj external/libz/src/gzlib.obj external/libz/src/gzread.obj external/libz/src/gzwrite.obj external/libz/src/infback.obj external/libz/src/inffast.obj external/libz/src/inflate.obj external/libz/src/inftrees.obj external/libz/src/trees.obj external/libz/src/uncompr.obj external/libz/src/zutil.obj external/md4c.obj external/stb_ds.obj external/stb_image.obj external/stb_truetype.obj src/abstract/charset.obj src/abstract/directory.obj src/abstract/dynamic.obj src/abstract/time.obj src/backend/gdi.obj src/color.obj src/core.obj src/cursor/arrow.obj src/cursor/center.obj src/cursor/cross.obj src/cursor/default.obj src/cursor/hand.obj src/cursor/hidden.obj src/cursor/text.obj src/default.obj src/dialog/colorpicker.obj src/dialog/directorychooser.obj src/dialog/filechooser.obj src/dialog/messagebox.obj src/draw.obj src/icon/back.obj src/icon/clock.obj src/icon/computer.obj src/icon/directory.obj src/icon/down.obj src/icon/error.obj src/icon/file.obj src/icon/forward.obj src/icon/info.obj src/icon/left.obj src/icon/news.obj src/icon/note.obj src/icon/right.obj src/icon/search.obj src/icon/up.obj src/icon/warning.obj src/lowlevel.obj src/string.obj src/text/font/boldfont.obj src/text/font/boldmonottf.obj src/text/font/boldttf.obj src/text/font/font.obj src/text/font/monottf.obj src/text/font/ttf.obj src/text/ft2.obj src/text/gdi.obj src/text/stbtt.obj src/text/text.obj src/truetype.obj src/unicode.obj src/widget/box.obj src/widget/button.obj src/widget/calendar.obj src/widget/chart.obj src/widget/checkbox.obj src/widget/clock.obj src/widget/combobox.obj src/widget/document.obj src/widget/entry.obj src/widget/frame.obj src/widget/image.obj src/widget/label.obj src/widget/listbox.obj src/widget/menu.obj src/widget/numberentry.obj src/widget/opengl.obj src/widget/progressbar.obj src/widget/radiobox.obj src/widget/scrollbar.obj src/widget/separator.obj src/widget/submenu.obj src/widget/subwindow.obj src/widget/tab.obj src/widget/table.obj src/widget/treeview.obj src/widget/viewport.obj src/widget/window.obj
$(LD) $(MW_LDFLAGS) option implib=src/Mw.lib name $@ file external/libz/src/adler32.obj file external/libz/src/compress.obj file external/libz/src/crc32.obj file external/libz/src/deflate.obj file external/libz/src/gzclose.obj file external/libz/src/gzlib.obj file external/libz/src/gzread.obj file external/libz/src/gzwrite.obj file external/libz/src/infback.obj file external/libz/src/inffast.obj file external/libz/src/inflate.obj file external/libz/src/inftrees.obj file external/libz/src/trees.obj file external/libz/src/uncompr.obj file external/libz/src/zutil.obj file external/md4c.obj file external/stb_ds.obj file external/stb_image.obj file external/stb_truetype.obj file src/abstract/charset.obj file src/abstract/directory.obj file src/abstract/dynamic.obj file src/abstract/time.obj file src/backend/gdi.obj file src/color.obj file src/core.obj file src/cursor/arrow.obj file src/cursor/center.obj file src/cursor/cross.obj file src/cursor/default.obj file src/cursor/hand.obj file src/cursor/hidden.obj file src/cursor/text.obj file src/default.obj file src/dialog/colorpicker.obj file src/dialog/directorychooser.obj file src/dialog/filechooser.obj file src/dialog/messagebox.obj file src/draw.obj file src/icon/back.obj file src/icon/clock.obj file src/icon/computer.obj file src/icon/directory.obj file src/icon/down.obj file src/icon/error.obj file src/icon/file.obj file src/icon/forward.obj file src/icon/info.obj file src/icon/left.obj file src/icon/news.obj file src/icon/note.obj file src/icon/right.obj file src/icon/search.obj file src/icon/up.obj file src/icon/warning.obj file src/lowlevel.obj file src/string.obj file src/text/font/boldfont.obj file src/text/font/boldmonottf.obj file src/text/font/boldttf.obj file src/text/font/font.obj file src/text/font/monottf.obj file src/text/font/ttf.obj file src/text/ft2.obj file src/text/gdi.obj file src/text/stbtt.obj file src/text/text.obj file src/truetype.obj file src/unicode.obj file src/widget/box.obj file src/widget/button.obj file src/widget/calendar.obj file src/widget/chart.obj file src/widget/checkbox.obj file src/widget/clock.obj file src/widget/combobox.obj file src/widget/document.obj file src/widget/entry.obj file src/widget/frame.obj file src/widget/image.obj file src/widget/label.obj file src/widget/listbox.obj file src/widget/menu.obj file src/widget/numberentry.obj file src/widget/opengl.obj file src/widget/progressbar.obj file src/widget/radiobox.obj file src/widget/scrollbar.obj file src/widget/separator.obj file src/widget/submenu.obj file src/widget/subwindow.obj file src/widget/tab.obj file src/widget/table.obj file src/widget/treeview.obj file src/widget/viewport.obj file src/widget/window.obj library clib3r.lib library opengl32.lib library gdi32.lib library ole32.lib library uuid.lib library user32.lib library advapi32.lib
src/Mw.dll: external/libz/src/adler32.obj external/libz/src/compress.obj external/libz/src/crc32.obj external/libz/src/deflate.obj external/libz/src/gzclose.obj external/libz/src/gzlib.obj external/libz/src/gzread.obj external/libz/src/gzwrite.obj external/libz/src/infback.obj external/libz/src/inffast.obj external/libz/src/inflate.obj external/libz/src/inftrees.obj external/libz/src/trees.obj external/libz/src/uncompr.obj external/libz/src/zutil.obj external/md4c.obj external/stb_ds.obj external/stb_image.obj external/stb_truetype.obj src/abstract/charset.obj src/abstract/directory.obj src/abstract/dynamic.obj src/abstract/time.obj src/backend/gdi.obj src/color.obj src/core.obj src/cursor/arrow.obj src/cursor/center.obj src/cursor/cross.obj src/cursor/default.obj src/cursor/hand.obj src/cursor/hidden.obj src/cursor/text.obj src/default.obj src/dialog/colorpicker.obj src/dialog/directorychooser.obj src/dialog/filechooser.obj src/dialog/messagebox.obj src/draw.obj src/icon/back.obj src/icon/clock.obj src/icon/computer.obj src/icon/directory.obj src/icon/down.obj src/icon/error.obj src/icon/file.obj src/icon/forward.obj src/icon/info.obj src/icon/left.obj src/icon/news.obj src/icon/note.obj src/icon/right.obj src/icon/search.obj src/icon/up.obj src/icon/warning.obj src/lowlevel.obj src/string.obj src/text/font/boldfont.obj src/text/font/boldmonottf.obj src/text/font/boldttf.obj src/text/font/font.obj src/text/font/monottf.obj src/text/font/ttf.obj src/text/ft2.obj src/text/gdi.obj src/text/stbtt.obj src/text/text.obj src/truetype.obj src/unicode.obj src/widget/box.obj src/widget/button.obj src/widget/calendar.obj src/widget/chart.obj src/widget/checkbox.obj src/widget/clock.obj src/widget/combobox.obj src/widget/direct3d9.obj src/widget/document.obj src/widget/entry.obj src/widget/frame.obj src/widget/image.obj src/widget/label.obj src/widget/listbox.obj src/widget/menu.obj src/widget/numberentry.obj src/widget/opengl.obj src/widget/progressbar.obj src/widget/radiobox.obj src/widget/scrollbar.obj src/widget/separator.obj src/widget/submenu.obj src/widget/subwindow.obj src/widget/tab.obj src/widget/table.obj src/widget/treeview.obj src/widget/viewport.obj src/widget/window.obj
$(LD) $(MW_LDFLAGS) option implib=src/Mw.lib name $@ file external/libz/src/adler32.obj file external/libz/src/compress.obj file external/libz/src/crc32.obj file external/libz/src/deflate.obj file external/libz/src/gzclose.obj file external/libz/src/gzlib.obj file external/libz/src/gzread.obj file external/libz/src/gzwrite.obj file external/libz/src/infback.obj file external/libz/src/inffast.obj file external/libz/src/inflate.obj file external/libz/src/inftrees.obj file external/libz/src/trees.obj file external/libz/src/uncompr.obj file external/libz/src/zutil.obj file external/md4c.obj file external/stb_ds.obj file external/stb_image.obj file external/stb_truetype.obj file src/abstract/charset.obj file src/abstract/directory.obj file src/abstract/dynamic.obj file src/abstract/time.obj file src/backend/gdi.obj file src/color.obj file src/core.obj file src/cursor/arrow.obj file src/cursor/center.obj file src/cursor/cross.obj file src/cursor/default.obj file src/cursor/hand.obj file src/cursor/hidden.obj file src/cursor/text.obj file src/default.obj file src/dialog/colorpicker.obj file src/dialog/directorychooser.obj file src/dialog/filechooser.obj file src/dialog/messagebox.obj file src/draw.obj file src/icon/back.obj file src/icon/clock.obj file src/icon/computer.obj file src/icon/directory.obj file src/icon/down.obj file src/icon/error.obj file src/icon/file.obj file src/icon/forward.obj file src/icon/info.obj file src/icon/left.obj file src/icon/news.obj file src/icon/note.obj file src/icon/right.obj file src/icon/search.obj file src/icon/up.obj file src/icon/warning.obj file src/lowlevel.obj file src/string.obj file src/text/font/boldfont.obj file src/text/font/boldmonottf.obj file src/text/font/boldttf.obj file src/text/font/font.obj file src/text/font/monottf.obj file src/text/font/ttf.obj file src/text/ft2.obj file src/text/gdi.obj file src/text/stbtt.obj file src/text/text.obj file src/truetype.obj file src/unicode.obj file src/widget/box.obj file src/widget/button.obj file src/widget/calendar.obj file src/widget/chart.obj file src/widget/checkbox.obj file src/widget/clock.obj file src/widget/combobox.obj file src/widget/direct3d9.obj file src/widget/document.obj file src/widget/entry.obj file src/widget/frame.obj file src/widget/image.obj file src/widget/label.obj file src/widget/listbox.obj file src/widget/menu.obj file src/widget/numberentry.obj file src/widget/opengl.obj file src/widget/progressbar.obj file src/widget/radiobox.obj file src/widget/scrollbar.obj file src/widget/separator.obj file src/widget/submenu.obj file src/widget/subwindow.obj file src/widget/tab.obj file src/widget/table.obj file src/widget/treeview.obj file src/widget/viewport.obj file src/widget/window.obj library clib3r.lib library opengl32.lib library gdi32.lib library ole32.lib library uuid.lib library user32.lib library advapi32.lib
@ -498,6 +507,8 @@ src/widget/clock.obj: src/widget/clock.c
$(CC) $(MW_CFLAGS) -fo=$@ src/widget/clock.c
src/widget/combobox.obj: src/widget/combobox.c
$(CC) $(MW_CFLAGS) -fo=$@ src/widget/combobox.c
src/widget/direct3d9.obj: src/widget/direct3d9.c
$(CC) $(MW_CFLAGS) -fo=$@ src/widget/direct3d9.c
src/widget/document.obj: src/widget/document.c
$(CC) $(MW_CFLAGS) -fo=$@ src/widget/document.c
src/widget/entry.obj: src/widget/entry.c

8
configure vendored
View file

@ -69,7 +69,8 @@ my %features = (
"wayland" => "enable wayland backend",
"gnustep" => "use gnustep",
"dbus" => "use DBus on supported platform",
"allow-sloppy-focus" => "prevent the x11 backend from using XSetInputFocus to enforce click-to-focus"
"allow-sloppy-focus" => "prevent the x11 backend from using XSetInputFocus to enforce click-to-focus",
"direct3d9" => "(Windows only) build Direct3D9 widget"
);
my @features_keys = (
"1classic-theme", "1stb-image",
@ -78,13 +79,14 @@ my @features_keys = (
"1vulkan", "2vulkan-string-helper",
"1shared", "1static",
"1wayland", "1gnustep",
"1dbus"
"1dbus", "1direct3d9"
);
sub def_platform {
if($target eq "Windows") {
param_set("freetype2", 0);
param_set("stb-truetype", 0);
param_set("direct3d9", 1);
} elsif($target ne "Darwin" and $target ne "ClassicMacOS" and $target ne "Haiku") {
param_set("freetype2", 1);
param_set("stb-truetype", 0);
@ -244,7 +246,7 @@ print(OUT
" clang-format --verbose -i `find tools src include examples \"(\" -name \"*.c\" -or -name \"*.cc\" -or -name \"*.h\" -or -name \"*.m\" \")\" -and -not -name \"*ttf.c\"`\n"
);
print(OUT
" perltidy -b -bext=\"/\" --paren-tightness=2 `find tools pl configure -name \"*.pl\"`\n"
" perltidy -b -bext=\"/\" --paren-tightness=2 `find tools pl -name \"*.pl\"` configure\n"
);
print(OUT "\n");
print(OUT "lib:");

View file

@ -5,3 +5,9 @@ endif()
if(${MW_TRY_VULKAN})
add_subdirectory(vkdemos)
endif()
if(WIN32)
if(${MW_TRY_DIRECT3D9})
add_subdirectory(dxdemos)
endif()
endif()

View file

@ -45,7 +45,6 @@ static void MWAPI tick(MwWidget handle, void* user_data, void* call_data) {
MwGetClipboard(handle, MwCLIPBOARD_MAIN);
cur_text = text2;
MwGetClipboard(handle, MwCLIPBOARD_PRIMARY);
MwForceRender(window);
}
int main() {

View file

@ -44,7 +44,6 @@ int main() {
NULL);
text_listbox = MwVaCreateWidget(MwListBoxClass, "label", box, 25, 150, 750, 700,
MwNtext, "",
MwNacceptsDnD, 1,
NULL);
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);

View file

@ -22,11 +22,12 @@ static void MWAPI resize_window(MwWidget handle, void* user, void* call) {
}
static void MWAPI layout_document(MwWidget handle, void* user, void* call) {
int height = *(int*)call;
MwRect size = *(MwRect*)call;
MwViewportSetSize(viewport, MwGetInteger(document, MwNwidth), height);
MwViewportSetSize(viewport, size.width, size.height);
MwVaApply(document,
MwNheight, height,
MwNwidth, size.width,
MwNheight, size.height,
NULL);
}

View file

@ -0,0 +1,15 @@
file(
GLOB
EXAMPLES_DIRECTX_SOURCES
*.c
)
foreach(PATH IN LISTS EXAMPLES_DIRECTX_SOURCES)
get_filename_component(TARGET ${PATH} NAME_WE)
add_executable(${TARGET} ${PATH})
target_link_libraries(
${TARGET}
PRIVATE
Mw
)
endforeach()

View file

@ -0,0 +1,92 @@
/*
* Adapted from:
* http://www.directxtutorial.com/Lesson.aspx?lessonid=9-4-1
* http://www.directxtutorial.com/Lesson.aspx?lessonid=9-4-4
*/
#include <Mw/Milsko.h>
#include <Mw/Widget/Direct3D9.h>
MwWidget window, d3d9;
LPDIRECT3D9 d3d;
LPDIRECT3DDEVICE9 d3ddev;
LPDIRECT3DVERTEXBUFFER9 v_buffer;
struct CUSTOMVERTEX {
FLOAT x, y, z, rhw; // from the D3DFVF_XYZRHW flag
DWORD color; // from the D3DFVF_DIFFUSE flag
};
#define CUSTOMFVF (D3DFVF_XYZRHW | D3DFVF_DIFFUSE)
static void MWAPI draw(MwWidget handle, void* user, void* client) {
// clear the window to a deep blue
d3ddev->lpVtbl->Clear(d3ddev, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 40, 100), 1.0f, 0);
d3ddev->lpVtbl->BeginScene(d3ddev); // begins the 3D scene
// select which vertex format we are using
d3ddev->lpVtbl->SetFVF(d3ddev, CUSTOMFVF);
// select the vertex buffer to display
d3ddev->lpVtbl->SetStreamSource(d3ddev, 0, v_buffer, 0, sizeof(struct CUSTOMVERTEX));
// copy the vertex buffer to the back buffer
d3ddev->lpVtbl->DrawPrimitive(d3ddev, D3DPT_TRIANGLELIST, 0, 1);
d3ddev->lpVtbl->EndScene(d3ddev); // ends the 3D scene
d3ddev->lpVtbl->Present(d3ddev, NULL, NULL, NULL, NULL); // displays the created frame
}
int main() {
VOID* pVoid;
// create three vertices using the CUSTOMVERTEX struct built earlier
struct CUSTOMVERTEX vertices[] =
{
{
400.0f,
0.0f,
0.5f,
1.0f,
D3DCOLOR_XRGB(0, 0, 255),
},
{
800.0f,
600.0f,
0.5f,
1.0f,
D3DCOLOR_XRGB(0, 255, 0),
},
{
0.0f,
600.0f,
0.5f,
1.0f,
D3DCOLOR_XRGB(255, 0, 0),
},
};
MwLibraryInit();
window = MwCreateWidget(MwWindowClass, NULL, NULL, MwDEFAULT, MwDEFAULT, 1024, 768);
d3d9 = MwCreateWidget(MwDirect3D9Class, NULL, window, (1024 - 800) / 2, (768 - 600) / 2, 800, 600);
d3d = MwDirect3D9GetDirect3D9(d3d9);
d3ddev = MwDirect3D9GetDirect3DDevice9(d3d9);
d3ddev->lpVtbl->CreateVertexBuffer(d3ddev,
3 * sizeof(struct CUSTOMVERTEX),
0,
CUSTOMFVF,
D3DPOOL_MANAGED,
&v_buffer,
NULL);
v_buffer->lpVtbl->Lock(v_buffer, 0, 0, (void**)&pVoid, 0); // lock the vertex buffer
memcpy(pVoid, vertices, sizeof(vertices)); // copy the vertices to the locked buffer
v_buffer->lpVtbl->Unlock(v_buffer); // unlock the vertex buffer
MwAddUserHandler(window, MwNtickHandler, draw, NULL);
MwLoop(window);
}

View file

@ -390,6 +390,13 @@ MWDECL void MWAPI MwFreeWidget(MwWidget handle);
*/
MWDECL void MWAPI MwGetFrame(MwWidget handle, MwRect* rect);
/*!
* @brief Gets the clipping frame of the widget
* @param handle Widget
* @param rect Frame
*/
MWDECL void MWAPI MwGetClipFrame(MwWidget handle, MwRect* rect);
#ifdef _MILSKO
MWDECL void MwForceRender_Internal(MwWidget handle);
MWDECL void MwForceRender2_Internal(MwWidget handle, void* ptr);

View file

@ -220,6 +220,13 @@ MWDECL void MWAPI MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color,
*/
MWDECL void MWAPI MwDrawCircle(MwWidget handle, MwRect* rect, MwLLColor color, MwLLColor background, int filled);
/*!
* @brief Calculate intersect of 2 rectangles
* @param a 1st rectangle
* @param a 2nd rectangle
*/
MWDECL void MwIntersectRect(MwRect* a, const MwRect* b);
/* text.c */
/*!

View file

@ -257,6 +257,14 @@ struct _MwLLWaylandLayerSurface {
struct zwlr_layer_surface_v1* surface;
};
struct _MwLLWaylandSubsurface {
MwLL parent;
struct xdg_surface* xdg_surface;
struct wl_subsurface* subsurface;
struct wl_subcompositor* subcompositor;
};
/* Shared set of anything needed for a shm buffer. */
struct _MwLLWaylandShmBuffer {
struct wl_shm* shm;
@ -271,6 +279,7 @@ struct _MwLLWaylandShmBuffer {
MwU8* buf;
MwU8* buf_back;
MwU64 buf_size;
MwU64 buf_capacity;
int fd;
int fd_back;
MwBool setup;
@ -282,6 +291,7 @@ enum _MwLLWaylandType {
MwLL_WAYLAND_SUBLEVEL,
MwLL_WAYLAND_POPUP,
MwLL_WAYLAND_LAYER_SURFACE,
MwLL_WAYLAND_SUBSURFACE,
};
typedef struct wl_clipboard_device_context {
@ -314,6 +324,8 @@ struct _MwLLWayland {
struct _MwLLWaylandPopup* popup;
/* Pointer for data that's only loaded if the widget is a layer surface */
struct _MwLLWaylandLayerSurface* layer_surface;
/* Pointer for data that's only loaded if the widget is a subsurface */
struct _MwLLWaylandSubsurface* subsurface;
};
enum _MwLLWaylandType type;
@ -427,6 +439,8 @@ struct _MwLLWayland {
MwBool do_cascading_draw;
int cascading_child_num;
cairo_surface_t* snapshot;
MwBool dispatching_resize;
struct _MwLLWaylandShmBuffer framebuffer;
@ -466,6 +480,12 @@ void MwLLWaylandBackbufferDestroy(struct _MwLLWayland* handle);
void MwLLWaylandBufferSetup(struct _MwLLWaylandShmBuffer* buffer, MwU32 width, MwU32 height);
void MwLLWaylandBufferUpdate(MwLL self, struct _MwLLWaylandShmBuffer* buffer);
void MwLLWaylandBufferDestroy(struct _MwLLWaylandShmBuffer* buffer);
/* Resize an already set-up shm buffer pair in place, growing the backing pool with
* wl_shm_pool_resize instead of tearing it down and recreating it from scratch. */
void MwLLWaylandBufferResize(struct _MwLLWaylandShmBuffer* buffer, MwU32 width, MwU32 height);
void MwLLWaylandFramebufferResize(struct _MwLLWayland* wayland);
void MwLLWaylandBackbufferResize(struct _MwLLWayland* wayland);
void MwLLWaylandRegionSetup(MwLL handle);
void MwLLWaylandRegionInvalidate(MwLL handle);
@ -488,12 +508,6 @@ void MwLLWaylandFlush(MwLL handle);
/* recursively dispatch the key event to focused widgets. */
void MwLLRecursiveKeyDispatch(MwLL self, int* k, MwBool down);
/* Standard procedure before event callbacks in Wayland */
#define WAYLAND_EVENT_OP_START(self)
/* Footer for WAYLAND_EVENT_OP_START */
#define WAYLAND_EVENT_OP_END(self)
/* the two decoration manager constructs */
typedef struct zxdg_decoration_manager_v1_context {
struct zxdg_decoration_manager_v1* manager;

View file

@ -58,6 +58,8 @@
#define MwNminute "Iminute"
#define MwNsecond "Isecond"
#define MwNtype "Itype"
#define MwNstrikethrough "Istrikethrough"
#define MwNunderline "Iunderline"
#define MwNtitle "Stitle"
#define MwNtext "Stext"

View file

@ -0,0 +1,59 @@
/*!
* @file Mw/Widget/DirectX.h
* @brief DirectX widget.
* @warning Only avaliable on Windows.
*/
#ifndef __MW_WIDGET_DIRECT3D9_H__
#define __MW_WIDGET_DIRECT3D9_H__
#include <Mw/Core.h>
#include <Mw/MachDep.h>
#include <Mw/TypeDefs.h>
#if !defined(MW_DIRECT3D9_NO_INCLUDE)
/* https://github.com/microsoft/Windows-classic-samples/issues/317 */
#if defined(__MINGW32__) || defined(__MINGW64__)
#undef NTDDI_VERSION
#undef _WIN32_WINNT
#define NTDDI_VERSION 0x07000000
#define _WIN32_WINNT 0x0A00
#endif
#ifndef _WIN32
#error D3D9 widget only avaliable for Win32 backends
#undef MW_DIRECT3D9
#else
#ifdef __WATCOMC__
#include <windows.h>
#endif
#include <d3d9.h>
#endif
#endif
/*!
* @brief D3D9 widget class
*/
MWDECL MwClass MwDirect3D9Class;
#ifdef __cplusplus
extern "C" {
#endif
MwInline LPDIRECT3D9 MwDirect3D9GetDirect3D9(MwWidget handle) {
LPDIRECT3D9 out = NULL;
MwVaWidgetExecute(handle, "mwDirect3D9GetDirect3D9", &out, NULL);
return out;
};
MwInline LPDIRECT3DDEVICE9 MwDirect3D9GetDirect3DDevice9(MwWidget handle) {
LPDIRECT3DDEVICE9 out = NULL;
MwVaWidgetExecute(handle, "mwDirect3D9GetDirect3DDevice9", &out);
return out;
};
#ifdef __cplusplus
}
#endif
#endif

View file

@ -204,7 +204,7 @@
<string />
</handler>
<handler name="layout">
<integer pointer="yes" />
<struct defname="MwRect" pointer="yes" />
</handler>
</handlers>
<enumerations>
@ -1070,10 +1070,20 @@
<return>
<pointer />
</return>
<arguments>
<integer enumname="MwVulkanField" name="field" />
<integer pointer="yes" name="output" />
</arguments>
</function>
</functions>
</widget>
<widget name="Direct3D9">
<functions>
<function name="GetDirect3D9">
<return>
<pointer />
</return>
</function>
<function name="GetDirect3DDevice9">
<return>
<pointer />
</return>
</function>
</functions>
</widget>

View file

@ -178,6 +178,7 @@ new_object("src/widget/window.c");
new_object("src/widget/opengl.c");
new_object("src/widget/vulkan.c");
new_object("src/widget/direct3d9.c");
if (param_get("opengl")) {
add_cflags("-DMW_OPENGL");
@ -185,6 +186,9 @@ if (param_get("opengl")) {
if (param_get("vulkan")) {
add_cflags("-DMW_VULKAN");
}
if (param_get("direct3d9")) {
add_cflags("-DMW_DIRECT3D9");
}
new_object("src/dialog/*.c");
@ -230,4 +234,8 @@ if (param_get("vulkan")) {
new_example("examples/vkdemos/vulkan");
}
if (param_get("direct3d9")) {
new_example("examples/dxdemos/direct3d9");
}
1;

325
resource/FindDirectX.cmake Normal file
View file

@ -0,0 +1,325 @@
# - try to find part of DirectX SDK
#
# Cache Variables: (probably not for direct use in your scripts)
# DIRECTX_INCLUDE_DIR
#
# Variables you should use in your CMakeLists.txt:
# DIRECTX_DXGUID_LIBRARY - deprecated, see below
# DIRECTX_DXERR_LIBRARY - deprecated, see http://blogs.msdn.com/b/chuckw/archive/2012/04/24/where-s-dxerr-lib.aspx
# DIRECTX_DINPUT_LIBRARY
# DIRECTX_DINPUT_INCLUDE_DIR
# DIRECTX_D3D9_LIBRARY
# DIRECTX_D3DXOF_LIBRARY
# DIRECTX_D3DX9_LIBRARIES
# DIRECTX_INCLUDE_DIRS
# DIRECTX_FOUND - if this is not true, do not attempt to use this library
#
# Defines these macros:
# find_directx_include - wrapper for find_path that provides PATHS, HINTS, and PATH_SUFFIXES.
# find_directx_library - wrapper for find_library that provides PATHS, HINTS, and PATH_SUFFIXES.
# Requires these CMake modules:
# FindPackageHandleStandardArgs (known included with CMake >=2.6.2)
# SelectLibraryConfigurations
#
# Original Author:
# 2012 Rylie Pavlik <rylie@ryliepavlik.com>
# https://ryliepavlik.com/
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright 2012, Iowa State University
#
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
# SPDX-License-Identifier: BSL-1.0
set(DIRECTX_ROOT_DIR
"${DIRECTX_ROOT_DIR}"
CACHE
PATH
"Root directory to search for DirectX")
if(MSVC)
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" _PROG_FILES)
set(_PF86 "ProgramFiles(x86)")
file(TO_CMAKE_PATH "$ENV{${_PF86}}" _PROG_FILES_X86)
if(_PROG_FILES_X86)
set(_PROG_FILES "${_PROG_FILES_X86}")
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_dx_lib_suffixes lib/x64 lib)
else()
set(_dx_lib_suffixes lib/x86 lib)
endif()
set(DXSDK_DIRS)
set(_dx_quiet)
if(DirectX_FIND_QUIETLY)
set(_dx_quiet QUIET)
endif()
find_package(WindowsSDK ${_dx_quiet})
if(WINDOWSSDK_FOUND)
foreach(_dir ${WINDOWSSDK_DIRS})
get_windowssdk_include_dirs(${_dir} _include_dirs)
if(_include_dirs)
list(APPEND DXSDK_DIRS ${_include_dirs})
endif()
endforeach()
endif()
macro(_append_dxsdk_in_inclusive_range _low _high)
if((NOT MSVC_VERSION LESS ${_low}) AND (NOT MSVC_VERSION GREATER ${_high}))
list(APPEND DXSDK_DIRS ${ARGN})
endif()
endmacro()
_append_dxsdk_in_inclusive_range(1500 1600 "${_PROG_FILES}/Microsoft DirectX SDK (June 2010)")
_append_dxsdk_in_inclusive_range(1400 1600
"${_PROG_FILES}/Microsoft DirectX SDK (February 2010)"
"${_PROG_FILES}/Microsoft DirectX SDK (August 2009)"
"${_PROG_FILES}/Microsoft DirectX SDK (March 2009)"
"${_PROG_FILES}/Microsoft DirectX SDK (November 2008)"
"${_PROG_FILES}/Microsoft DirectX SDK (August 2008)"
"${_PROG_FILES}/Microsoft DirectX SDK (June 2008)"
"${_PROG_FILES}/Microsoft DirectX SDK (March 2008)")
_append_dxsdk_in_inclusive_range(1310 1500
"${_PROG_FILES}/Microsoft DirectX SDK (November 2007)"
"${_PROG_FILES}/Microsoft DirectX SDK (August 2007)"
"${_PROG_FILES}/Microsoft DirectX SDK (June 2007)"
"${_PROG_FILES}/Microsoft DirectX SDK (April 2007)"
"${_PROG_FILES}/Microsoft DirectX SDK (February 2007)"
"${_PROG_FILES}/Microsoft DirectX SDK (December 2006)"
"${_PROG_FILES}/Microsoft DirectX SDK (October 2006)"
"${_PROG_FILES}/Microsoft DirectX SDK (August 2006)"
"${_PROG_FILES}/Microsoft DirectX SDK (June 2006)"
"${_PROG_FILES}/Microsoft DirectX SDK (April 2006)"
"${_PROG_FILES}/Microsoft DirectX SDK (February 2006)")
file(TO_CMAKE_PATH "$ENV{DXSDK_DIR}" ENV_DXSDK_DIR)
if(ENV_DXSDK_DIR)
list(APPEND DXSDK_DIRS ${ENV_DXSDK_DIR})
endif()
else()
set(_dx_lib_suffixes lib)
set(DXSDK_DIRS /mingw)
endif()
find_path(DIRECTX_INCLUDE_DIR
NAMES
dxdiag.h
dinput.h
dxerr8.h
PATHS
${DXSDK_DIRS}
HINTS
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
include)
find_path(DIRECTX_DINPUT_INCLUDE_DIR
NAMES
dinput.h
PATHS
${DXSDK_DIRS}
HINTS
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
include)
set(DXLIB_HINTS)
if(WINDOWSSDK_FOUND AND DIRECTX_INCLUDE_DIR)
get_windowssdk_from_component("${DIRECTX_INCLUDE_DIR}" _winsdk)
if(_winsdk)
get_windowssdk_library_dirs("${_winsdk}" _libdirs)
if(_libdirs)
list(APPEND DXLIB_HINTS ${_libdirs})
endif()
endif()
endif()
if(WINDOWSSDK_FOUND AND DIRECTX_DINPUT_INCLUDE_DIR)
get_windowssdk_from_component("${DIRECTX_DINPUT_INCLUDE_DIR}" _winsdk)
if(_winsdk)
get_windowssdk_library_dirs("${_winsdk}" _includes)
if(_includes)
list(APPEND DXLIB_HINTS ${_includes})
endif()
endif()
endif()
find_library(DIRECTX_DXGUID_LIBRARY
NAMES
dxguid
PATHS
${DXLIB_HINTS}
${DXSDK_DIRS}
HINTS
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
if(DIRECTX_DXGUID_LIBRARY)
get_filename_component(_dxsdk_lib_dir ${DIRECTX_DXGUID_LIBRARY} PATH)
list(APPEND DXLIB_HINTS "${_dxsdk_lib_dir}")
endif()
find_library(DIRECTX_DINPUT_LIBRARY
NAMES
dinput8
dinput
PATHS
${DXSDK_DIRS}
HINTS
${DXLIB_HINTS}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
find_library(DIRECTX_DXERR_LIBRARY
NAMES
dxerr
dxerr9
dxerr8
PATHS
${DXSDK_DIRS}
HINTS
${DXLIB_HINTS}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
find_library(DIRECTX_D3D9_LIBRARY
NAMES
d3d9
PATHS
${DXSDK_DIRS}
HINTS
${DXLIB_HINTS}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
find_library(DIRECTX_D3DXOF_LIBRARY
NAMES
d3dxof
PATHS
${DXSDK_DIRS}
HINTS
${DXLIB_HINTS}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
find_library(DIRECTX_D3DX9_LIBRARY_RELEASE
NAMES
d3dx9
PATHS
${DXSDK_DIRS}
HINTS
${DXLIB_HINTS}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
find_library(DIRECTX_D3DX9_LIBRARY_DEBUG
NAMES
d3dx9d
PATHS
${DXSDK_DIRS}
HINTS
${DXLIB_HINTS}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
find_library(DIRECTX_XINPUT_LIBRARY
NAMES
Xinput9_1_0
Xinput
PATHS
${DXSDK_DIRS}
HINTS
${DXLIB_HINTS}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
include(SelectLibraryConfigurations)
select_library_configurations(DIRECTX_D3DX9)
set(DIRECTX_EXTRA_CHECK)
if(DIRECTX_INCLUDE_DIR)
if(MSVC80)
set(DXSDK_DEPRECATION_BUILD 1962)
endif()
if(DXSDK_DEPRECATION_BUILD)
include(CheckCSourceCompiles)
set(_dinput_old_includes ${CMAKE_REQUIRED_INCLUDES})
set(CMAKE_REQUIRED_INCLUDES "${DIRECTX_INCLUDE_DIR}")
check_c_source_compiles("
#include <dxsdkver.h>
#if _DXSDK_BUILD_MAJOR >= ${DXSDK_DEPRECATION_BUILD}
#error
#else
int main(int argc, char * argv[]) {
return 0;
}
#endif
"
DIRECTX_SDK_SUPPORTS_COMPILER)
set(DIRECTX_EXTRA_CHECK DIRECTX_SDK_SUPPORTS_COMPILER)
set(CMAKE_REQUIRED_INCLUDES "${_dinput_old_includes}")
else()
# Until proven otherwise.
set(DIRECTX_SDK_SUPPORTS_COMPILER TRUE)
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DirectX
DEFAULT_MSG
DIRECTX_DXGUID_LIBRARY
DIRECTX_DINPUT_LIBRARY
DIRECTX_INCLUDE_DIR
${DIRECTX_EXTRA_CHECK})
if(DIRECTX_FOUND)
set(DIRECTX_LIBRARIES
"${DIRECTX_DXGUID_LIBRARY}"
"${DIRECTX_DINPUT_LIBRARY}")
set(DIRECTX_INCLUDE_DIRS "${DIRECTX_INCLUDE_DIR}")
mark_as_advanced(DIRECTX_ROOT_DIR)
endif()
macro(find_directx_library)
find_library(${ARGN}
PATHS
${DXSDK_DIRS}
HINTS
${DXLIB_HINTS}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
${_dx_lib_suffixes})
endmacro()
macro(find_directx_include)
find_path(${ARGN}
PATHS
${DXSDK_DIRS}
HINTS
${DIRECTX_INCLUDE_DIR}
"${DIRECTX_ROOT_DIR}"
PATH_SUFFIXES
include)
endmacro()
mark_as_advanced(DIRECTX_DINPUT_LIBRARY
DIRECTX_DXGUID_LIBRARY
DIRECTX_DXERR_LIBRARY
DIRECTX_D3D9_LIBRARY
DIRECTX_D3DXOF_LIBRARY
DIRECTX_D3DX9_LIBRARY_RELEASE
DIRECTX_D3DX9_LIBRARY_DEBUG
DIRECTX_INCLUDE_DIR)

View file

@ -7,7 +7,7 @@ void MwLLWaylandFramebufferSetup(struct _MwLLWayland* wayland) {
MwLLCairoFrontSetup(&wayland->cairo, wayland->framebuffer.buf_back, wayland->ww, wayland->wh);
memset(wayland->framebuffer.buf_back, 0, wayland->framebuffer.buf_size);
memset(wayland->framebuffer.buf_back, 255, wayland->framebuffer.buf_size);
if(wayland->configured)
wl_surface_attach(wayland->framebuffer.surface, wayland->framebuffer.shm_buffer, 0, 0);
if(wayland->framebuffer.fifo)
@ -38,7 +38,7 @@ void MwLLWaylandBackbufferSetup(struct _MwLLWayland* wayland) {
MwLLCairoBackSetup(&wayland->cairo, wayland->backbuffer.buf_back, w, h);
memset(wayland->backbuffer.buf_back, 255, wayland->backbuffer.buf_size);
memset(wayland->backbuffer.buf_back, 0, wayland->backbuffer.buf_size);
if(wayland->configured)
wl_surface_attach(wayland->backbuffer.surface, wayland->backbuffer.shm_buffer, 0, 0);
// if(wayland->framebuffer.fifo)
@ -90,6 +90,8 @@ void MwLLWaylandBufferSetup(struct _MwLLWaylandShmBuffer* buffer, MwU32 width, M
buffer->buf = mmap(NULL, buffer->buf_size, PROT_WRITE, MAP_SHARED, buffer->fd, 0);
buffer->buf_back = mmap(NULL, buffer->buf_size, PROT_WRITE, MAP_SHARED, buffer->fd_back, 0);
buffer->buf_capacity = buffer->buf_size;
fsync(buffer->fd);
fsync(buffer->fd_back);
@ -108,8 +110,8 @@ void MwLLWaylandBufferDestroy(struct _MwLLWaylandShmBuffer* buffer) {
if(!buffer->setup) {
return;
}
if(buffer->buf) munmap(buffer->buf, buffer->buf_size);
if(buffer->buf_back) munmap(buffer->buf_back, buffer->buf_size);
if(buffer->buf) munmap(buffer->buf, buffer->buf_capacity);
if(buffer->buf_back) munmap(buffer->buf_back, buffer->buf_capacity);
if(buffer->shm_buffer) wl_buffer_destroy(buffer->shm_buffer);
if(buffer->shm_buffer_back) wl_buffer_destroy(buffer->shm_buffer_back);
if(buffer->shm_pool) wl_shm_pool_destroy(buffer->shm_pool);
@ -119,11 +121,61 @@ void MwLLWaylandBufferDestroy(struct _MwLLWaylandShmBuffer* buffer) {
buffer->setup = MwFALSE;
}
void MwLLWaylandBufferResize(struct _MwLLWaylandShmBuffer* buffer, MwU32 width, MwU32 height) {
MwLLWaylandBufferDestroy(buffer);
MwLLWaylandBufferSetup(buffer, width, height);
memset(buffer->buf_back, 0, buffer->buf_size);
memset(buffer->buf, 0, buffer->buf_size);
}
void MwLLWaylandFramebufferResize(struct _MwLLWayland* wayland) {
MwLLWaylandBufferResize(&wayland->framebuffer, wayland->ww, wayland->wh);
MwLLCairoFrontDestroy(&wayland->cairo);
MwLLCairoFrontSetup(&wayland->cairo, wayland->framebuffer.buf_back, wayland->ww, wayland->wh);
if(wayland->configured)
wl_surface_attach(wayland->framebuffer.surface, wayland->framebuffer.shm_buffer, 0, 0);
if(wayland->framebuffer.fifo)
wp_fifo_v1_set_barrier(wayland->framebuffer.fifo);
wl_surface_commit(wayland->framebuffer.surface);
MwLLWaylandHangUntilConfigured((MwLL)wayland);
MwLLWaylandBufferUpdate((MwLL)wayland, &wayland->framebuffer);
}
void MwLLWaylandBackbufferResize(struct _MwLLWayland* wayland) {
MwU32 w = wayland->ww;
MwU32 h = wayland->wh;
if(wayland->type != MwLL_WAYLAND_TOPLEVEL) {
return;
}
if(!wayland->has_decorations && wayland->do_csd) {
w += (CSD_BORDER_FRAME_LEFT + CSD_BORDER_FRAME_RIGHT);
h += (CSD_BORDER_FRAME_TOP + CSD_BORDER_FRAME_BOTTOM);
}
MwLLWaylandBufferResize(&wayland->backbuffer, w, h);
MwLLCairoBackDestroy(&wayland->cairo);
MwLLCairoBackSetup(&wayland->cairo, wayland->backbuffer.buf_back, w, h);
if(wayland->configured)
wl_surface_attach(wayland->backbuffer.surface, wayland->backbuffer.shm_buffer, 0, 0);
wl_surface_commit(wayland->backbuffer.surface);
MwLLWaylandHangUntilConfigured((MwLL)wayland);
MwLLWaylandBufferUpdate((MwLL)wayland, &wayland->backbuffer);
}
void MwLLWaylandBufferUpdate(MwLL self, struct _MwLLWaylandShmBuffer* buffer) {
if(self->wayland.configured) {
memcpy(buffer->buf, buffer->buf_back, buffer->buf_size);
if(buffer->surface) {
// Yes this is needed every time, it's how we fix weston.
// it's also how we fix comboboxes.
if(self->wayland.configured) {
wl_surface_attach(buffer->surface, buffer->shm_buffer, 0, 0);
}

View file

@ -19,7 +19,7 @@ static void setup_zwp_clipboard(MwLL self, struct wl_seat* wl_seat);
static void destroy_clipboard(MwLL self, struct wl_seat* wl_seat);
static void destroy_zwp_clipboard(MwLL self, struct wl_seat* wl_seat);
static bool hit_detect(MwLL child, MwLL* _topmost_parent, MwPoint* _point, MwPoint* _relative_mouse_pos, MwPoint* _absolute_pos);
static MwBool hit_detect(MwLL child, MwLL* _topmost_parent, MwPoint* _point, MwPoint* _relative_mouse_pos, MwPoint* _absolute_pos);
/* Recursively dispatch a key event to a widget and its children */
static void recursive_dispatch_key(MwLL handle, int* k) {
@ -72,8 +72,6 @@ static void new_protocol(void* data, struct wl_registry* registry,
(void)version;
(void)registry;
WAYLAND_EVENT_OP_START(self);
wayland_protocol_callback_table_t* cb = shget(self->wayland.wl_protocol_setup_map, interface);
if(cb != NULL) {
shput(self->wayland.wl_protocol_map, interface, cb->setup(name, data, version));
@ -83,8 +81,6 @@ static void new_protocol(void* data, struct wl_registry* registry,
} else {
// printf("unknown interface %s\n", interface);
}
WAYLAND_EVENT_OP_END(self);
};
/* `wl_registry.global_remove` callback */
@ -154,11 +150,7 @@ static void wl_data_device_enter(void* data,
(void)y;
(void)id;
WAYLAND_EVENT_OP_START(self);
self->ll->wayland.clipboard_serial = serial;
WAYLAND_EVENT_OP_END(self);
};
static void wl_data_device_leave(void* data,
struct wl_data_device* wl_data_device) {
@ -398,7 +390,6 @@ static void wl_data_source_listener_target(void* data,
(void)data;
(void)wl_data_source;
(void)mime_type;
printf("test\n");
};
static void wl_data_source_listener_send(void* data,
struct wl_data_source* wl_data_source,
@ -408,12 +399,10 @@ static void wl_data_source_listener_send(void* data,
(void)wl_data_source;
(void)mime_type;
WAYLAND_EVENT_OP_START(self);
if(self->wayland.clipboard_buffer != NULL) {
write(fd, self->wayland.clipboard_buffer, strlen(self->wayland.clipboard_buffer));
close(fd);
}
WAYLAND_EVENT_OP_END(self);
};
static void wl_data_source_listener_cancelled(void* data,
struct wl_data_source* wl_data_source);
@ -428,8 +417,6 @@ static void wl_data_source_listener_cancelled(void* data,
struct wl_data_source* wl_data_source) {
MwLL self = data;
WAYLAND_EVENT_OP_START(self);
if(wl_data_source)
wl_data_source_destroy(wl_data_source);
@ -443,8 +430,6 @@ static void wl_data_source_listener_cancelled(void* data,
wl_data_source_offer(self->wayland.clipboard_source.wl, "text/uri-list");
wl_data_source_add_listener(self->wayland.clipboard_source.wl, &wl_data_source_listener, self);
WAYLAND_EVENT_OP_END(self);
};
static void zwp_primary_selection_source_v1_send(void* data,
@ -455,22 +440,16 @@ static void zwp_primary_selection_source_v1_send(void* data,
(void)wl_data_source;
(void)mime_type;
WAYLAND_EVENT_OP_START(self);
if(self->wayland.clipboard_buffer != NULL) {
write(fd, self->wayland.clipboard_buffer, strlen(self->wayland.clipboard_buffer));
close(fd);
}
WAYLAND_EVENT_OP_END(self);
};
static void zwp_primary_selection_source_v1_cancelled(void* data,
struct zwp_primary_selection_source_v1* wl_data_source) {
MwLL self = data;
(void)wl_data_source;
WAYLAND_EVENT_OP_START(self);
zwp_primary_selection_source_v1_destroy(self->wayland.clipboard_source.zwp);
self->wayland.clipboard_source.zwp = zwp_primary_selection_device_manager_v1_create_source(self->wayland.clipboard_manager.zwp);
@ -480,8 +459,6 @@ static void zwp_primary_selection_source_v1_cancelled(void* data,
zwp_primary_selection_source_v1_offer(self->wayland.clipboard_source.zwp, "TEXT");
zwp_primary_selection_source_v1_offer(self->wayland.clipboard_source.zwp, "STRING");
zwp_primary_selection_source_v1_offer(self->wayland.clipboard_source.zwp, "UTF8_STRING");
WAYLAND_EVENT_OP_END(self);
};
struct zwp_primary_selection_source_v1_listener zwp_primary_selection_source_v1_listener = {
@ -578,7 +555,6 @@ static void pointer_enter(void* data, struct wl_pointer* wl_pointer, MwU32 seria
(void)surface_y;
(void)wl_pointer;
WAYLAND_EVENT_OP_START(self);
while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent;
if(self->wayland.framebuffer.surface == surface) {
@ -591,19 +567,18 @@ static void pointer_enter(void* data, struct wl_pointer* wl_pointer, MwU32 seria
if(self->wayland.backbuffer.surface == surface) {
curSurface = surface;
}
WAYLAND_EVENT_OP_END(self);
self->wayland.cur_mouse_pos.x = wl_fixed_to_int(surface_x);
self->wayland.cur_mouse_pos.y = wl_fixed_to_int(surface_y);
};
/* `wl_pointer.leave` callback */
static void pointer_leave(void* data, struct wl_pointer* wl_pointer, MwU32 serial,
struct wl_surface* surface) {
MwLL self = data;
(void)data;
(void)wl_pointer;
(void)serial;
(void)surface;
WAYLAND_EVENT_OP_START(self);
curSurface = NULL;
WAYLAND_EVENT_OP_END(self);
};
static void xdg_borderless_step_mdown(MwLL self, MwMouse p, MwU32 serial) {
@ -673,15 +648,11 @@ static void relative_pointer_motion(void* data,
(void)dx;
(void)dy;
WAYLAND_EVENT_OP_START(self);
p.point.x = wl_fixed_to_int(dxUnaccel);
p.point.y = wl_fixed_to_int(dyUnaccel);
recursive_dispatch_move(self, &p);
if(self->wayland.locked_pointer) zwp_locked_pointer_v1_set_cursor_position_hint(self->wayland.locked_pointer, 0, CSD_BORDER_FRAME_TOP);
WAYLAND_EVENT_OP_END(self);
}
struct zwp_relative_pointer_v1_listener MwLLWaylandRelativePointerListener =
@ -713,7 +684,6 @@ static void pointer_motion(void* data, struct wl_pointer* wl_pointer, MwU32 time
(void)time;
(void)wl_pointer;
WAYLAND_EVENT_OP_START(self);
while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent;
currentlyHeldWidgets = topmost_parent->wayland.currentlyHeldWidgets;
@ -722,9 +692,9 @@ static void pointer_motion(void* data, struct wl_pointer* wl_pointer, MwU32 time
inArea |= self->wayland.framebuffer.surface == curSurface;
}
// if(self->wayland.backbuffer.surface) {
// inArea |= self->wayland.backbuffer.surface == curSurface;
// }
if(self->wayland.backbuffer.surface) {
inArea |= self->wayland.backbuffer.surface == curSurface;
}
self->wayland.cur_mouse_pos.x = wl_fixed_to_int(surface_x);
self->wayland.cur_mouse_pos.y = wl_fixed_to_int(surface_y);
@ -749,8 +719,6 @@ static void pointer_motion(void* data, struct wl_pointer* wl_pointer, MwU32 time
if(self->wayland.backbuffer.surface) {
wl_pointer_set_cursor(self->wayland.pointer, self->wayland.pointer_serial, self->wayland.cursor.surface, 0, 0);
}
WAYLAND_EVENT_OP_END(self);
};
static void recursive_dispatch_mouse_down(MwLL handle, MwMouse* p) {
@ -780,7 +748,7 @@ static void recursive_dispatch_mouse_up(MwLL handle, MwMouse* p) {
}
};
static bool hit_detect(MwLL child, MwLL* _topmost_parent, MwPoint* _point, MwPoint* _relative_mouse_pos, MwPoint* _absolute_pos) {
static MwBool hit_detect(MwLL child, MwLL* _topmost_parent, MwPoint* _point, MwPoint* _relative_mouse_pos, MwPoint* _absolute_pos) {
MwLL topmost_parent = child;
MwPoint point;
MwPoint relative_mouse_pos;
@ -791,10 +759,15 @@ static bool hit_detect(MwLL child, MwLL* _topmost_parent, MwPoint* _point, MwPoi
while(topmost_parent->wayland.parent) {
topmost_parent = topmost_parent->wayland.parent;
if(topmost_parent) {
/* if the topmost parent is a popup/subwindow then its x/y is irrelevant to us. */
if(topmost_parent->wayland.type != MwLL_WAYLAND_POPUP && topmost_parent->wayland.type != MwLL_WAYLAND_TOPLEVEL) {
if(topmost_parent->wayland.x > 0)
absolute_pos.x += topmost_parent->wayland.x;
if(topmost_parent->wayland.y > 0)
absolute_pos.y += topmost_parent->wayland.y;
}
}
}
point = topmost_parent->wayland.cur_mouse_pos;
@ -871,8 +844,6 @@ static void pointer_button(void* data, struct wl_pointer* wl_pointer, MwU32 seri
(void)serial;
(void)time;
WAYLAND_EVENT_OP_START(self);
if(self->wayland.type != MwLL_WAYLAND_POPUP) {
while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent;
}
@ -883,7 +854,6 @@ static void pointer_button(void* data, struct wl_pointer* wl_pointer, MwU32 seri
inArea |= self->wayland.framebuffer.surface == curSurface;
}
if(inArea) {
switch(button) {
case BTN_LEFT:
p.button = MwMOUSE_LEFT;
@ -895,11 +865,13 @@ static void pointer_button(void* data, struct wl_pointer* wl_pointer, MwU32 seri
p.button = MwMOUSE_RIGHT;
break;
}
self->wayland.held_down = state == WL_POINTER_BUTTON_STATE_PRESSED;
if(inArea) {
self->wayland.held_down = state == WL_POINTER_BUTTON_STATE_PRESSED;
arrsetlen(self->wayland.currentlyHeldWidgets, 0);
mouse_dispatch(self, p, state);
}
if(self->wayland.backbuffer.surface) {
if(!self->wayland.has_decorations && self->wayland.do_csd) {
if(state != WL_POINTER_BUTTON_STATE_RELEASED)
@ -910,8 +882,6 @@ static void pointer_button(void* data, struct wl_pointer* wl_pointer, MwU32 seri
}
MwLLForceRender(self);
WAYLAND_EVENT_OP_END(self);
};
/* `wl_pointer.axis` callback */
@ -974,13 +944,9 @@ static void keyboard_enter(void* data,
(void)surface;
(void)keys;
WAYLAND_EVENT_OP_START(self);
self->wayland.keyboard_serial = serial;
MwLLDispatch(self, focus_in, NULL);
WAYLAND_EVENT_OP_END(self);
};
/* `wl_keyboard.leave` callback */
@ -993,11 +959,7 @@ static void keyboard_leave(void* data,
(void)serial;
(void)surface;
WAYLAND_EVENT_OP_START(self);
MwLLDispatch(self, focus_out, NULL);
WAYLAND_EVENT_OP_END(self);
};
void MwLLRecursiveKeyDispatch(MwLL self, int* k, MwBool down) {
@ -1043,8 +1005,6 @@ static void keyboard_key(void* data,
while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent;
WAYLAND_EVENT_OP_START(self);
if(self->wayland.framebuffer.surface) {
inArea |= self->wayland.framebuffer.surface == curSurface;
}
@ -1062,7 +1022,7 @@ static void keyboard_key(void* data,
int i;
if(!self->wayland.xkb_keymap) {
WAYLAND_EVENT_OP_END(self);
return;
}
@ -1077,7 +1037,7 @@ static void keyboard_key(void* data,
}
syms_num = xkb_keymap_key_get_syms_by_level(self->wayland.xkb_keymap, keycode, layout, level, &syms_out);
if(syms_out == NULL) {
WAYLAND_EVENT_OP_END(self);
return;
}
@ -1151,8 +1111,6 @@ static void keyboard_key(void* data,
if(!MwWaylandVulkan) {
MwLLDispatch(self, draw, NULL);
}
WAYLAND_EVENT_OP_END(self);
};
/* `wl_keyboard.modifiers` callback */
@ -1169,13 +1127,9 @@ static void keyboard_modifiers(void* data,
(void)group;
(void)mods_latched;
WAYLAND_EVENT_OP_START(self);
self->wayland.mod_state = 0;
self->wayland.mod_state |= mods_depressed;
self->wayland.mod_state |= mods_locked;
WAYLAND_EVENT_OP_END(self);
};
static void setup_zwp_clipboard(MwLL self, struct wl_seat* wl_seat) {
@ -1246,8 +1200,6 @@ static void wl_seat_capabilities(void* data, struct wl_seat* wl_seat,
MwU32 capabilities) {
MwLL self = data;
WAYLAND_EVENT_OP_START(self);
/* Always remember the seat itself, regardless of which capabilities it has - this is
* both what setup_clipboard()/setup_zwp_clipboard() below use, and what lets
* wl_seat_interface_destroy() release it later even on a keyboard-only seat. */
@ -1261,7 +1213,6 @@ static void wl_seat_capabilities(void* data, struct wl_seat* wl_seat,
self->wayland.pointer = wl_seat_get_pointer(wl_seat);
wl_pointer_add_listener(self->wayland.pointer, &pointer_listener, data);
}
WAYLAND_EVENT_OP_END(self);
/* Only hooked up if this seat actually has a pointer: wl_data_device.get_data_device()
* requires a non-null seat, and pointer_seat is only ever null before the first
@ -1399,6 +1350,8 @@ static wayland_protocol_t* wl_subcompositor_setup(MwU32 name, struct _MwLLWaylan
(void)version;
if(wayland->type == MwLL_WAYLAND_TOPLEVEL) {
wayland->toplevel->scompositor = wl_registry_bind(wayland->registry, name, &wl_subcompositor_interface, 1);
} else if(wayland->type == MwLL_WAYLAND_SUBSURFACE) {
wayland->subsurface->subcompositor = wl_registry_bind(wayland->registry, name, &wl_subcompositor_interface, 1);
}
return NULL;
@ -1409,6 +1362,9 @@ static void wl_subcompositor_interface_destroy(struct _MwLLWayland* wayland, way
if(wayland->type == MwLL_WAYLAND_TOPLEVEL) {
wl_subcompositor_destroy(wayland->toplevel->scompositor);
}
if(wayland->type == MwLL_WAYLAND_SUBSURFACE) {
wl_subcompositor_destroy(wayland->subsurface->subcompositor);
}
}
/* xdg_wm_base setup function */
@ -1549,19 +1505,11 @@ void MwLLWaylandSetupCallbacks(struct _MwLLWayland* wayland) {
WL_INTERFACE(zwp_relative_pointer_manager_v1);
WL_INTERFACE(xdg_wm_base);
WL_INTERFACE(zwlr_layer_shell_v1); /* Only used for layer surface, but we use it always if it's turned into a tool window */
WL_INTERFACE(wl_subcompositor);
if(wayland->type == MwLL_WAYLAND_TOPLEVEL) {
WL_INTERFACE(zxdg_decoration_manager_v1);
WL_INTERFACE(xdg_toplevel_icon_manager_v1);
WL_INTERFACE(wl_subcompositor);
WL_INTERFACE(wl_seat);
WL_INTERFACE(wp_fifo_manager_v1);
} else if(wayland->type == MwLL_WAYLAND_POPUP) {
WL_INTERFACE(wl_seat);
} else if(wayland->type == MwLL_WAYLAND_LAYER_SURFACE) {
WL_INTERFACE(wl_subcompositor);
WL_INTERFACE(wl_seat);
} else {
WL_INTERFACE(wl_subcompositor);
}
#undef WL_INTERFACE
}

View file

@ -173,10 +173,7 @@ static void xdg_toplevel_configure(void* data,
if(self->wayland.resizing == 0) {
xdg_surface_set_window_geometry(self->wayland.toplevel->xdg_surface, 0, 0, self->wayland.ww, self->wayland.wh);
MwLLWaylandBackbufferDestroy(&self->wayland);
MwLLWaylandBackbufferSetup(&self->wayland);
MwLLWaylandFramebufferDestroy(&self->wayland);
MwLLWaylandFramebufferSetup(&self->wayland);
MwLLWaylandFramebufferResize(&self->wayland);
MwLLWaylandRegionSetup(self);
MwLLDispatch(self, resize, NULL);
@ -196,9 +193,8 @@ static void xdg_toplevel_close(
void* data, struct xdg_toplevel* xdg_toplevel) {
MwLL self = data;
(void)xdg_toplevel;
WAYLAND_EVENT_OP_START(self);
MwLLDispatch(self, close, NULL);
WAYLAND_EVENT_OP_END(self);
};
/* `xdg_surface.configure` callback */
@ -370,6 +366,8 @@ static void setup_sublevel(MwLL parent, MwLL r, int x, int y) {
r->wayland.sublevel->xdg_surface = parent->wayland.toplevel->xdg_surface;
} else if(parent->wayland.type == MwLL_WAYLAND_SUBLEVEL) {
r->wayland.sublevel->xdg_surface = parent->wayland.sublevel->xdg_surface;
} else if(parent->wayland.type == MwLL_WAYLAND_SUBSURFACE) {
r->wayland.sublevel->xdg_surface = parent->wayland.subsurface->xdg_surface;
} else if(parent->wayland.type == MwLL_WAYLAND_POPUP) {
r->wayland.sublevel->xdg_surface = parent->wayland.popup->xdg_surface;
}
@ -400,6 +398,66 @@ static void destroy_sublevel(MwLL r) {
r->wayland.configured = MwFALSE;
}
/* Subsurface setup function */
static void setup_subsurface(MwLL parent, MwLL r, int x, int y) {
struct wl_compositor* compositor = parent->wayland.compositor;
struct wl_surface* parent_surface = parent->wayland.framebuffer.surface;
r->wayland.subsurface = malloc(sizeof(struct _MwLLWaylandSubsurface));
r->wayland.subsurface->parent = parent;
r->wayland.type = MwLL_WAYLAND_SUBSURFACE;
r->wayland.display = parent->wayland.display;
MwLLWaylandSetupCallbacks(&r->wayland);
r->wayland.registry = wl_display_get_registry(parent->wayland.display);
r->wayland.display = parent->wayland.display;
if(parent->wayland.type == MwLL_WAYLAND_TOPLEVEL) {
r->wayland.subsurface->xdg_surface = parent->wayland.toplevel->xdg_surface;
} else {
r->wayland.subsurface->xdg_surface = parent->wayland.subsurface->xdg_surface;
}
wl_registry_add_listener(r->wayland.registry, &r->wayland.registry_listener, r);
if(wl_display_roundtrip(r->wayland.display) == -1) {
printf("roundtrip failed: %d\n", wl_display_get_error(r->wayland.display));
raise(SIGTRAP);
return;
}
r->wayland.framebuffer.surface = wl_compositor_create_surface(compositor);
r->wayland.subsurface->subsurface = wl_subcompositor_get_subsurface(r->wayland.subsurface->subcompositor, r->wayland.framebuffer.surface, parent_surface);
wl_subsurface_set_desync(r->wayland.subsurface->subsurface);
wl_subsurface_set_position(r->wayland.subsurface->subsurface, x, y);
if(parent) {
wl_subsurface_place_above(r->wayland.subsurface->subsurface, parent->wayland.framebuffer.surface);
}
r->wayland.xkb_keymap = parent->wayland.xkb_keymap;
r->wayland.xkb_state = parent->wayland.xkb_state;
r->wayland.configured = MwTRUE;
MwLLWaylandFramebufferSetup(&r->wayland);
MwLLWaylandBackbufferSetup(&r->wayland);
}
/* Subsurface setup function */
static void destroy_subsurface(MwLL r) {
MwLLWaylandBackbufferDestroy(&r->wayland);
MwLLWaylandFramebufferDestroy(&r->wayland);
free(r->wayland.sublevel);
r->wayland.configured = MwFALSE;
}
static void popup_configure(void* data,
struct xdg_popup* xdg_popup,
int32_t x,
@ -834,6 +892,7 @@ static void widget_setup(MwLL r, MwLL parent, int x, int y, int width, int heigh
r->wayland.parent = parent;
r->wayland.valid = MwTRUE;
printf("type %d\n", ty);
if(ty == MwLL_WAYLAND_UNKNOWN) {
if(parent == NULL) {
setup_toplevel(r, x, y);
@ -866,6 +925,9 @@ static void widget_setup(MwLL r, MwLL parent, int x, int y, int width, int heigh
case MwLL_WAYLAND_LAYER_SURFACE:
setup_layer_surface(r, x, y, width, height);
break;
case MwLL_WAYLAND_SUBSURFACE:
setup_subsurface(parent, r, x, y);
break;
}
}
@ -943,6 +1005,13 @@ static void draw_children(MwLL handle) {
cairo_reset_clip(handle->wayland.cairo.front_cairo_back);
if(handle->wayland.snapshot) {
cairo_set_operator(handle->wayland.cairo.front_cairo_back, CAIRO_OPERATOR_SOURCE);
cairo_set_source_surface(handle->wayland.cairo.front_cairo_back, handle->wayland.snapshot, 0, 0);
cairo_paint(handle->wayland.cairo.front_cairo_back);
cairo_set_operator(handle->wayland.cairo.front_cairo_back, CAIRO_OPERATOR_OVER);
}
MwLLWaylandChildrenIterate(handle, draw_child);
if(handle->wayland.configured) MwLLWaylandBufferUpdate(handle, &handle->wayland.framebuffer);
@ -986,6 +1055,9 @@ static void MwLLDestroyImpl(MwLL handle) {
int i;
struct timeval tv;
int select_ret;
MwLL topmost_parent = handle;
while(topmost_parent->wayland.parent) topmost_parent = topmost_parent->wayland.parent;
event_loop(handle);
// wl_display_cancel_read(handle->wayland.display);
@ -1025,6 +1097,12 @@ static void MwLLDestroyImpl(MwLL handle) {
printf("widget invalid\n");
}
for(i = 0; i < arrlen(topmost_parent->wayland.currentlyHeldWidgets); i++) {
if(topmost_parent->wayland.currentlyHeldWidgets[i] == handle) {
arrdel(topmost_parent->wayland.currentlyHeldWidgets, i);
}
}
// pthread_mutex_destroy(&handle->wayland.eventsMutex);
free(handle);
@ -1074,6 +1152,9 @@ static void MwLLSetXYImpl(MwLL handle, int x, int y) {
break;
case MwLL_WAYLAND_UNKNOWN:
break;
case MwLL_WAYLAND_SUBSURFACE:
wl_subsurface_set_position(handle->wayland.subsurface->subsurface, x, y);
break;
}
MwLLWaylandRegionSetup(handle);
@ -1104,10 +1185,7 @@ static void actually_set_wh(MwLL handle) {
MwLLWaylandRegionSetup(handle);
if(handle->wayland.type == MwLL_WAYLAND_SUBLEVEL) recursive_render(handle);
MwLLWaylandFramebufferDestroy(&handle->wayland);
MwLLWaylandFramebufferSetup(&handle->wayland);
MwLLWaylandBackbufferDestroy(&handle->wayland);
MwLLWaylandBackbufferSetup(&handle->wayland);
MwLLWaylandFramebufferResize(&handle->wayland);
MwLLDispatch(handle, draw, NULL);
}
@ -1297,6 +1375,21 @@ static void MwLLEndDrawImpl(MwLL handle) {
}
root->wayland.do_cascading_draw = MwTRUE;
if(handle->wayland.snapshot) {
cairo_surface_destroy(handle->wayland.snapshot);
handle->wayland.snapshot = NULL;
}
if(handle->wayland.ww > 0 && handle->wayland.wh > 0) {
cairo_t* snap_cr;
handle->wayland.snapshot = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, handle->wayland.ww, handle->wayland.wh);
snap_cr = cairo_create(handle->wayland.snapshot);
cairo_set_operator(snap_cr, CAIRO_OPERATOR_SOURCE);
cairo_set_source_surface(snap_cr, handle->wayland.cairo.front_cs_back, 0, 0);
cairo_paint(snap_cr);
cairo_destroy(snap_cr);
}
if(handle->wayland.configured) {
if(handle->wayland.type == MwLL_WAYLAND_TOPLEVEL) {
MwLLWaylandBufferUpdate(handle, &handle->wayland.backbuffer);

View file

@ -978,6 +978,7 @@ static void MwLLNextEventImpl(MwLL handle) {
};
case SelectionNotify:
{
#if 0
handle->x11.clipboard_pending = 0;
if(ev.xselection.property == handle->x11.xdnd_selection) {
@ -1066,6 +1067,7 @@ static void MwLLNextEventImpl(MwLL handle) {
}
XDeleteProperty(handle->x11.display, handle->x11.window, handle->x11.selection);
}
#endif
} break;
}
if(render) {

View file

@ -69,7 +69,8 @@ static void lldrawhandler(MwLL handle, void* data) {
static void lluphandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;
MwMouse* p = data;
if(MwGetInteger(h, MwNdisabled) == 1) return;
int n;
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
if(p->button == MwMOUSE_LEFT) h->pressed = 0;
h->mouse_point.x = p->point.x;
@ -83,7 +84,8 @@ static void lluphandler(MwLL handle, void* data) {
static void lldownhandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;
MwMouse* p = data;
if(MwGetInteger(h, MwNdisabled) == 1) return;
int n;
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
if(p->button == MwMOUSE_LEFT) h->pressed = 1;
h->mouse_point.x = p->point.x;
@ -158,7 +160,8 @@ static void llmovehandler(MwLL handle, void* data) {
static void llkeyhandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;
int key = *(int*)data;
if(MwGetInteger(h, MwNdisabled) == 1) return;
int n;
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
MwDispatch3(h, key, key);
MwDispatchUserHandler(h, MwNkeyHandler, data);
@ -166,28 +169,32 @@ static void llkeyhandler(MwLL handle, void* data) {
static void llkeyrelhandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;
if(MwGetInteger(h, MwNdisabled) == 1) return;
int n;
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
MwDispatchUserHandler(h, MwNkeyReleaseHandler, data);
}
static void llfocusinhandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;
if(MwGetInteger(h, MwNdisabled) == 1) return;
int n;
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
MwDispatchUserHandler(h, MwNfocusInHandler, data);
}
static void llfocusouthandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;
if(MwGetInteger(h, MwNdisabled) == 1) return;
int n;
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
MwDispatchUserHandler(h, MwNfocusOutHandler, data);
}
static void llclipboardhandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;
if(MwGetInteger(h, MwNdisabled) == 1) return;
int n;
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
MwDispatch3(h, clipboard, data);
MwDispatchUserHandler(h, MwNclipboardHandler, data);
@ -195,7 +202,8 @@ static void llclipboardhandler(MwLL handle, void* data) {
static void lldraganddrophandler(MwLL handle, void* data) {
MwWidget h = (MwWidget)handle->common.user;
if(MwGetInteger(h, MwNdisabled) == 1) return;
int n;
if((n = MwGetInteger(h, MwNdisabled)) != MwDEFAULT && n) return;
MwDispatchUserHandler(h, MwNdragAndDropHandler, data);
}
@ -671,7 +679,7 @@ void MwSetInteger(MwWidget handle, const char* key, int n) {
if(h->lowlevel != NULL) MwLLSetDarkTheme(h->lowlevel, n);
}
if(strcmp(key, MwNacceptsDnD) == 0) {
if(strcmp(key, MwNacceptsDnD) == 0 && n) {
if(handle->lowlevel != NULL) MwLLSetupDragAndDrop(handle->lowlevel);
}
}
@ -1233,4 +1241,31 @@ void MwGetFrame(MwWidget handle, MwRect* rect) {
rect->height = MwGetInteger(handle, MwNheight);
}
void MwGetClipFrame(MwWidget handle, MwRect* rect) {
MwWidget child = handle;
MwWidget p = handle->parent;
int o_x = 0, o_y = 0;
rect->x = 0;
rect->y = 0;
rect->width = MwGetInteger(handle, MwNwidth);
rect->height = MwGetInteger(handle, MwNheight);
while(p != NULL && p->widget_class != MwWindowClass) {
MwRect pclip;
o_x += MwGetInteger(child, MwNx);
o_y += MwGetInteger(child, MwNy);
pclip.x = -o_x;
pclip.y = -o_y;
pclip.width = MwGetInteger(p, MwNwidth);
pclip.height = MwGetInteger(p, MwNheight);
MwIntersectRect(rect, &pclip);
if(rect->width == 0 || rect->height == 0) break;
child = p;
p = p->parent;
}
}
const char* MwVersionString = MwVERSION;

View file

@ -39,7 +39,9 @@ static int hex(const char* txt, int len) {
}
static void color_set_disabled_if_disabled(MwWidget handle, MwLLColor rgb) {
if(MwGetInteger(handle, MwNdisabled) == 1) {
int n;
if((n = MwGetInteger(handle, MwNdisabled)) != MwDEFAULT && n) {
MwLLColor c = handle->parent == NULL ? NULL : MwParseColor(handle->parent, MwGetText(handle->parent, MwNbackground));
if(c != NULL) {
@ -1123,3 +1125,35 @@ MwLLPixmap MwLoadXPM(MwWidget handle, char** data) {
return px;
}
static int _min(int a, int b) {
return a < b ? a : b;
}
static int _max(int a, int b) {
return a > b ? a : b;
}
void MwIntersectRect(MwRect* a, const MwRect* b) {
int x;
int y;
int right;
int bottom;
x = _max(a->x, b->x);
y = _max(a->y, b->y);
right = _min(a->x + a->width, b->x + b->width);
bottom = _min(a->y + a->height, b->y + b->height);
a->x = x;
a->y = y;
if(right <= x || bottom <= x) {
a->width = 0;
a->height = 0;
return;
}
a->width = right - x;
a->height = bottom - y;
}

View file

@ -82,8 +82,9 @@ void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text,
char* last = input;
int cp;
MwLLColor fadedColor = NULL;
int n;
if(MwGetInteger(handle, MwNdisabled) == 1) {
if((n = MwGetInteger(handle, MwNdisabled)) != MwDEFAULT && n) {
MwLLColor c = handle->parent == NULL ? NULL : MwParseColor(handle->parent, MwGetText(handle->parent, MwNbackground));
if(c != NULL) {
@ -109,6 +110,8 @@ void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text,
if(*input == 0 || cp == '\n') {
char* line = malloc(input - last + 1);
int i;
MwPoint l[2];
int tw, th;
if(!line) {
printf("Out Of Memory\n");
@ -134,20 +137,38 @@ void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text,
continue;
}
tw = MwTextWidth(handle, ttf, line);
th = MwTextHeight(handle, ttf, line);
p.x = point->x;
if(align == MwALIGNMENT_CENTER) {
p.x -= MwTextWidth(handle, ttf, line) / 2;
p.x -= tw / 2;
} else if(align == MwALIGNMENT_END) {
p.x -= MwTextWidth(handle, ttf, line);
p.x -= tw;
}
l[0].x = p.x;
l[1].x = l[0].x + tw;
#ifdef TTF
if(MwFLDrawText)
if(is_bitmap(handle, ttf) || ttf == NULL || MwFLDrawText(handle, ttf, &p, line, fadedColor ? fadedColor : color))
#endif
bitmap_MwDrawText(handle, &p, line, is_bold(handle, ttf), fadedColor ? fadedColor : color);
p.y += MwTextHeight(handle, ttf, line);
l[0].y = l[1].y = p.y;
if((n = MwGetInteger(handle, MwNstrikethrough)) != MwDEFAULT && n) {
MwLLLine(handle->lowlevel, l, color);
}
if((n = MwGetInteger(handle, MwNunderline)) != MwDEFAULT && n) {
l[0].y += th / 2;
l[1].y += th / 2;
MwLLLine(handle->lowlevel, l, color);
}
p.y += th;
free(line);

105
src/widget/direct3d9.c Normal file
View file

@ -0,0 +1,105 @@
#include <Mw/Milsko.h>
#ifdef MW_DIRECT3D9
#include <Mw/Widget/Direct3D9.h>
typedef struct gdid3d9 {
void* d3d9dll;
IDirect3D9*(WINAPI* Direct3DCreate9)(UINT sdk_version);
LPDIRECT3D9 d3d; // the pointer to our Direct3D interface
LPDIRECT3DDEVICE9 d3ddev; // the pointer to the device class
} gdid3d9_t;
#ifndef D3D_SDK_VERSION
#define D3D_SDK_VERSION 32
#endif
static int wcreate_d3d9(MwWidget handle) {
gdid3d9_t* o = malloc(sizeof(gdid3d9_t));
HRESULT hr;
char errbuf[2048];
D3DPRESENT_PARAMETERS d3dpp; // create a struct to hold various device information
o->d3d9dll = LoadLibrary("d3d9.dll");
if(!o->d3d9dll) {
MessageBox(NULL, "d3d9.dll not found! Is DirectX9 installed?", "Error", MB_OK);
ExitProcess(-1);
}
o->Direct3DCreate9 = (void*)GetProcAddress(o->d3d9dll, "Direct3DCreate9");
o->d3d = o->Direct3DCreate9(D3D_SDK_VERSION); // create the Direct3D interface
if(o->d3d == NULL) {
MwDispatchError(1, "Direct3DCreate9 NULL");
return 1;
}
ZeroMemory(&d3dpp, sizeof(d3dpp)); // clear out the struct for use
d3dpp.Windowed = TRUE; // program windowed, not fullscreen
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; // discard old frames
d3dpp.hDeviceWindow = handle->lowlevel->gdi.hWnd; // set the window to be used by Direct3D
// create a device class using this information and information from the d3dpp stuct
hr = o->d3d->lpVtbl->CreateDevice(o->d3d,
D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
handle->lowlevel->gdi.hWnd,
D3DCREATE_MIXED_VERTEXPROCESSING,
&d3dpp,
&o->d3ddev);
if(hr != D3D_OK) {
MwStringPrintIntoBuffer(errbuf, sizeof(errbuf) - 1, "CreateDevice ERROR: %s", hr);
MwDispatchError(1, errbuf);
return 1;
}
handle->internal = o;
return 0;
}
static void destroy_d3d9(MwWidget handle) {
gdid3d9_t* o = handle->internal;
o->d3ddev->lpVtbl->Release(o->d3ddev); // close and release the 3D device
o->d3d->lpVtbl->Release(o->d3d); // close and release Direct3D
free(handle->internal);
}
static void func_handler_d3d9(MwWidget handle, const char* name, void* out,
va_list va) {
gdid3d9_t* o = handle->internal;
(void)va;
if(strcmp(name, "mwDirect3D9GetDirect3D9") == 0) {
*(LPDIRECT3D9*)out = o->d3d;
}
if(strcmp(name, "mwDirect3D9GetDirect3DDevice9") == 0) {
*(LPDIRECT3DDEVICE9*)out = o->d3ddev;
}
}
MwClassRec MwDirect3D9ClassRec = {wcreate_d3d9, /* create */
destroy_d3d9, /* destroy */
NULL, /* draw */
NULL, /* click */
NULL, /* parent_resize */
NULL, /* prop_change */
NULL, /* mouse_move */
NULL, /* mouse_up */
NULL, /* mouse_down */
NULL, /* key */
func_handler_d3d9, /* execute */
NULL, /* tick */
NULL, /* resize */
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL, /* props_change */
NULL, NULL, NULL};
MwClass MwDirect3D9Class = &MwDirect3D9ClassRec;
#else
MwClass MwDirect3D9Class = NULL;
#endif

View file

@ -59,6 +59,9 @@ static void draw(MwWidget handle) {
MwFLFont font = NULL;
MwPoint u_p, s_p, c_p;
int u = 0, s = 0, c = 0;
MwRect clip;
MwGetClipFrame(handle, &clip);
u_p.x = s_p.x = c_p.x = 0;
u_p.y = s_p.y = c_p.y = 0;
@ -76,9 +79,12 @@ static void draw(MwWidget handle) {
case MwDOCUMENT_TEXT:
{
MwPoint p;
int th2;
p.x = l->x;
p.y = l->y + MwTextHeight(handle, font, l->text) / 2;
p.y = l->y + (th2 = MwTextHeight(handle, font, l->text) / 2);
if((p.y + th2) <= clip.y || (p.y - th2) >= clip.y + clip.height) break;
if(u || s || c) {
MwPoint line[2];
@ -498,6 +504,7 @@ static void layout(MwWidget handle) {
MwFLFont* fontstack = NULL;
MwRect clickable;
char* c_title = NULL;
MwRect size;
arrput(fontstack, NULL);
@ -612,8 +619,9 @@ static void layout(MwWidget handle) {
l->font = TOPFONT;
}
y += MwTextHeight(handle, TOPFONT, "M");
MwDispatchUserHandler(handle, MwNlayoutHandler, &y);
size.width = w;
size.height = y + MwTextHeight(handle, TOPFONT, "M");
MwDispatchUserHandler(handle, MwNlayoutHandler, &size);
arrfree(fontstack);

View file

@ -351,13 +351,22 @@ static int vulkan_surface_setup(MwWidget handle, vulkan_t* o) {
if(handle->lowlevel->common.type == MwLLBackendWayland) {
LOAD_VK_FUNCTION(vkCreateWaylandSurfaceKHR);
VkWaylandSurfaceCreateInfoKHR createInfo = {
VkWaylandSurfaceCreateInfoKHR createInfo;
/* transition to a subsurface */
MwLLBeginStateChange(handle->lowlevel);
handle->lowlevel->wayland.changing = MwTRUE;
handle->lowlevel->wayland.type_to_be = MwLL_WAYLAND_SUBSURFACE;
MwLLEndStateChange(handle->lowlevel);
createInfo = (VkWaylandSurfaceCreateInfoKHR){
.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR,
.pNext = NULL,
.flags = 0,
.display = handle->lowlevel->wayland.display,
.surface = handle->lowlevel->wayland.framebuffer.surface,
};
VK_CMD(_vkCreateWaylandSurfaceKHR(o->vkInstance, &createInfo, NULL, &o->vkSurface));
}
#endif
@ -609,6 +618,7 @@ void MwVulkanConfigure(MwVulkanConfig* cfg) {
}
int MwVulkanSupported(void) {
printf("[vulkan support not copmiled]\n");
return 0;
}
#endif

View file

@ -59,6 +59,8 @@ sub scan {
while (my $file = readdir($dh)) {
if ( !(($dir . "/" . $file) eq "src/widget/opengl.c")
&& !(($dir . "/" . $file) eq "src/widget/vulkan.c")
&& !(($dir . "/" . $file) eq "src/widget/d3d8.c")
&& !(($dir . "/" . $file) eq "src/widget/d3d9.c")
&& !(($dir . "/" . $file) eq "external/stb_truetype.c")
&& !(($dir . "/" . $file) eq "external/stb_image.c")
&& ($file =~ /\.c$/))

View file

@ -42,6 +42,34 @@ sub cobjs {
return $r;
}
sub d3d9_detect_block {
return <<'EOF';
!if [where /R "%DXSDK_DIR%\\Include" /Q d3d9.h] == 0
!if [echo DX9_FLAGS = /DMW_DIRECT3D9 /I"%DXSDK_DIR%\\Include">d3d9flags.mk]
!endif
!else
!if [echo DX9_FLAGS =>d3d9flags.mk]
!endif
!endif
!if exist("d3d9flags.mk")
!include "d3d9flags.mk"
!else
DX9_FLAGS =
!endif
EOF
}
sub skip_d3d9 {
my $f = $_[0];
my $type = $_[1];
if (($f =~ /\/dxdemos\//) and not($type eq "Watcom")) {
return 1;
}
return 0;
}
sub generate {
my ($output, $type) = @_;
@ -65,6 +93,8 @@ sub generate {
my $lib = "";
my $c_dllout = "";
my $c_dllafter = "";
my $d3d9_flags = "";
my $d3d9_block = "";
if ($type eq "Borland") {
$cc = "bcc32 -c";
@ -88,9 +118,12 @@ sub generate {
$def = "/D";
$inc = "/I";
$dll = "/DLL";
$d3d9_flags = "\$(DX9_FLAGS)";
$d3d9_block = d3d9_detect_block();
}
elsif ($type eq "Watcom") {
$cc = "wcc386 -bt=nt -q";
$cc = "wcc386 -bt=nt -q -fr";
$link = "wlink option quiet";
$out = "-fo=";
$dllout = "name ";
@ -109,14 +142,20 @@ sub generate {
$prefobj = "file ";
$needlibs = "${lib}clib3r.lib";
$c_dllout = "option implib=src${dir}Mw.lib";
$d3d9_flags = "${def}MW_DIRECT3D9";
}
open(OUT, ">", $output);
print(OUT "CC = $cc\n");
print(OUT "LD = $link\n");
print(OUT "\n");
if ($d3d9_block ne "") {
print(OUT $d3d9_block);
print(OUT "\n");
}
print(OUT
"MW_CFLAGS = ${cdll} ${inc}include ${inc}external${dir}libz${dir}include ${def}_MILSKO ${def}_MILSKO_BUILD ${def}USE_GDI ${def}USE_STB_IMAGE ${def}STBI_NO_SIMD ${def}USE_GDI_TEXT ${def}MW_OPENGL\n"
"MW_CFLAGS = ${cdll} ${inc}include ${inc}external${dir}libz${dir}include ${def}_MILSKO ${def}_MILSKO_BUILD ${def}USE_GDI ${def}USE_STB_IMAGE ${def}STBI_NO_SIMD ${def}USE_GDI_TEXT ${def}MW_OPENGL ${d3d9_flags}\n"
);
print(OUT "MW_LDFLAGS = $dll\n");
print(OUT "EXE_CFLAGS = ${inc}include\n");
@ -128,6 +167,9 @@ sub generate {
}
print(OUT "all: src${dir}Mw.dll");
foreach my $f (@examples) {
if (skip_d3d9($f, $type)) {
next;
}
$b = $f;
$b =~ s/\.c$/.exe/;
$b =~ s/\//$dir/g;
@ -137,6 +179,9 @@ sub generate {
print(OUT "lib: src${dir}Mw.dll\n");
print(OUT "examples:");
foreach my $f (@examples) {
if (skip_d3d9($f, $type)) {
next;
}
$b = $f;
$b =~ s/\.c$/.exe/;
$b =~ s/\//$dir/g;
@ -145,6 +190,9 @@ sub generate {
print(OUT "\n");
print(OUT "clean: $symbolic\n");
foreach my $f (@cfiles) {
if (skip_d3d9($f, $type)) {
next;
}
my $b = $f;
$b =~ s/\.c$/.obj/;
$b =~ s/\//$dir/g;
@ -152,13 +200,22 @@ sub generate {
}
print(OUT " $del src${dir}Mw.dll\n");
print(OUT " $del src${dir}Mw.lib\n");
if ($d3d9_block ne "") {
print(OUT " $del d3d9flags.mk\n");
}
foreach my $f (@examples) {
if (skip_d3d9($f, $type)) {
next;
}
my $b = $f;
$b =~ s/\.c$/.obj/;
$b =~ s/\//$dir/g;
print(OUT " $del $b\n");
}
foreach my $f (@examples) {
if (skip_d3d9($f, $type)) {
next;
}
$b = $f;
$b =~ s/\.c$/.exe/;
$b =~ s/\//$dir/g;
@ -166,6 +223,9 @@ sub generate {
}
print(OUT "\n");
foreach my $f (@examples) {
if (skip_d3d9($f, $type)) {
next;
}
my $b = $f;
$b =~ s/\.c$/.exe/;
$b =~ s/\//$dir/g;
@ -227,6 +287,7 @@ push(@cfiles, "src/backend/gdi.c");
scan_examples("examples/basic");
scan_examples("examples/gldemos");
scan_examples("examples/dxdemos");
@examples = sort(@examples);