summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--redo/dialog_unix.go1
-rw-r--r--redo/modalqueue.c50
-rw-r--r--redo/modalqueue.h9
-rw-r--r--redo/uitask_darwin.go5
-rw-r--r--redo/uitask_darwin.m5
-rw-r--r--redo/uitask_unix.go10
-rw-r--r--redo/uitask_windows.c21
-rw-r--r--redo/uitask_windows.go5
-rw-r--r--redo/winapi_windows.h2
-rw-r--r--redo/window_windows.c6
-rw-r--r--redo/window_windows.go19
11 files changed, 2 insertions, 131 deletions
diff --git a/redo/dialog_unix.go b/redo/dialog_unix.go
index 7ecef93..158d11b 100644
--- a/redo/dialog_unix.go
+++ b/redo/dialog_unix.go
@@ -9,7 +9,6 @@ import (
)
// #include "gtk_unix.h"
-// #include "modalqueue.h"
// extern void our_openfile_response_callback(GtkDialog *, gint, gpointer);
// /* because cgo doesn't like ... */
// static inline GtkWidget *newOpenFileDialog(GtkWindow *parent)
diff --git a/redo/modalqueue.c b/redo/modalqueue.c
deleted file mode 100644
index a41787f..0000000
--- a/redo/modalqueue.c
+++ /dev/null
@@ -1,50 +0,0 @@
-// 19 august 2014
-
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include "modalqueue.h"
-
-static struct {
- int inmodal;
- void **queue;
- size_t len;
- size_t cap;
-} mq = { 0, NULL, 0, 0 };
-
-void beginModal(void)
-{
- mq.inmodal = 1;
- if (mq.queue == NULL) {
- mq.cap = 128;
- mq.queue = (void **) malloc(mq.cap * sizeof (void *));
- if (mq.queue == NULL)
- modalPanic("error allocating modal queue", strerror(errno));
- mq.len = 0;
- }
-}
-
-void endModal(void)
-{
- size_t i;
-
- mq.inmodal = 0;
- for (i = 0; i < mq.len; i++)
- doissue(mq.queue[i]);
- mq.len = 0;
-}
-
-int queueIfModal(void *what)
-{
- if (!mq.inmodal)
- return 0;
- mq.queue[mq.len] = what;
- mq.len++;
- if (mq.len >= mq.cap) {
- mq.cap *= 2;
- mq.queue = (void **) realloc(mq.queue, mq.cap * sizeof (void *));
- if (mq.queue == NULL)
- modalPanic("error growing modal queue", strerror(errno));
- }
- return 1;
-}
diff --git a/redo/modalqueue.h b/redo/modalqueue.h
deleted file mode 100644
index e05db36..0000000
--- a/redo/modalqueue.h
+++ /dev/null
@@ -1,9 +0,0 @@
-/* 19 august 2014 */
-
-extern void beginModal(void);
-extern void endModal(void);
-extern int queueIfModal(void *);
-
-/* needed by the above */
-extern void doissue(void *);
-extern void modalPanic(char *, char *);
diff --git a/redo/uitask_darwin.go b/redo/uitask_darwin.go
index 2e0380a..13de8e0 100644
--- a/redo/uitask_darwin.go
+++ b/redo/uitask_darwin.go
@@ -39,8 +39,3 @@ func issue(f *func()) {
func doissue(fp unsafe.Pointer) {
perform(fp)
}
-
-//export modalPanic
-func modalPanic(reason *C.char, strerror *C.char) {
- panic(fmt.Errorf("%s: %s", C.GoString(reason), C.GoString(strerror)))
-}
diff --git a/redo/uitask_darwin.m b/redo/uitask_darwin.m
index 4a2173f..e69882a 100644
--- a/redo/uitask_darwin.m
+++ b/redo/uitask_darwin.m
@@ -2,7 +2,6 @@
#import "objc_darwin.h"
#import "_cgo_export.h"
-#import "modalqueue.h"
#import <Cocoa/Cocoa.h>
#define toNSWindow(x) ((NSWindow *) (x))
@@ -130,13 +129,9 @@ void uistop(void)
[NSApp postEvent:e atStart:NO]; // let pending events take priority
}
-// we use the modal queue because dispatch_suspend()/dispatch_resume() can't be used with the main queue
-
// thanks to mikeash in irc.freenode.net/#macdev for suggesting the use of Grand Central Dispatch and blocks for this
void issue(void *what)
{
- if (queueIfModal(what))
- return;
dispatch_async(dispatch_get_main_queue(), ^{
doissue(what);
});
diff --git a/redo/uitask_unix.go b/redo/uitask_unix.go
index 7786d95..4a3e4b8 100644
--- a/redo/uitask_unix.go
+++ b/redo/uitask_unix.go
@@ -12,7 +12,6 @@ import (
// #cgo pkg-config: gtk+-3.0
// #cgo CFLAGS: --std=c99
// #include "gtk_unix.h"
-// #include "modalqueue.h"
// extern gboolean xdoissue(gpointer data);
import "C"
@@ -37,9 +36,7 @@ func uistop() {
}
func issue(f *func()) {
- if C.queueIfModal(unsafe.Pointer(f)) == 0 {
- C.gdk_threads_add_idle(C.GSourceFunc(C.xdoissue), C.gpointer(unsafe.Pointer(f)))
- }
+ C.gdk_threads_add_idle(C.GSourceFunc(C.xdoissue), C.gpointer(unsafe.Pointer(f)))
}
//export xdoissue
@@ -53,8 +50,3 @@ func doissue(data unsafe.Pointer) {
// for the modal queue functions
perform(data)
}
-
-//export modalPanic
-func modalPanic(reason *C.char, strerror *C.char) {
- panic(fmt.Errorf("%s: %s", C.GoString(reason), C.GoString(strerror)))
-}
diff --git a/redo/uitask_windows.c b/redo/uitask_windows.c
index 6e5e384..e7f9b5e 100644
--- a/redo/uitask_windows.c
+++ b/redo/uitask_windows.c
@@ -2,7 +2,6 @@
#include "winapi_windows.h"
#include "_cgo_export.h"
-#include "modalqueue.h"
// note that this includes the terminating '\0'
// this also assumes WC_TABCONTROL is longer than areaWindowClass
@@ -117,13 +116,6 @@ HWND msgwin;
#define msgwinclass L"gouimsgwin"
-static BOOL CALLBACK beginEndModalAll(HWND hwnd, LPARAM lParam)
-{
- if (hwnd != msgwin)
- SendMessageW(hwnd, (UINT) lParam, 0, 0);
- return TRUE;
-}
-
static LRESULT CALLBACK msgwinproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
LRESULT shared;
@@ -133,18 +125,7 @@ static LRESULT CALLBACK msgwinproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
return shared;
switch (uMsg) {
case msgRequest:
- // in modal?
- if (!queueIfModal((void *) lParam))
- // nope, we can run now
- doissue((void *) lParam);
- return 0;
- case msgBeginModal:
- beginModal();
- EnumThreadWindows(GetCurrentThreadId(), beginEndModalAll, msgBeginModal);
- return 0;
- case msgEndModal:
- endModal();
- EnumThreadWindows(GetCurrentThreadId(), beginEndModalAll, msgEndModal);
+ doissue((void *) lParam);
return 0;
case msgOpenFileDone:
finishOpenFile((WCHAR *) wParam, (void *) lParam);
diff --git a/redo/uitask_windows.go b/redo/uitask_windows.go
index 5d9d29a..c3c1884 100644
--- a/redo/uitask_windows.go
+++ b/redo/uitask_windows.go
@@ -68,8 +68,3 @@ func makemsgwin() error {
func doissue(fp unsafe.Pointer) {
perform(fp)
}
-
-//export modalPanic
-func modalPanic(reason *C.char, strerror *C.char) {
- panic(fmt.Errorf("%s: %s", C.GoString(reason), C.GoString(strerror)))
-}
diff --git a/redo/winapi_windows.h b/redo/winapi_windows.h
index ca88f01..743c819 100644
--- a/redo/winapi_windows.h
+++ b/redo/winapi_windows.h
@@ -34,8 +34,6 @@ enum {
msgAreaRepaint,
msgAreaRepaintAll,
msgTabCurrentTabHasChildren,
- msgBeginModal,
- msgEndModal,
msgAreaKeyDown,
msgAreaKeyUp,
msgLoadImageList,
diff --git a/redo/window_windows.c b/redo/window_windows.c
index 8a042e0..7790bfe 100644
--- a/redo/window_windows.c
+++ b/redo/window_windows.c
@@ -17,12 +17,6 @@ static LRESULT CALLBACK windowWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARA
if (sharedWndProc(hwnd, uMsg, wParam, lParam, &lResult))
return lResult;
switch (uMsg) {
- case msgBeginModal:
- windowBeginModal(data);
- return 0;
- case msgEndModal:
- windowEndModal(data);
- return 0;
case WM_SIZE:
if (GetClientRect(hwnd, &r) == 0)
xpanic("error getting client rect for Window in WM_SIZE", GetLastError());
diff --git a/redo/window_windows.go b/redo/window_windows.go
index 5789df8..60f89d1 100644
--- a/redo/window_windows.go
+++ b/redo/window_windows.go
@@ -14,7 +14,6 @@ import "C"
type window struct {
hwnd C.HWND
shownbefore bool
- modallevel int
closing *event
@@ -100,21 +99,3 @@ func windowClosing(data unsafe.Pointer) {
C.windowClose(w.hwnd)
}
}
-
-//export windowBeginModal
-func windowBeginModal(data unsafe.Pointer) {
- w := (*window)(data)
- C.EnableWindow(w.hwnd, C.FALSE)
- w.modallevel++
-}
-
-//export windowEndModal
-func windowEndModal(data unsafe.Pointer) {
- w := (*window)(data)
- w.modallevel--
- if w.modallevel == 0 {
- C.EnableWindow(w.hwnd, C.TRUE)
- } else if w.modallevel < 0 {
- panic("window begin/end modal mismatch")
- }
-}