31
31
#include <string.h>
32
32
#include <stdlib.h>
34
#if GTK_CHECK_VERSION (3, 0, 0)
35
#include <cairo-xlib.h>
34
38
static void meta_ui_accelerator_parse(const char* accel, guint* keysym, guint* keycode, GdkModifierType* keymask);
117
#if GTK_CHECK_VERSION (3, 0, 0)
118
gdk_window = gdk_x11_window_lookup_for_display (gdisplay, window);
108
120
gdk_window = gdk_window_lookup_for_display (gdisplay, window);
109
122
if (gdk_window == NULL)
116
129
if (gdk_display_pointer_is_grabbed (gdisplay))
132
#if !GTK_CHECK_VERSION (3, 0, 0)
119
133
memset (&gevent, 0, sizeof (gevent));
121
136
switch (xevent->type)
139
154
ABS (xevent->xbutton.x - ui->button_click_x) <= double_click_distance &&
140
155
ABS (xevent->xbutton.y - ui->button_click_y) <= double_click_distance)
157
#if GTK_CHECK_VERSION (3, 0, 0)
158
gevent = gdk_event_new (GDK_2BUTTON_PRESS);
142
160
gevent.button.type = GDK_2BUTTON_PRESS;
144
163
ui->button_click_number = 0;
167
#if GTK_CHECK_VERSION (3, 0, 0)
168
gevent = gdk_event_new (GDK_BUTTON_PRESS);
148
170
gevent.button.type = GDK_BUTTON_PRESS;
149
172
ui->button_click_number = xevent->xbutton.button;
150
173
ui->button_click_window = xevent->xbutton.window;
151
174
ui->button_click_time = xevent->xbutton.time;
181
#if GTK_CHECK_VERSION (3, 0, 0)
182
gevent = gdk_event_new (GDK_BUTTON_RELEASE);
158
184
gevent.button.type = GDK_BUTTON_RELEASE;
188
#if GTK_CHECK_VERSION (3, 0, 0)
189
gevent->button.window = g_object_ref (gdk_window);
190
gevent->button.button = xevent->xbutton.button;
191
gevent->button.time = xevent->xbutton.time;
192
gevent->button.x = xevent->xbutton.x;
193
gevent->button.y = xevent->xbutton.y;
194
gevent->button.x_root = xevent->xbutton.x_root;
195
gevent->button.y_root = xevent->xbutton.y_root;
161
197
gevent.button.window = gdk_window;
162
198
gevent.button.button = xevent->xbutton.button;
163
199
gevent.button.time = xevent->xbutton.time;
165
201
gevent.button.y = xevent->xbutton.y;
166
202
gevent.button.x_root = xevent->xbutton.x_root;
167
203
gevent.button.y_root = xevent->xbutton.y_root;
170
207
case MotionNotify:
208
#if GTK_CHECK_VERSION (3, 0, 0)
209
gevent = gdk_event_new (GDK_MOTION_NOTIFY);
210
gevent->motion.type = GDK_MOTION_NOTIFY;
211
gevent->motion.window = g_object_ref (gdk_window);
171
213
gevent.motion.type = GDK_MOTION_NOTIFY;
172
214
gevent.motion.window = gdk_window;
174
217
case EnterNotify:
175
218
case LeaveNotify:
219
#if GTK_CHECK_VERSION (3, 0, 0)
220
gevent = gdk_event_new (xevent->type == EnterNotify ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY);
221
gevent->crossing.window = g_object_ref (gdk_window);
222
gevent->crossing.x = xevent->xcrossing.x;
223
gevent->crossing.y = xevent->xcrossing.y;
176
225
gevent.crossing.type = xevent->type == EnterNotify ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY;
177
226
gevent.crossing.window = gdk_window;
178
227
gevent.crossing.x = xevent->xcrossing.x;
179
228
gevent.crossing.y = xevent->xcrossing.y;
182
232
g_assert_not_reached ();
186
236
/* If we've gotten here, we've filled in the gdk_event and should send it on */
237
#if GTK_CHECK_VERSION (3, 0, 0)
238
gmanager = gdk_display_get_device_manager (gdisplay);
239
gdk_event_set_device (gevent, gdk_device_manager_get_client_pointer (gmanager)); gtk_main_do_event (gevent);
240
gdk_event_free (gevent);
187
242
gtk_main_do_event (&gevent);
304
360
gint attributes_mask;
305
361
GdkWindow *window;
306
362
GdkVisual *visual;
363
#if !GTK_CHECK_VERSION (3, 0, 0)
307
364
GdkColormap *cmap = gdk_screen_get_default_colormap (screen);
309
367
/* Default depth/visual handles clients with weird visuals; they can
310
368
* always be children of the root depth/visual obviously, but
318
376
visual = gdk_x11_screen_lookup_visual (screen,
319
377
XVisualIDFromVisual (xvisual));
378
#if !GTK_CHECK_VERSION (3, 0, 0)
320
379
cmap = gdk_colormap_new (visual, FALSE);
323
383
attrs.title = NULL;
334
394
attrs.wclass = GDK_INPUT_OUTPUT;
335
395
attrs.visual = visual;
396
#if !GTK_CHECK_VERSION (3, 0, 0)
336
397
attrs.colormap = cmap;
337
399
attrs.window_type = GDK_WINDOW_CHILD;
338
400
attrs.cursor = NULL;
339
401
attrs.wmclass_name = NULL;
343
405
attrs.width = width;
344
406
attrs.height = height;
408
#if GTK_CHECK_VERSION (3, 0, 0)
409
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
346
411
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
349
415
gdk_window_new (gdk_screen_get_root_window(screen),
381
447
GdkWindow *window;
449
#if GTK_CHECK_VERSION (3, 0, 0)
451
display = gdk_x11_lookup_xdisplay (ui->xdisplay);
452
window = gdk_x11_window_lookup_for_display (display, xwindow);
383
454
window = gdk_xid_table_lookup (xwindow);
386
458
gdk_window_show_unraised (window);
393
465
GdkWindow *window;
467
#if GTK_CHECK_VERSION (3, 0, 0)
469
display = gdk_x11_lookup_xdisplay (ui->xdisplay);
470
window = gdk_x11_window_lookup_for_display (display, xwindow);
395
472
window = gdk_xid_table_lookup (xwindow);
398
476
gdk_window_hide (window);
509
588
gtk_window_set_screen (GTK_WINDOW (iw->window), gscreen);
511
590
gtk_widget_realize (iw->window);
512
iw->pixmap = gdk_pixmap_new (iw->window->window,
591
iw->pixmap = gdk_pixmap_new (gtk_widget_get_window (iw->window),
513
592
max_width, max_height,
629
#if GTK_CHECK_VERSION (3, 0, 0)
552
633
/* We use a back pixmap to avoid having to handle exposes, because
553
634
* it's really too slow for large clients being minimized, etc.
554
635
* and this way flicker is genuinely zero.
638
#if !GTK_CHECK_VERSION (3, 0, 0)
557
639
gdk_draw_pixbuf (iw->pixmap,
558
iw->window->style->black_gc,
640
gtk_widget_get_style (iw->window)->black_gc,
562
644
gdk_pixbuf_get_width (pixbuf),
563
645
gdk_pixbuf_get_height (pixbuf),
564
646
GDK_RGB_DITHER_NORMAL,
566
649
cr = gdk_cairo_create (iw->pixmap);
567
650
gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
568
651
cairo_paint (cr);
569
652
cairo_destroy (cr);
571
gdk_window_set_back_pixmap (iw->window->window,
655
gdk_window_set_back_pixmap (gtk_widget_get_window (iw->window),
575
gdk_window_move_resize (iw->window->window,
659
gdk_window_move_resize (gtk_widget_get_window (iw->window),
577
661
gdk_pixbuf_get_width (pixbuf),
578
662
gdk_pixbuf_get_height (pixbuf));
580
gdk_window_clear (iw->window->window);
664
gdk_window_clear (gtk_widget_get_window (iw->window));
668
#if !GTK_CHECK_VERSION (3, 0, 0)
583
669
static GdkColormap*
584
670
get_cmap (GdkPixmap *pixmap)
707
#if GTK_CHECK_VERSION (3, 0, 0)
621
meta_gdk_pixbuf_get_from_window (GdkPixbuf *dest,
709
meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf *dest,
630
GdkDrawable *drawable;
718
cairo_surface_t *surface;
722
unsigned int w_ret, h_ret, bw_ret, depth_ret;
723
XWindowAttributes attrs;
631
724
GdkPixbuf *retval;
636
drawable = gdk_xid_table_lookup (xwindow);
639
g_object_ref (G_OBJECT (drawable));
726
display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
728
if (!XGetGeometry (display, xpixmap, &root_return,
729
&x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret))
734
surface = cairo_xlib_surface_create_for_bitmap (display,
736
GDK_SCREEN_XSCREEN (gdk_screen_get_default ()),
641
drawable = gdk_window_foreign_new (xwindow);
643
cmap = get_cmap (drawable);
645
retval = gdk_pixbuf_get_from_drawable (dest,
653
g_object_unref (G_OBJECT (cmap));
654
g_object_unref (G_OBJECT (drawable));
742
if (!XGetWindowAttributes (display, root_return, &attrs))
745
surface = cairo_xlib_surface_create (display,
751
retval = gdk_pixbuf_get_from_surface (surface,
756
cairo_surface_destroy (surface);
660
762
meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf *dest,
669
771
GdkDrawable *drawable;
670
772
GdkPixbuf *retval;
773
#if !GTK_CHECK_VERSION (3, 0, 0)
671
774
GdkColormap *cmap;
778
#if !GTK_CHECK_VERSION (3, 0, 0)
782
#if GTK_CHECK_VERSION (3, 0, 0)
783
drawable = gdk_x11_window_lookup_for_display (gdk_display_get_default (), xpixmap);
676
785
drawable = gdk_xid_table_lookup (xpixmap);
679
789
g_object_ref (G_OBJECT (drawable));
804
#if !GTK_CHECK_VERSION (3, 0, 0)
695
806
g_object_unref (G_OBJECT (cmap));
697
809
g_object_unref (G_OBJECT (drawable));
703
816
meta_ui_push_delay_exposes (MetaUI *ui)
788
901
GdkWindow *window;
903
#if GTK_CHECK_VERSION (3, 0, 0)
904
window = gdk_x11_window_lookup_for_display (gdk_display_get_default (), xwindow);
790
906
window = gdk_xid_table_lookup (xwindow);
792
909
/* we shouldn't cause focus if we're an override redirect
793
910
* toplevel which is not foreign
802
919
meta_text_property_to_utf8 (Display *xdisplay,
803
920
const XTextProperty *prop)
922
#if GTK_CHECK_VERSION (3, 0, 0)
931
#if GTK_CHECK_VERSION (3, 0, 0)
932
display = gdk_x11_lookup_xdisplay (xdisplay);
933
count = gdk_text_property_to_utf8_list_for_display (display,
934
gdk_x11_xatom_to_atom_for_display (display, prop->encoding),
811
940
count = gdk_text_property_to_utf8_list (gdk_x11_xatom_to_atom (prop->encoding),
912
if (strcmp (accel, "disabled") == 0)
1042
if (!accel[0] || strcmp (accel, "disabled") == 0)
915
1045
meta_ui_accelerator_parse (accel, &gdk_sym, &gdk_code, &gdk_mask);
999
if (accel == NULL || strcmp (accel, "disabled") == 0)
1129
if (accel == NULL || !accel[0] || strcmp (accel, "disabled") == 0)
1002
1132
meta_ui_accelerator_parse (accel, &gdk_sym, &gdk_code, &gdk_mask);
1040
1170
GdkWindow *window;
1172
#if GTK_CHECK_VERSION (3, 0, 0)
1173
GdkDisplay *display;
1175
window = gdk_x11_window_lookup_for_display (display, xwindow);
1042
1177
window = gdk_xid_table_lookup (xwindow);
1078
1214
return META_UI_DIRECTION_LTR;
1217
#if !GTK_CHECK_VERSION (3, 0, 0)
1081
1218
GdkPixbuf* meta_ui_get_pixbuf_from_pixmap(Pixmap pmap)
1083
1220
GdkPixmap* gpmap;
1084
1221
GdkScreen* screen;
1085
1222
GdkPixbuf* pixbuf;
1223
#if !GTK_CHECK_VERSION (3, 0, 0)
1086
1224
GdkColormap* cmap;
1091
1230
gpmap = gdk_pixmap_foreign_new(pmap);
1092
1231
screen = gdk_drawable_get_screen(gpmap);
1094
#if GTK_CHECK_VERSION(3, 0, 0)
1095
width = gdk_window_get_width(GDK_WINDOW(gpmap));
1096
height = gdk_window_get_height(GDK_WINDOW(gpmap));
1098
gdk_drawable_get_size(GDK_DRAWABLE(gpmap), &width, &height);
1233
#if GTK_CHECK_VERSION(3, 0, 0)
1234
width = gdk_window_get_width(GDK_WINDOW(gpmap));
1235
height = gdk_window_get_height(GDK_WINDOW(gpmap));
1237
gdk_drawable_get_size(GDK_DRAWABLE(gpmap), &width, &height);
1101
1240
depth = gdk_drawable_get_depth(GDK_DRAWABLE(gpmap));
1242
#if !GTK_CHECK_VERSION (3, 0, 0)
1103
1243
if (depth <= 24)
1105
1245
cmap = gdk_screen_get_system_colormap(screen);
1109
1249
cmap = gdk_screen_get_rgba_colormap(screen);
1112
1253
pixbuf = gdk_pixbuf_get_from_drawable(NULL, gpmap, cmap, 0, 0, 0, 0, width, height);