ocarina: Capture window resizing
I store the new size of the window in the preferences and use it the next time ocarina starts up. Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
parent
292d237561
commit
5c618de4df
|
@ -22,6 +22,25 @@ static void destroy(GtkWidget *widget, GdkEvent *event, gpointer data)
|
|||
{
|
||||
ocarina::quit();
|
||||
}
|
||||
|
||||
static void configure(GtkWidget *widget, GdkEvent *event, gpointer data)
|
||||
{
|
||||
int w, h;
|
||||
int x = libsaria::prefs::get("ocarina.window.w");
|
||||
int y = libsaria::prefs::get("ocarina.window.h");
|
||||
|
||||
gtk_window_get_size(GTK_WINDOW(win), &w, &h);
|
||||
if ( (w == x) && (h == y) )
|
||||
return;
|
||||
|
||||
if (w != x)
|
||||
libsaria::prefs::set("ocarina.window.w", w);
|
||||
if (h != y)
|
||||
libsaria::prefs::set("ocarina.window.h", h);
|
||||
|
||||
println("New (w,h): (%d, %d)", w, h);
|
||||
gtk_window_resize(GTK_WINDOW(win), w, h);
|
||||
}
|
||||
/*
|
||||
void window_resize(int w, int h)
|
||||
{
|
||||
|
@ -55,7 +74,9 @@ namespace ocarina
|
|||
void window::init()
|
||||
{
|
||||
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
g_signal_connect(win, "destroy", G_CALLBACK(destroy), NULL);
|
||||
g_signal_connect(win, "configure-event", G_CALLBACK(configure), NULL);
|
||||
|
||||
set_title("Ocarina " + vers_str());
|
||||
set_icon(full_path("images/ocarina.png"));
|
||||
|
|
Loading…
Reference in New Issue