X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=unix%2Fgtkask.c;h=c2b582e9c9afe29e29a2d0befaf5c6dd3453ecca;hb=095072fa46b2d7b8beafaddb2f873d2f500a1e10;hp=e5439bbb172c8b5e743f9f78218e8c5a0f44ecb3;hpb=8fdeb3a95cc3d7dce5629fc22e309eb3c996f44d;p=PuTTY.git diff --git a/unix/gtkask.c b/unix/gtkask.c index e5439bbb..c2b582e9 100644 --- a/unix/gtkask.c +++ b/unix/gtkask.c @@ -43,7 +43,9 @@ struct askpass_ctx { #endif char *passphrase; int passlen, passsize; -#if GTK_CHECK_VERSION(3,0,0) +#if GTK_CHECK_VERSION(3,20,0) + GdkSeat *seat; /* for gdk_seat_grab */ +#elif GTK_CHECK_VERSION(3,0,0) GdkDevice *keyboard; /* for gdk_device_grab */ #endif }; @@ -218,9 +220,25 @@ static int try_grab_keyboard(struct askpass_ctx *ctx) { int ret; -#if GTK_CHECK_VERSION(3,0,0) +#if GTK_CHECK_VERSION(3,20,0) /* - * Grabbing the keyboard is quite complicated in GTK 3. + * Grabbing the keyboard in GTK 3.20 requires the new notion of + * GdkSeat. + */ + GdkSeat *seat; + + seat = gdk_display_get_default_seat + (gtk_widget_get_display(ctx->dialog)); + if (!seat) + return FALSE; + + ctx->seat = seat; + ret = gdk_seat_grab(seat, gtk_widget_get_window(ctx->dialog), + GDK_SEAT_CAPABILITY_KEYBOARD, + TRUE, NULL, NULL, NULL, NULL); +#elif GTK_CHECK_VERSION(3,0,0) + /* + * And it has to be done differently again prior to GTK 3.20. */ GdkDeviceManager *dm; GdkDevice *pointer, *keyboard; @@ -357,6 +375,12 @@ static const char *gtk_askpass_setup(struct askpass_ctx *ctx, G_CALLBACK(expose_area), &ctx->drawingareas[i]); #endif + +#if GTK_CHECK_VERSION(3,0,0) + g_object_set(G_OBJECT(ctx->drawingareas[i].area), + "margin-bottom", 8, (const char *)NULL); +#endif + gtk_widget_show(ctx->drawingareas[i].area); } ctx->active_area = rand() % N_DRAWING_AREAS; @@ -409,7 +433,9 @@ static const char *gtk_askpass_setup(struct askpass_ctx *ctx, static void gtk_askpass_cleanup(struct askpass_ctx *ctx) { -#if GTK_CHECK_VERSION(3,0,0) +#if GTK_CHECK_VERSION(3,20,0) + gdk_seat_ungrab(ctx->seat); +#elif GTK_CHECK_VERSION(3,0,0) gdk_device_ungrab(ctx->keyboard, GDK_CURRENT_TIME); #else gdk_keyboard_ungrab(GDK_CURRENT_TIME);