Got rid of the modal queue now that it's no longer needed.
This commit is contained in:
parent
428c20d4f5
commit
8e9607083b
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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 *);
|
|
@ -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)))
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
|
|
|
@ -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)))
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)))
|
||||
}
|
||||
|
|
|
@ -34,8 +34,6 @@ enum {
|
|||
msgAreaRepaint,
|
||||
msgAreaRepaintAll,
|
||||
msgTabCurrentTabHasChildren,
|
||||
msgBeginModal,
|
||||
msgEndModal,
|
||||
msgAreaKeyDown,
|
||||
msgAreaKeyUp,
|
||||
msgLoadImageList,
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue