Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bitsdojo_window_linux/lib/src/native_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ typedef Void TSetWindowTitle(IntPtr window, Pointer<Utf8> title);
typedef DSetWindowTitle = void Function(int window, Pointer<Utf8> title);
final DSetWindowTitle setWindowTitle = _theAPI.ref.setWindowTitle.asFunction();

// setTopmost
typedef Void TSetTopmost(IntPtr window, Int32 topmost);
typedef DSetTopmost = void Function(int window, int topmost);
final DSetTopmost setTopmost = _theAPI.ref.setTopMost.asFunction();

class BDWAPI extends Struct {
external Pointer<NativeFunction<TGetAppWindowHandle>> getAppWindowHandle;
external Pointer<NativeFunction<TGetScreenRect>> getScreenRect;
Expand All @@ -110,6 +115,7 @@ class BDWAPI extends Struct {
external Pointer<NativeFunction<TMaximizeWindow>> maximizeWindow;
external Pointer<NativeFunction<TUnmaximizeWindow>> unmaximizeWindow;
external Pointer<NativeFunction<TSetWindowTitle>> setWindowTitle;
external Pointer<NativeFunction<TSetTopmost>> setTopMost;
}

typedef Pointer<BDWAPI> TBitsdojoWindowAPI();
Expand Down
6 changes: 6 additions & 0 deletions bitsdojo_window_linux/lib/src/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ class GtkWindow extends DesktopWindow {
handle!, _maxSize!.width.toInt(), _maxSize!.height.toInt());
}

@override
set topmost(bool topmost) {
if (!isValidHandle(handle, "set topmost")) return;
native.setTopmost(handle!, topmost ? 1 : 0);
}

@override
set size(Size newSize) {
if (!isValidHandle(handle, "set size")) return;
Expand Down
3 changes: 2 additions & 1 deletion bitsdojo_window_linux/linux/api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ BDWAPI _theAPI = {
minimizeWindow,
maximizeWindow,
unmaximizeWindow,
setWindowTitle
setWindowTitle,
setTopmost
};

} // namespace bitsdojo_window
Expand Down
1 change: 1 addition & 0 deletions bitsdojo_window_linux/linux/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ typedef struct _BDWAPI {
TMaximizeWindow maximizeWindow;
TUnmaximizeWindow unmaximizeWindow;
TSetWindowTitle setWindowTitle;
TSetTopmost setTopmost;
} BDWAPI;

} // namespace bitsdojo_window
Expand Down
4 changes: 4 additions & 0 deletions bitsdojo_window_linux/linux/api_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,8 @@ void setWindowTitle(GtkWindow* window, const gchar* title) {
g_idle_add_full(G_PRIORITY_HIGH_IDLE, setWindowTitleProc, params, NULL);
}

void setTopmost(GtkWindow* window, int topmost){
gtk_window_set_keep_above(window,topmost == 1 ? TRUE : FALSE);
}

} // namespace bitsdojo_window
3 changes: 3 additions & 0 deletions bitsdojo_window_linux/linux/api_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ namespace bitsdojo_window {

typedef void (*TSetWindowTitle)(GtkWindow*, const gchar *);
void setWindowTitle(GtkWindow* window, const gchar *title);

typedef void (*TSetTopmost)(GtkWindow*, int);
void setTopmost(GtkWindow* window,int topmost);
}

#endif // _BDW_API_IMPL_
6 changes: 6 additions & 0 deletions bitsdojo_window_macos/lib/src/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -238,4 +238,10 @@ class MacOSWindow extends DesktopWindow {
if (!isValidHandle(handle, "maximizeOrRestore")) return;
maximizeOrRestoreWindow(handle!);
}

@override
set topmost(bool topmost) {
// TODO: implement topmost
throw UnimplementedError();
}
}
2 changes: 2 additions & 0 deletions bitsdojo_window_platform_interface/lib/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ abstract class DesktopWindow {
set minSize(Size? newSize);
set maxSize(Size? newSize);

set topmost(bool topmost);

Alignment? get alignment;
set alignment(Alignment? newAlignment);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class NotImplementedWindow extends DesktopWindow {
throw UnimplementedError('maxSize setter has not been implemented.');
}

set topmost(bool toomost) {
throw UnimplementedError('topmost setter has not been implemented.');
}

Alignment get alignment {
throw UnimplementedError('alignment getter has not been implemented.');
}
Expand Down
7 changes: 7 additions & 0 deletions bitsdojo_window_windows/lib/src/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -293,4 +293,11 @@ class WinWindow extends WinDesktopWindow {
void startDragging() {
BitsdojoWindowPlatform.instance.dragAppWindow();
}

@override
set topmost(bool topmost) {
if (!isValidHandle(handle, "topmost")) return;

PostMessage(handle!, WM_USER + 1, topmost ? 1 : 0, 0);
}
}
Loading