summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAlexander Neumann <alexander.neumann@picos-software.com>2019-02-25 17:48:29 +0100
committerAlexander Neumann <alexander.neumann@picos-software.com>2019-02-25 17:48:29 +0100
commit7482e1fbe5e45d808ca208d08a93b46a4d7738e4 (patch)
treecf697b53d9f540f5d3018526507094119b7f504e
parentNothing to see here. Move on. (diff)
downloadwireguard-windows-7482e1fbe5e45d808ca208d08a93b46a4d7738e4.tar.xz
wireguard-windows-7482e1fbe5e45d808ca208d08a93b46a4d7738e4.zip
Remove experimental run.dll performance improvement code
-rw-r--r--container.go55
-rw-r--r--form.go66
2 files changed, 17 insertions, 104 deletions
diff --git a/container.go b/container.go
index b3087709..81ca217c 100644
--- a/container.go
+++ b/container.go
@@ -7,7 +7,6 @@
package walk
import (
- "errors"
"unsafe"
"github.com/lxn/win"
@@ -116,14 +115,6 @@ type layoutResultItem struct {
}
func applyLayoutResults(container Container, items []layoutResultItem) error {
- // if applyLayoutResultsProc != 0 {
- // return applyLayoutResultsRun(container, items)
- // }
-
- return applyLayoutResultsWalk(container, items)
-}
-
-func applyLayoutResultsWalk(container Container, items []layoutResultItem) error {
hdwp := win.BeginDeferWindowPos(int32(len(items)))
if hdwp == 0 {
return lastError("BeginDeferWindowPos")
@@ -166,14 +157,11 @@ func applyLayoutResultsWalk(container Container, items []layoutResultItem) error
return lastError("DeferWindowPos")
}
- // FIXME: Is this really necessary?
- // for _, item := range items {
- if /*!shouldLayoutWidget(item.widget) ||*/ item.widget.GraphicsEffects().Len() == 0 {
+ if item.widget.GraphicsEffects().Len() == 0 {
continue
}
item.widget.AsWidgetBase().invalidateBorderInParent()
- // }
}
if !win.EndDeferWindowPos(hdwp) {
@@ -183,47 +171,6 @@ func applyLayoutResultsWalk(container Container, items []layoutResultItem) error
return nil
}
-func applyLayoutResultsRun(container Container, items []layoutResultItem) error {
- resultItems := make([]applyLayoutResultsItem, 0, len(items))
-
- for _, item := range items {
- widget := item.widget
- x, y, w, h := item.bounds.X, item.bounds.Y, item.bounds.Width, item.bounds.Height
-
- b := widget.Bounds()
-
- if b.X == x && b.Y == y && b.Width == w {
- if _, ok := widget.(*ComboBox); ok {
- if b.Height+1 == h {
- continue
- }
- } else if b.Height == h {
- continue
- }
- }
-
- resultItems = append(resultItems, applyLayoutResultsItem{
- hwnd: widget.Handle(),
- x: int32(x),
- y: int32(y),
- w: int32(w),
- h: int32(h),
- oldBounds: b.toRECT(),
- shouldInvalidateBorderInParent: win.BoolToBOOL( /*shouldLayoutWidget(item.widget) &&*/ item.widget.GraphicsEffects().Len() > 0),
- })
- }
-
- if len(resultItems) == 0 {
- return nil
- }
-
- if !applyLayoutResultsImpl(container.Handle(), win.BoolToBOOL(container.AsContainerBase().hasComplexBackground()), &resultItems[0], int32(len(resultItems))) {
- return errors.New("ApplyLayoutResults failed")
- }
-
- return nil
-}
-
type applyLayoutResultsItem struct {
hwnd win.HWND
x int32
diff --git a/form.go b/form.go
index dd8bad4d..87258749 100644
--- a/form.go
+++ b/form.go
@@ -24,9 +24,6 @@ const (
)
var (
- processMessageProc uintptr
- applyLayoutResultsProc uintptr
-
syncFuncs struct {
m sync.Mutex
funcs []func()
@@ -37,25 +34,10 @@ var (
)
func init() {
- if dll, err := syscall.LoadLibrary("run.dll"); err == nil {
- applyLayoutResultsProc, err = syscall.GetProcAddress(dll, "ApplyLayoutResults")
- processMessageProc, err = syscall.GetProcAddress(dll, "ProcessMessage")
- }
-
syncMsgId = win.RegisterWindowMessage(syscall.StringToUTF16Ptr("WalkSync"))
taskbarButtonCreatedMsgId = win.RegisterWindowMessage(syscall.StringToUTF16Ptr("TaskbarButtonCreated"))
}
-func applyLayoutResultsImpl(hwndParent win.HWND, maybeInvalidate win.BOOL, items *applyLayoutResultsItem, itemsLen int32) bool {
- ret, _, _ := syscall.Syscall6(applyLayoutResultsProc, 4, uintptr(hwndParent), uintptr(maybeInvalidate), uintptr(unsafe.Pointer(items)), uintptr(itemsLen), 0, 0)
- return ret != 0
-}
-
-func processMessage(hwnd win.HWND, msg *win.MSG) bool {
- ret, _, _ := syscall.Syscall(processMessageProc, 2, uintptr(hwnd), uintptr(unsafe.Pointer(msg)), 0)
- return ret != 0
-}
-
func synchronize(f func()) {
syncFuncs.m.Lock()
defer syncFuncs.m.Unlock()
@@ -413,44 +395,28 @@ func (fb *FormBase) Run() int {
var msg win.MSG
- if processMessageProc != 0 {
- for fb.hWnd != 0 {
- if !processMessage(fb.hWnd, &msg) {
- return int(msg.WParam)
- }
+ for fb.hWnd != 0 {
+ switch win.GetMessage(&msg, 0, 0, 0) {
+ case 0:
+ return int(msg.WParam)
- if msg.Message == win.WM_KEYDOWN {
- if fb.webViewTranslateAccelerator(&msg) {
- // handled accelerator key of webview and its childen (ie IE)
- }
- }
-
- runSynchronized()
+ case -1:
+ return -1
}
- } else {
- for fb.hWnd != 0 {
- switch win.GetMessage(&msg, 0, 0, 0) {
- case 0:
- return int(msg.WParam)
-
- case -1:
- return -1
- }
-
- switch msg.Message {
- case win.WM_KEYDOWN:
- if fb.webViewTranslateAccelerator(&msg) {
- // handled accelerator key of webview and its childen (ie IE)
- }
- }
- if !win.IsDialogMessage(fb.hWnd, &msg) {
- win.TranslateMessage(&msg)
- win.DispatchMessage(&msg)
+ switch msg.Message {
+ case win.WM_KEYDOWN:
+ if fb.webViewTranslateAccelerator(&msg) {
+ // handled accelerator key of webview and its childen (ie IE)
}
+ }
- runSynchronized()
+ if !win.IsDialogMessage(fb.hWnd, &msg) {
+ win.TranslateMessage(&msg)
+ win.DispatchMessage(&msg)
}
+
+ runSynchronized()
}
return 0