Skip to content

Commit b2f0656

Browse files
committed
fixup
1 parent d755f6d commit b2f0656

File tree

4 files changed

+112
-30
lines changed

4 files changed

+112
-30
lines changed

editor/screen.go

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ type Cell struct {
5656

5757
type IntInt [2]int
5858

59+
// ExternalWin is
60+
type ExternalWin struct {
61+
widgets.QDialog
62+
}
63+
5964
// Window is
6065
type Window struct {
6166
paintMutex sync.Mutex
@@ -93,7 +98,7 @@ type Window struct {
9398
devicePixelRatio float64
9499
textCache gcache.Cache
95100

96-
diag *widgets.QDialog
101+
extwin *ExternalWin
97102
font *Font
98103
background *RGBA
99104
width float64
@@ -2154,9 +2159,9 @@ func (s *Screen) update() {
21542159
// s.windows.Delete(grid)
21552160
// }
21562161
win.hide()
2157-
if win.diag != nil {
2158-
win.diag.Hide()
2159-
win.diag = nil
2162+
if win.extwin != nil {
2163+
win.extwin.Hide()
2164+
win.extwin = nil
21602165
}
21612166
s.windows.Delete(grid)
21622167
}
@@ -2914,42 +2919,38 @@ func (s *Screen) windowExternalPosition(args []interface{}) {
29142919
// winid := arg.([]interface{})[1].(nvim.Window)
29152920

29162921
s.windows.Range(func(_, winITF interface{}) bool {
2917-
win := winITF.(*Window)
2918-
if win == nil {
2919-
return true
2920-
}
2921-
if win.grid == 1 {
2922-
return true
2923-
}
2924-
if win.isMsgGrid {
2925-
return true
2926-
}
2922+
win := winITF.(*Window)
2923+
if win == nil {
2924+
return true
2925+
}
2926+
if win.grid == 1 {
2927+
return true
2928+
}
2929+
if win.isMsgGrid {
2930+
return true
2931+
}
29272932
if win.grid == gridid && !win.isExternal {
29282933
win.isExternal = true
2929-
diag := widgets.NewQDialog(nil, core.Qt__Dialog)
2930-
win.widget.SetParent(diag)
2931-
diag.ConnectKeyPressEvent(editor.keyPress)
2932-
diag.ConnectResizeEvent(func(event *gui.QResizeEvent) {
2933-
height := diag.Height()
2934-
width := diag.Width()
2934+
2935+
extwin := createExternalWin()
2936+
win.widget.SetParent(extwin)
2937+
extwin.ConnectKeyPressEvent(editor.keyPress)
2938+
extwin.ConnectResizeEvent(func(event *gui.QResizeEvent) {
2939+
height := extwin.Height()-10
2940+
width := extwin.Width()-10
29352941
cols := int((float64(width) / win.getFont().truewidth))
29362942
rows := height / win.getFont().lineHeight
29372943
_ = s.ws.nvim.TryResizeUIGrid(win.grid, cols, rows)
29382944
})
2939-
diag.SetWindowFlag(core.Qt__WindowMaximizeButtonHint, false)
2940-
diag.SetWindowFlag(core.Qt__WindowMinimizeButtonHint, false)
2941-
diag.SetWindowFlag(core.Qt__WindowCloseButtonHint, false)
2942-
diag.SetWindowFlag(core.Qt__WindowContextHelpButtonHint, false)
29432945

29442946
win.background = s.ws.background.copy()
2945-
diag.SetAutoFillBackground(true)
2947+
extwin.SetAutoFillBackground(true)
29462948
p := gui.NewQPalette()
29472949
p.SetColor2(gui.QPalette__Background, s.ws.background.QColor())
2948-
diag.SetPalette(p)
2950+
extwin.SetPalette(p)
29492951

2950-
diag.Show()
2951-
2952-
win.diag = diag
2952+
extwin.Show()
2953+
win.extwin = extwin
29532954
}
29542955

29552956
return true
@@ -3050,7 +3051,7 @@ func (w *Window) raise() {
30503051
if !w.isExternal {
30513052
editor.window.Raise()
30523053
} else if w.isExternal {
3053-
w.diag.Raise()
3054+
w.extwin.Raise()
30543055
}
30553056
}
30563057

@@ -3148,6 +3149,13 @@ func (w *Window) move(col int, row int) {
31483149
y += w.s.ws.tabline.widget.Height()
31493150
}
31503151
}
3152+
if w.isExternal {
3153+
x += 5
3154+
y += 5
3155+
3156+
}
3157+
3158+
31513159
w.widget.Move2(x, y)
31523160

31533161
}

editor/screen_darwin.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package editor
2+
3+
/*
4+
#cgo CFLAGS: -x objective-c
5+
#cgo LDFLAGS: -framework Cocoa
6+
#import <Cocoa/Cocoa.h>
7+
8+
void setNoButtonWindow(long *wid) {
9+
NSView* view = (NSView*)wid;
10+
NSWindow *window = view.window;
11+
12+
// Style
13+
window.styleMask |= NSWindowStyleMaskTitled;
14+
window.styleMask |= NSWindowStyleMaskResizable;
15+
window.styleMask |= NSWindowStyleMaskMiniaturizable;
16+
window.styleMask |= NSWindowStyleMaskFullSizeContentView;
17+
18+
// Appearance
19+
window.opaque = NO;
20+
window.backgroundColor = [NSColor clearColor];
21+
window.hasShadow = YES;
22+
23+
// Don't show title bar
24+
window.titlebarAppearsTransparent = YES;
25+
// window.titleVisibility = NSWindowTitleHidden;
26+
27+
// Hidden native buttons
28+
[[window standardWindowButton:NSWindowCloseButton] setHidden:YES];
29+
[[window standardWindowButton:NSWindowMiniaturizeButton] setHidden:YES];
30+
[[window standardWindowButton:NSWindowZoomButton] setHidden:YES];
31+
return;
32+
}
33+
34+
*/
35+
import "C"
36+
37+
import (
38+
"unsafe"
39+
)
40+
41+
func createExternalWin() *ExternalWin {
42+
extwin := NewExternalWin(nil, 0)
43+
extwin.SetContentsMargins(5, 5, 5, 5)
44+
wid := extwin.WinId()
45+
46+
C.setNoButtonWindow((*C.long)(unsafe.Pointer(wid)))
47+
48+
return extwin
49+
}

editor/screen_linux.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package editor
2+
3+
func createExternalWin() *ExternalWin {
4+
extwin := NewExternalWin(nil, 0)
5+
6+
extwin.SetWindowFlag(core.Qt__WindowMaximizeButtonHint, false)
7+
extwin.SetWindowFlag(core.Qt__WindowMinimizeButtonHint, false)
8+
extwin.SetWindowFlag(core.Qt__WindowCloseButtonHint, false)
9+
extwin.SetWindowFlag(core.Qt__WindowContextHelpButtonHint, false)
10+
11+
return extwin
12+
}
13+

editor/screen_windows.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package editor
2+
3+
func createExternalWin() *ExternalWin {
4+
extwin := NewExternalWin(nil, 0)
5+
6+
extwin.SetWindowFlag(core.Qt__WindowMaximizeButtonHint, false)
7+
extwin.SetWindowFlag(core.Qt__WindowMinimizeButtonHint, false)
8+
extwin.SetWindowFlag(core.Qt__WindowCloseButtonHint, false)
9+
extwin.SetWindowFlag(core.Qt__WindowContextHelpButtonHint, false)
10+
11+
return extwin
12+
}

0 commit comments

Comments
 (0)