summaryrefslogtreecommitdiff
path: root/redo/window_unix.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-07-14 22:54:57 -0400
committerPietro Gagliardi <[email protected]>2014-07-14 22:54:57 -0400
commitb3cba4bfb1108bed1c8ea9d36fde61abfb8bc087 (patch)
tree168cd8c4af975e63342521bebf1aee6958b72fb3 /redo/window_unix.go
parentdaafb7aef88908229c2039566e832333c111a95c (diff)
Added window resize handling to the GTK+ backend.
Diffstat (limited to 'redo/window_unix.go')
-rw-r--r--redo/window_unix.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/redo/window_unix.go b/redo/window_unix.go
index 8c0f55e..062c65f 100644
--- a/redo/window_unix.go
+++ b/redo/window_unix.go
@@ -6,10 +6,12 @@ package ui
import (
"unsafe"
+"fmt"
)
// #include "gtk_unix.h"
// extern gboolean windowClosing(GtkWidget *, GdkEvent *, gpointer);
+// extern gboolean windowResizing(GtkWidget *, GdkEvent *, gpointer);
import "C"
type window struct {
@@ -47,6 +49,11 @@ func newWindow(title string, width int, height int) *Request {
"delete-event",
C.GCallback(C.windowClosing),
C.gpointer(unsafe.Pointer(w)))
+ g_signal_connect(
+ C.gpointer(unsafe.Pointer(w.window)),
+ "configure-event",
+ C.GCallback(C.windowResizing),
+ C.gpointer(unsafe.Pointer(w)))
// TODO size
C.gtk_container_add(w.container, layoutw)
c <- w
@@ -144,3 +151,14 @@ func windowClosing(wid *C.GtkWidget, e *C.GdkEvent, data C.gpointer) C.gboolean
}
return C.GDK_EVENT_STOP // keeps window alive
}
+
+//export windowResizing
+func windowResizing(wid *C.GtkWidget, event *C.GdkEvent, data C.gpointer) C.gboolean {
+ w := (*window)(unsafe.Pointer(data))
+ e := (*C.GdkEventConfigure)(unsafe.Pointer(event))
+ _ = w // TODO
+ // TODO this does not take CSD into account; my attempts at doing so so far have failed to work correctly in the face of rapid live resizing
+ // TODO triggered twice on each resize or maximize for some reason???
+ fmt.Printf("new size %d x %d\n", e.width, e.height)
+ return C.GDK_EVENT_PROPAGATE // let's be safe
+}