Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/linux warnings #1656

Merged
merged 8 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
7 changes: 3 additions & 4 deletions v2/internal/appng/app_production.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,14 @@ type App struct {
}

func (a *App) Shutdown() {
if a.shutdownCallback != nil {
a.shutdownCallback(a.ctx)
}
a.frontend.Quit()
}

func (a *App) Run() error {
err := a.frontend.Run(a.ctx)
a.Shutdown()
if a.shutdownCallback != nil {
a.shutdownCallback(a.ctx)
}
leaanthony marked this conversation as resolved.
Show resolved Hide resolved
return err
}

Expand Down
27 changes: 25 additions & 2 deletions v2/internal/frontend/desktop/linux/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,27 @@ GdkMonitor* getCurrentMonitor(GtkWindow *window) {
// Get the monitor that the window is currently on
GdkDisplay *display = gtk_widget_get_display(GTK_WIDGET(window));
GdkWindow *gdk_window = gtk_widget_get_window(GTK_WIDGET(window));
if( gdk_window == NULL ) {
return NULL;
}
GdkMonitor *monitor = gdk_display_get_monitor_at_window(display, gdk_window);

return GDK_MONITOR(monitor);
}

bool isNULLRectangle(GdkRectangle input) {
return input.x == -1 && input.y == -1 && input.width == -1 && input.height == -1;
}

GdkRectangle getCurrentMonitorGeometry(GtkWindow *window) {
GdkMonitor *monitor = getCurrentMonitor(window);
GdkRectangle result;
if( monitor == NULL ) {
result.x = result.y = result.height = result.width = -1;
return result;
}

// Get the geometry of the monitor
GdkRectangle result;
gdk_monitor_get_geometry (monitor,&result);
return result;
}
Expand All @@ -63,7 +74,10 @@ static void SetMinMaxSize(GtkWindow* window, int min_width, int min_height, int
size.min_width = size.min_height = size.max_width = size.max_height = 0;

GdkRectangle monitorSize = getCurrentMonitorGeometry(window);
int flags = GDK_HINT_MAX_SIZE | GDK_HINT_MIN_SIZE;
if( isNULLRectangle(monitorSize) ) {
return;
Copy link
Collaborator

@stffabi stffabi Jul 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure, do we still apply the constraints for a minimum or maximum in the options.Options?

IIRC the call to SetMinMaxSize for those is also very early and if the monitorSize couldn't be determined we would skip applying the constraints.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't confirm tonight but it's interesting it worked at all with a null window. Potentially we'll need to hook on the "present"(?) Signal.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the fix may cause issues with fullscreen.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can confirm min/max options do not get set on this branch.

}
int flags = GDK_HINT_MAX_SIZE | GDK_HINT_MIN_SIZE;
size.max_height = (max_height == 0 ? monitorSize.height : max_height);
size.max_width = (max_width == 0 ? monitorSize.width : max_width);
size.min_height = min_height;
Expand All @@ -76,6 +90,9 @@ gboolean Center(gpointer data) {

// Get the geometry of the monitor
GdkRectangle m = getCurrentMonitorGeometry(window);
if( isNULLRectangle(m) ) {
return G_SOURCE_REMOVE;
}

// Get the window width/height
int windowWidth, windowHeight;
Expand Down Expand Up @@ -478,6 +495,9 @@ gboolean setPosition(gpointer data) {

void SetPosition(void* window, int x, int y) {
GdkRectangle monitorDimensions = getCurrentMonitorGeometry(window);
if( isNULLRectangle(monitorDimensions) ) {
return;
}
SetPositionArgs* args = malloc(sizeof(SetPositionArgs));
args->window = window;
args->x = monitorDimensions.x + x;
Expand Down Expand Up @@ -526,6 +546,9 @@ gboolean Fullscreen(gpointer data) {

// Get the geometry of the monitor.
GdkRectangle m = getCurrentMonitorGeometry(window);
if( isNULLRectangle(m) ) {
return G_SOURCE_REMOVE;
}
int scale = getCurrentMonitorScaleFactor(window);
SetMinMaxSize(window, 0, 0, m.width * scale, m.height * scale);

Expand Down