cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to make modal dialog on stm32mp157c-dk2 ? #GTK #Wayland

La1
Associate III

I am building graphical app using GTK. I have code that make modal dialog and it works well on ubuntu, but on stm32mp1 it doesn't. Dialog appear ,but it is not modal (i can click outsite and it disapear, or move it around). I am doing something wrong or it is impossible to make this on stm32mp1?

Here is image from Ubuntu:

0690X00000DBm2dQAD.png

And here is the code:

#include <gtk/gtk.h>
 
static GtkWidget *window = NULL;
 
void openDialog()
{
	GtkWidget* dialog = gtk_dialog_new_with_buttons (
                   "Do you want to continue?",
                    GTK_WINDOW(window),
                    GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, 
                    "Yes",
                    GTK_RESPONSE_ACCEPT,
                    "Cancel",
                    GTK_RESPONSE_REJECT,
                    NULL);
	gtk_window_set_position(GTK_WINDOW(dialog),GTK_WIN_POS_CENTER);
	int result = gtk_dialog_run (dialog);
	gtk_widget_destroy (dialog);
	if(result==GTK_RESPONSE_ACCEPT)
	{
		//continuing
	} else {
		//canceling
	}
}
 
int main( int argc, char *argv[])
{
	gtk_init(&argc, &argv);
 
	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
	gtk_window_set_title (GTK_WINDOW (window), "Dialog example");
	gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
 
	gtk_container_set_border_width (GTK_CONTAINER (window), 8);
	
	GtkButton *button = gtk_button_new_with_label ("open dialog");
	g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(openDialog), NULL);
	
      
    gtk_container_add(GTK_CONTAINER(window), button);
 
	gtk_widget_show_all (window);
 
	gtk_main();
 
	return 0;
}

2 REPLIES 2
La1
Associate III

I build image based on x11 using distribution package, but still same problem.

Moreover modal window, don't work on STM32MP1, but when i enable X forwarding to my Ubuntu host PC it works great. So i think, maybe the problem is in window manager. On STM i have matchbox and on Ubuntu it is GNOME. Is there some way to change easily window manager ? I looked at local.conf and bblayers.conf, but couldn't find the way.

La1
Associate III

I finally managed to do this. I created own implementation of modal dialog using gtk_overlay and gtk_widget_set_sensitive(). Gtk overlay allows to display widget on top of another widget, and set_sensitive function makes sure that you cannot click outside dialog.