mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-04-13 09:08:06 -05:00
Replace deprecated GDK_DISPLAY() with modern facilities.
We still don't actually support more than one X display active at once, so it's sufficient to replace every call to that macro with GDK_DISPLAY_XDISPLAY(gdk_display_get_default()).
This commit is contained in:
parent
5319c659ad
commit
1b3b993467
@ -76,6 +76,12 @@
|
||||
#define gtk_widget_get_realized(w) GTK_WIDGET_REALIZED(w)
|
||||
#define gtk_widget_get_state(w) GTK_WIDGET_STATE(w)
|
||||
|
||||
/* This is a bit of a bodge because it relies on us only calling this
|
||||
* macro as GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), so under
|
||||
* GTK1 it makes sense to omit the contained function call and just
|
||||
* return the GDK default display. */
|
||||
#define GDK_DISPLAY_XDISPLAY(x) GDK_DISPLAY()
|
||||
|
||||
#define GDK_KEY_Alt_L GDK_Alt_L
|
||||
#define GDK_KEY_Alt_R GDK_Alt_R
|
||||
#define GDK_KEY_BackSpace GDK_BackSpace
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "putty.h"
|
||||
#include "gtkfont.h"
|
||||
#include "gtkcompat.h"
|
||||
#include "tree234.h"
|
||||
|
||||
/*
|
||||
@ -218,7 +219,7 @@ static const struct unifont_vtable x11font_vtable = {
|
||||
|
||||
static char *x11_guess_derived_font_name(XFontStruct *xfs, int bold, int wide)
|
||||
{
|
||||
Display *disp = GDK_DISPLAY();
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
Atom fontprop = XInternAtom(disp, "FONT", False);
|
||||
unsigned long ret;
|
||||
if (XGetFontProperty(xfs, fontprop, &ret)) {
|
||||
@ -349,7 +350,7 @@ static unifont *x11font_create(GtkWidget *widget, const char *name,
|
||||
{
|
||||
struct x11font *xfont;
|
||||
XFontStruct *xfs;
|
||||
Display *disp = GDK_DISPLAY();
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
Atom charset_registry, charset_encoding, spacing;
|
||||
unsigned long registry_ret, encoding_ret, spacing_ret;
|
||||
int pubcs, realcs, sixteen_bit, variable;
|
||||
@ -455,7 +456,7 @@ static unifont *x11font_create(GtkWidget *widget, const char *name,
|
||||
|
||||
static void x11font_destroy(unifont *font)
|
||||
{
|
||||
Display *disp = GDK_DISPLAY();
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
struct x11font *xfont = (struct x11font *)font;
|
||||
int i;
|
||||
|
||||
@ -482,7 +483,7 @@ static void x11font_destroy(unifont *font)
|
||||
|
||||
static void x11_alloc_subfont(struct x11font *xfont, int sfid)
|
||||
{
|
||||
Display *disp = GDK_DISPLAY();
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
char *derived_name = x11_guess_derived_font_name
|
||||
(xfont->fonts[0].xfs, sfid & 1, !!(sfid & 2));
|
||||
xfont->fonts[sfid].xfs = XLoadQueryFont(disp, derived_name);
|
||||
@ -539,15 +540,17 @@ static int x11font_width_8(unifont_drawctx *ctx, x11font_individual *xfi,
|
||||
#ifdef DRAW_TEXT_GDK
|
||||
static void x11font_gdk_setup(unifont_drawctx *ctx, x11font_individual *xfi)
|
||||
{
|
||||
XSetFont(GDK_DISPLAY(), GDK_GC_XGC(ctx->u.gdk.gc), xfi->xfs->fid);
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
XSetFont(disp, GDK_GC_XGC(ctx->u.gdk.gc), xfi->xfs->fid);
|
||||
}
|
||||
|
||||
static void x11font_gdk_draw_16(unifont_drawctx *ctx,
|
||||
x11font_individual *xfi, int x, int y,
|
||||
const void *vstring, int start, int length)
|
||||
{
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
const XChar2b *string = (const XChar2b *)vstring;
|
||||
XDrawString16(GDK_DISPLAY(), GDK_DRAWABLE_XID(ctx->u.gdk.target),
|
||||
XDrawString16(disp, GDK_DRAWABLE_XID(ctx->u.gdk.target),
|
||||
GDK_GC_XGC(ctx->u.gdk.gc), x, y, string+start, length);
|
||||
}
|
||||
|
||||
@ -555,8 +558,9 @@ static void x11font_gdk_draw_8(unifont_drawctx *ctx,
|
||||
x11font_individual *xfi, int x, int y,
|
||||
const void *vstring, int start, int length)
|
||||
{
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
const char *string = (const char *)vstring;
|
||||
XDrawString(GDK_DISPLAY(), GDK_DRAWABLE_XID(ctx->u.gdk.target),
|
||||
XDrawString(disp, GDK_DRAWABLE_XID(ctx->u.gdk.target),
|
||||
GDK_GC_XGC(ctx->u.gdk.gc), x, y, string+start, length);
|
||||
}
|
||||
#endif
|
||||
@ -565,6 +569,7 @@ static void x11font_gdk_draw_8(unifont_drawctx *ctx,
|
||||
static void x11font_cairo_setup(unifont_drawctx *ctx, x11font_individual *xfi)
|
||||
{
|
||||
if (xfi->pixmap == None) {
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
XGCValues gcvals;
|
||||
GdkWindow *widgetwin = gtk_widget_get_window(ctx->u.cairo.widget);
|
||||
int widgetscr = GDK_SCREEN_XNUMBER(gdk_window_get_screen(widgetwin));
|
||||
@ -597,13 +602,13 @@ static void x11font_cairo_setup(unifont_drawctx *ctx, x11font_individual *xfi)
|
||||
}
|
||||
|
||||
xfi->pixmap = XCreatePixmap
|
||||
(GDK_DISPLAY(),
|
||||
(disp,
|
||||
GDK_DRAWABLE_XID(gtk_widget_get_window(ctx->u.cairo.widget)),
|
||||
xfi->pixwidth, xfi->pixheight, 1);
|
||||
gcvals.foreground = WhitePixel(GDK_DISPLAY(), widgetscr);
|
||||
gcvals.background = BlackPixel(GDK_DISPLAY(), widgetscr);
|
||||
gcvals.foreground = WhitePixel(disp, widgetscr);
|
||||
gcvals.background = BlackPixel(disp, widgetscr);
|
||||
gcvals.font = xfi->xfs->fid;
|
||||
xfi->gc = XCreateGC(GDK_DISPLAY(), xfi->pixmap,
|
||||
xfi->gc = XCreateGC(disp, xfi->pixmap,
|
||||
GCForeground | GCBackground | GCFont, &gcvals);
|
||||
}
|
||||
}
|
||||
@ -613,11 +618,12 @@ static void x11font_cairo_cache_glyph(x11font_individual *xfi, int glyphindex)
|
||||
XImage *image;
|
||||
int x, y;
|
||||
unsigned char *bitmap;
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
|
||||
bitmap = snewn(xfi->allsize, unsigned char);
|
||||
memset(bitmap, 0, xfi->allsize);
|
||||
|
||||
image = XGetImage(GDK_DISPLAY(), xfi->pixmap, 0, 0,
|
||||
image = XGetImage(disp, xfi->pixmap, 0, 0,
|
||||
xfi->pixwidth, xfi->pixheight, AllPlanes, XYPixmap);
|
||||
for (y = 0; y < xfi->pixheight; y++) {
|
||||
for (x = 0; x < xfi->pixwidth; x++) {
|
||||
@ -666,6 +672,7 @@ static void x11font_cairo_draw_16(unifont_drawctx *ctx,
|
||||
x11font_individual *xfi, int x, int y,
|
||||
const void *vstring, int start, int length)
|
||||
{
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
const XChar2b *string = (const XChar2b *)vstring + start;
|
||||
int i;
|
||||
for (i = 0; i < length; i++) {
|
||||
@ -674,7 +681,7 @@ static void x11font_cairo_draw_16(unifont_drawctx *ctx,
|
||||
(unsigned char)string[i].byte2);
|
||||
if (glyphindex >= xfi->nglyphs ||
|
||||
!xfi->glyphcache[glyphindex].surface) {
|
||||
XDrawImageString16(GDK_DISPLAY(), xfi->pixmap, xfi->gc,
|
||||
XDrawImageString16(disp, xfi->pixmap, xfi->gc,
|
||||
xfi->pixoriginx, xfi->pixoriginy,
|
||||
string+i, 1);
|
||||
x11font_cairo_cache_glyph(xfi, glyphindex);
|
||||
@ -689,6 +696,7 @@ static void x11font_cairo_draw_8(unifont_drawctx *ctx,
|
||||
x11font_individual *xfi, int x, int y,
|
||||
const void *vstring, int start, int length)
|
||||
{
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
const char *string = (const char *)vstring + start;
|
||||
int i;
|
||||
for (i = 0; i < length; i++) {
|
||||
@ -696,7 +704,7 @@ static void x11font_cairo_draw_8(unifont_drawctx *ctx,
|
||||
int glyphindex = (unsigned char)string[i];
|
||||
if (glyphindex >= xfi->nglyphs ||
|
||||
!xfi->glyphcache[glyphindex].surface) {
|
||||
XDrawImageString(GDK_DISPLAY(), xfi->pixmap, xfi->gc,
|
||||
XDrawImageString(disp, xfi->pixmap, xfi->gc,
|
||||
xfi->pixoriginx, xfi->pixoriginy,
|
||||
string+i, 1);
|
||||
x11font_cairo_cache_glyph(xfi, glyphindex);
|
||||
@ -866,13 +874,14 @@ static void x11font_draw_text(unifont_drawctx *ctx, unifont *font,
|
||||
static void x11font_enum_fonts(GtkWidget *widget,
|
||||
fontsel_add_entry callback, void *callback_ctx)
|
||||
{
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
char **fontnames;
|
||||
char *tmp = NULL;
|
||||
int nnames, i, max, tmpsize;
|
||||
|
||||
max = 32768;
|
||||
while (1) {
|
||||
fontnames = XListFonts(GDK_DISPLAY(), "*", max, &nnames);
|
||||
fontnames = XListFonts(disp, "*", max, &nnames);
|
||||
if (nnames >= max) {
|
||||
XFreeFontNames(fontnames);
|
||||
max *= 2;
|
||||
@ -1047,7 +1056,7 @@ static char *x11font_canonify_fontname(GtkWidget *widget, const char *name,
|
||||
* selector treats them as worthwhile in their own right.
|
||||
*/
|
||||
XFontStruct *xfs;
|
||||
Display *disp = GDK_DISPLAY();
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
Atom fontprop, fontprop2;
|
||||
unsigned long ret;
|
||||
|
||||
|
@ -153,7 +153,8 @@ static void exit_callback(void *vinst);
|
||||
char *x_get_default(const char *key)
|
||||
{
|
||||
#ifndef NOT_X_WINDOWS
|
||||
return XGetDefault(GDK_DISPLAY(), app_name, key);
|
||||
return XGetDefault(GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
|
||||
app_name, key);
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
@ -1868,21 +1869,22 @@ void init_cutbuffers()
|
||||
{
|
||||
#ifndef NOT_X_WINDOWS
|
||||
unsigned char empty[] = "";
|
||||
XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
XChangeProperty(disp, GDK_ROOT_WINDOW(),
|
||||
XA_CUT_BUFFER0, XA_STRING, 8, PropModeAppend, empty, 0);
|
||||
XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
|
||||
XChangeProperty(disp, GDK_ROOT_WINDOW(),
|
||||
XA_CUT_BUFFER1, XA_STRING, 8, PropModeAppend, empty, 0);
|
||||
XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
|
||||
XChangeProperty(disp, GDK_ROOT_WINDOW(),
|
||||
XA_CUT_BUFFER2, XA_STRING, 8, PropModeAppend, empty, 0);
|
||||
XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
|
||||
XChangeProperty(disp, GDK_ROOT_WINDOW(),
|
||||
XA_CUT_BUFFER3, XA_STRING, 8, PropModeAppend, empty, 0);
|
||||
XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
|
||||
XChangeProperty(disp, GDK_ROOT_WINDOW(),
|
||||
XA_CUT_BUFFER4, XA_STRING, 8, PropModeAppend, empty, 0);
|
||||
XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
|
||||
XChangeProperty(disp, GDK_ROOT_WINDOW(),
|
||||
XA_CUT_BUFFER5, XA_STRING, 8, PropModeAppend, empty, 0);
|
||||
XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
|
||||
XChangeProperty(disp, GDK_ROOT_WINDOW(),
|
||||
XA_CUT_BUFFER6, XA_STRING, 8, PropModeAppend, empty, 0);
|
||||
XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
|
||||
XChangeProperty(disp, GDK_ROOT_WINDOW(),
|
||||
XA_CUT_BUFFER7, XA_STRING, 8, PropModeAppend, empty, 0);
|
||||
#endif
|
||||
}
|
||||
@ -1891,9 +1893,10 @@ void init_cutbuffers()
|
||||
void store_cutbuffer(char * ptr, int len)
|
||||
{
|
||||
#ifndef NOT_X_WINDOWS
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
/* ICCCM says we must rotate the buffers before storing to buffer 0. */
|
||||
XRotateBuffers(GDK_DISPLAY(), 1);
|
||||
XStoreBytes(GDK_DISPLAY(), ptr, len);
|
||||
XRotateBuffers(disp, 1);
|
||||
XStoreBytes(disp, ptr, len);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1903,8 +1906,9 @@ void store_cutbuffer(char * ptr, int len)
|
||||
char * retrieve_cutbuffer(int * nbytes)
|
||||
{
|
||||
#ifndef NOT_X_WINDOWS
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
char * ptr;
|
||||
ptr = XFetchBytes(GDK_DISPLAY(), nbytes);
|
||||
ptr = XFetchBytes(disp, nbytes);
|
||||
if (*nbytes <= 0 && ptr != 0) {
|
||||
XFree(ptr);
|
||||
ptr = 0;
|
||||
@ -1935,6 +1939,7 @@ void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_des
|
||||
#ifndef NOT_X_WINDOWS
|
||||
XTextProperty tp;
|
||||
char *list[1];
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
#endif
|
||||
|
||||
inst->pasteout_data_utf8 = snewn(len*6, char);
|
||||
@ -1958,7 +1963,7 @@ void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_des
|
||||
*/
|
||||
#ifndef NOT_X_WINDOWS
|
||||
list[0] = inst->pasteout_data_utf8;
|
||||
if (Xutf8TextListToTextProperty(GDK_DISPLAY(), list, 1,
|
||||
if (Xutf8TextListToTextProperty(disp, list, 1,
|
||||
XCompoundTextStyle, &tp) == 0) {
|
||||
inst->pasteout_data_ctext = snewn(tp.nitems+1, char);
|
||||
memcpy(inst->pasteout_data_ctext, tp.value, tp.nitems);
|
||||
@ -2157,13 +2162,13 @@ void selection_received(GtkWidget *widget, GtkSelectionData *seldata,
|
||||
#ifndef NOT_X_WINDOWS
|
||||
XTextProperty tp;
|
||||
int ret, count;
|
||||
Display *disp = GDK_DISPLAY_XDISPLAY(gdk_display_get_default());
|
||||
|
||||
tp.value = (unsigned char *)seldata_data;
|
||||
tp.encoding = (Atom) seldata_type;
|
||||
tp.format = gtk_selection_data_get_format(seldata);
|
||||
tp.nitems = seldata_length;
|
||||
ret = Xutf8TextPropertyToTextList(GDK_DISPLAY(), &tp,
|
||||
&list, &count);
|
||||
ret = Xutf8TextPropertyToTextList(disp, &tp, &list, &count);
|
||||
if (ret == 0 && count == 1) {
|
||||
text = list[0];
|
||||
length = strlen(list[0]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user