Skip to content

Commit 4f2d83d

Browse files
authored
Merge branch 'v3-alpha' into v3-update-templates
2 parents 193984e + aa97009 commit 4f2d83d

File tree

6 files changed

+83
-41
lines changed

6 files changed

+83
-41
lines changed

v3/pkg/application/linux_cgo.go

+59-20
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,7 @@ func getScreenByIndex(display *C.struct__GdkDisplay, index int) *Screen {
779779
Height: int(geometry.height),
780780
Width: int(geometry.width),
781781
},
782+
Rotation: 0.0,
782783
}
783784
}
784785

@@ -852,16 +853,29 @@ func getMousePosition() (int, int, *Screen) {
852853
C.gdk_monitor_get_geometry(monitor, &geometry)
853854
scaleFactor := int(C.gdk_monitor_get_scale_factor(monitor))
854855
return int(x), int(y), &Screen{
855-
ID: fmt.Sprintf("%d", 0), // A unique identifier for the display
856-
Name: C.GoString(C.gdk_monitor_get_model(monitor)), // The name of the display
857-
ScaleFactor: float32(scaleFactor), // The scale factor of the display
858-
X: int(geometry.x), // The x-coordinate of the top-left corner of the rectangle
859-
Y: int(geometry.y), // The y-coordinate of the top-left corner of the rectangle
860-
Size: Size{Width: int(geometry.width), Height: int(geometry.height)}, // The size of the display
861-
Bounds: Rect{}, // The bounds of the display
862-
WorkArea: Rect{}, // The work area of the display
863-
IsPrimary: false, // Whether this is the primary display
864-
Rotation: 0.0, // The rotation of the display
856+
ID: fmt.Sprintf("%d", 0), // A unique identifier for the display
857+
Name: C.GoString(C.gdk_monitor_get_model(monitor)), // The name of the display
858+
ScaleFactor: float32(scaleFactor), // The scale factor of the display
859+
X: int(geometry.x), // The x-coordinate of the top-left corner of the rectangle
860+
Y: int(geometry.y), // The y-coordinate of the top-left corner of the rectangle
861+
Size: Size{
862+
Height: int(geometry.height),
863+
Width: int(geometry.width),
864+
},
865+
Bounds: Rect{
866+
X: int(geometry.x),
867+
Y: int(geometry.y),
868+
Height: int(geometry.height),
869+
Width: int(geometry.width),
870+
},
871+
WorkArea: Rect{
872+
X: int(geometry.x),
873+
Y: int(geometry.y),
874+
Height: int(geometry.height),
875+
Width: int(geometry.width),
876+
},
877+
IsPrimary: false,
878+
Rotation: 0.0,
865879
}
866880
}
867881

@@ -905,16 +919,41 @@ func (w *linuxWebviewWindow) getScreen() (*Screen, error) {
905919
name := C.gdk_monitor_get_model(monitor)
906920
mx, my, width, height, scaleFactor := w.getCurrentMonitorGeometry()
907921
return &Screen{
908-
ID: fmt.Sprintf("%d", w.id), // A unique identifier for the display
909-
Name: C.GoString(name), // The name of the display
910-
ScaleFactor: float32(scaleFactor), // The scale factor of the display
911-
X: mx, // The x-coordinate of the top-left corner of the rectangle
912-
Y: my, // The y-coordinate of the top-left corner of the rectangle
913-
Size: Size{Width: width, Height: height}, // The size of the display
914-
Bounds: Rect{}, // The bounds of the display
915-
WorkArea: Rect{}, // The work area of the display
916-
IsPrimary: false, // Whether this is the primary display
917-
Rotation: 0.0, // The rotation of the display
922+
ID: fmt.Sprintf("%d", w.id), // A unique identifier for the display
923+
Name: C.GoString(name), // The name of the display
924+
ScaleFactor: float32(scaleFactor), // The scale factor of the display
925+
X: mx, // The x-coordinate of the top-left corner of the rectangle
926+
Y: my, // The y-coordinate of the top-left corner of the rectangle
927+
Size: Size{
928+
Height: int(height),
929+
Width: int(width),
930+
},
931+
Bounds: Rect{
932+
X: int(mx),
933+
Y: int(my),
934+
Height: int(height),
935+
Width: int(width),
936+
},
937+
WorkArea: Rect{
938+
X: int(mx),
939+
Y: int(my),
940+
Height: int(height),
941+
Width: int(width),
942+
},
943+
PhysicalBounds: Rect{
944+
X: int(mx),
945+
Y: int(my),
946+
Height: int(height),
947+
Width: int(width),
948+
},
949+
PhysicalWorkArea: Rect{
950+
X: int(mx),
951+
Y: int(my),
952+
Height: int(height),
953+
Width: int(width),
954+
},
955+
IsPrimary: false,
956+
Rotation: 0.0,
918957
}, nil
919958
}
920959

v3/pkg/application/menuitem_darwin.go

+14-6
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ void* newMenuItem(unsigned int menuItemID, char *label, bool disabled, char* too
4848
4949
// set menu item label
5050
void setMenuItemLabel(void* nsMenuItem, char *label) {
51-
MenuItem *menuItem = (MenuItem *)nsMenuItem;
52-
menuItem.title = [NSString stringWithUTF8String:label];
51+
dispatch_async(dispatch_get_main_queue(), ^{
52+
MenuItem *menuItem = (MenuItem *)nsMenuItem;
53+
menuItem.title = [NSString stringWithUTF8String:label];
54+
free(label);
55+
});
5356
}
5457
5558
// set menu item disabled
@@ -76,14 +79,19 @@ void setMenuItemHidden(void* nsMenuItem, bool hidden) {
7679
7780
// set menu item tooltip
7881
void setMenuItemTooltip(void* nsMenuItem, char *tooltip) {
79-
MenuItem *menuItem = (MenuItem *)nsMenuItem;
80-
menuItem.toolTip = [NSString stringWithUTF8String:tooltip];
82+
dispatch_async(dispatch_get_main_queue(), ^{
83+
MenuItem *menuItem = (MenuItem *)nsMenuItem;
84+
menuItem.toolTip = [NSString stringWithUTF8String:tooltip];
85+
free(tooltip);
86+
});
8187
}
8288
8389
// Check menu item
8490
void setMenuItemChecked(void* nsMenuItem, bool checked) {
85-
MenuItem *menuItem = (MenuItem *)nsMenuItem;
86-
menuItem.state = checked ? NSControlStateValueOn : NSControlStateValueOff;
91+
dispatch_async(dispatch_get_main_queue(), ^{
92+
MenuItem *menuItem = (MenuItem *)nsMenuItem;
93+
menuItem.state = checked ? NSControlStateValueOn : NSControlStateValueOff;
94+
});
8795
}
8896
8997
NSString* translateKey(NSString* key) {

v3/pkg/application/menuitem_darwin.h

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#ifndef MenuItemDelegate_h
32
#define MenuItemDelegate_h
43

v3/pkg/application/webview_window_darwin.m

+7-13
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ - (NSString *)keyStringFromEvent:(NSEvent *)event {
162162
case 24: return @"=";
163163
case 50: return @"`";
164164
case 42: return @"\\";
165+
165166
default: return @"";
166167
}
167168
}
@@ -283,14 +284,13 @@ - (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenP
283284
return proposedOptions | NSApplicationPresentationAutoHideToolbar;
284285
}
285286
}
286-
- (void)windowDidChangeVisibility:(NSNotification *)notification {
287+
- (void)windowDidChangeOcclusionState:(NSNotification *)notification {
287288
NSWindow *window = notification.object;
288-
BOOL isVisible = ![window isVisible];
289+
BOOL isVisible = ([window occlusionState] & NSWindowOcclusionStateVisible) != 0;
289290
if (hasListeners(isVisible ? EventWindowShow : EventWindowHide)) {
290291
processWindowEvent(self.windowId, isVisible ? EventWindowShow : EventWindowHide);
291292
}
292293
}
293-
// GENERATED EVENTS START
294294
- (void)windowDidBecomeKey:(NSNotification *)notification {
295295
if( hasListeners(EventWindowDidBecomeKey) ) {
296296
processWindowEvent(self.windowId, EventWindowDidBecomeKey);
@@ -339,12 +339,6 @@ - (void)windowDidChangeEffectiveAppearance:(NSNotification *)notification {
339339
}
340340
}
341341

342-
- (void)windowDidChangeOcclusionState:(NSNotification *)notification {
343-
if( hasListeners(EventWindowDidChangeOcclusionState) ) {
344-
processWindowEvent(self.windowId, EventWindowDidChangeOcclusionState);
345-
}
346-
}
347-
348342
- (void)windowDidChangeOrderingMode:(NSNotification *)notification {
349343
if( hasListeners(EventWindowDidChangeOrderingMode) ) {
350344
processWindowEvent(self.windowId, EventWindowDidChangeOrderingMode);
@@ -747,25 +741,25 @@ - (void)windowHide:(NSNotification *)notification {
747741
}
748742
}
749743

750-
- (void)webView:(WKWebView *)webview didStartProvisionalNavigation:(WKNavigation *)navigation {
744+
- (void)webView:(nonnull WKWebView *)webview didStartProvisionalNavigation:(WKNavigation *)navigation {
751745
if( hasListeners(EventWebViewDidStartProvisionalNavigation) ) {
752746
processWindowEvent(self.windowId, EventWebViewDidStartProvisionalNavigation);
753747
}
754748
}
755749

756-
- (void)webView:(WKWebView *)webview didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation {
750+
- (void)webView:(nonnull WKWebView *)webview didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation {
757751
if( hasListeners(EventWebViewDidReceiveServerRedirectForProvisionalNavigation) ) {
758752
processWindowEvent(self.windowId, EventWebViewDidReceiveServerRedirectForProvisionalNavigation);
759753
}
760754
}
761755

762-
- (void)webView:(WKWebView *)webview didFinishNavigation:(WKNavigation *)navigation {
756+
- (void)webView:(nonnull WKWebView *)webview didFinishNavigation:(WKNavigation *)navigation {
763757
if( hasListeners(EventWebViewDidFinishNavigation) ) {
764758
processWindowEvent(self.windowId, EventWebViewDidFinishNavigation);
765759
}
766760
}
767761

768-
- (void)webView:(WKWebView *)webview didCommitNavigation:(WKNavigation *)navigation {
762+
- (void)webView:(nonnull WKWebView *)webview didCommitNavigation:(WKNavigation *)navigation {
769763
if( hasListeners(EventWebViewDidCommitNavigation) ) {
770764
processWindowEvent(self.windowId, EventWebViewDidCommitNavigation);
771765
}

v3/pkg/events/defaults.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ var defaultWindowEventMapping = map[string]map[WindowEventType]WindowEventType{
3333
Mac.WindowUnMaximise: Common.WindowUnMaximise,
3434
Mac.WindowDidMove: Common.WindowDidMove,
3535
Mac.WindowDidResize: Common.WindowDidResize,
36-
Mac.WindowDidUpdate: Common.WindowShow,
3736
Mac.WindowDidZoom: Common.WindowMaximise,
37+
Mac.WindowShow: Common.WindowShow,
38+
Mac.WindowHide: Common.WindowHide,
3839
Mac.WindowZoomIn: Common.WindowZoomIn,
3940
Mac.WindowZoomOut: Common.WindowZoomOut,
4041
Mac.WindowZoomReset: Common.WindowZoomReset,

v3/pkg/w32/screen.go

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func getMonitorName(deviceName string) (string, error) {
3939
if device.StateFlags&0x1 != 0 {
4040
return syscall.UTF16ToString(device.DeviceString[:]), nil
4141
}
42+
i++
4243
}
4344

4445
return "", fmt.Errorf("monitor name not found for device: %s", deviceName)

0 commit comments

Comments
 (0)