~ubuntu-branches/ubuntu/utopic/marco/utopic-proposed

« back to all changes in this revision

Viewing changes to src/ui/ui.c

  • Committer: Package Import Robot
  • Author(s): Mike Gabriel
  • Date: 2014-03-11 20:38:14 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20140311203814-kyq2m8h0zbk7vymi
Tags: 1.8.0+dfsg1-1
* New upstream release.
* Repack upstream tarball and omit non-DFSG (GFDL-1.1) files
  (creating themes documentation).
* debian/watch:
  + Use tagged CGit tarball snapshots as upstream source.
  + Mangle Debian package version.
* debian/copyright:
  + Adapt to files in new (repacked) upstream tarball.
* debian/rules:
  + Build package using autogen.sh.
* debian/control:
  + Add B-D: yelp-tools.
  + Drop B-D: mate-doc-utils, mate-doc-utils-gnome.
* debian/patches:
  + Drop patch 1001_hypen-used-as-minus-sign-on-man-page.patch. Fixed
    upstream.
  + Add patch 2001_omit-gfdl-licensed-theme-documentation.patch. Don't build
    GFDL-1.1 licensed files that got removed from the repacked tarball.
* debian/marco-common.install: 
  + Marco's arch-indep files now reside in /usr/share/marco (not
    /usr/share/mate-window-manager).
  + Install gsettings conversion map into bin:package marco-common.
* lintian:
  + Drop unused overrides.
  + Add override for shlib-calls-exit in bin:package libmarco-private0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
#include <string.h>
32
32
#include <stdlib.h>
33
33
 
 
34
#if GTK_CHECK_VERSION (3, 0, 0)
 
35
#include <cairo-xlib.h>
 
36
#endif
 
37
 
34
38
static void meta_ui_accelerator_parse(const char* accel, guint* keysym, guint* keycode, GdkModifierType* keymask);
35
39
 
36
40
struct _MetaUI {
79
83
{
80
84
  GdkDisplay *gdisplay;
81
85
  MetaUI *ui;
 
86
#if GTK_CHECK_VERSION (3, 0, 0)
 
87
  GdkDeviceManager *gmanager;
 
88
  GdkEvent *gevent;
 
89
#else
82
90
  GdkEvent gevent;
 
91
#endif
83
92
  GdkWindow *gdk_window;
84
93
  Window window;
85
94
 
105
114
  if (!ui)
106
115
    return FALSE;
107
116
 
 
117
#if GTK_CHECK_VERSION (3, 0, 0)
 
118
  gdk_window = gdk_x11_window_lookup_for_display (gdisplay, window);
 
119
#else
108
120
  gdk_window = gdk_window_lookup_for_display (gdisplay, window);
 
121
#endif
109
122
  if (gdk_window == NULL)
110
123
    return FALSE;
111
124
 
116
129
  if (gdk_display_pointer_is_grabbed (gdisplay))
117
130
    return FALSE;
118
131
 
 
132
#if !GTK_CHECK_VERSION (3, 0, 0)
119
133
  memset (&gevent, 0, sizeof (gevent));
 
134
#endif
120
135
 
121
136
  switch (xevent->type)
122
137
    {
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)
141
156
            {
 
157
#if GTK_CHECK_VERSION (3, 0, 0)
 
158
              gevent = gdk_event_new (GDK_2BUTTON_PRESS);
 
159
#else
142
160
              gevent.button.type = GDK_2BUTTON_PRESS;
 
161
#endif
143
162
 
144
163
              ui->button_click_number = 0;
145
164
            }
146
165
          else
147
166
            {
 
167
#if GTK_CHECK_VERSION (3, 0, 0)
 
168
              gevent = gdk_event_new (GDK_BUTTON_PRESS);
 
169
#else
148
170
              gevent.button.type = GDK_BUTTON_PRESS;
 
171
#endif
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;
155
178
        }
156
179
      else
157
180
        {
 
181
#if GTK_CHECK_VERSION (3, 0, 0)
 
182
          gevent = gdk_event_new (GDK_BUTTON_RELEASE);
 
183
#else
158
184
          gevent.button.type = GDK_BUTTON_RELEASE;
 
185
#endif
159
186
        }
160
187
 
 
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;
 
196
#else
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;
 
204
#endif
168
205
 
169
206
      break;
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);
 
212
#else
171
213
      gevent.motion.type = GDK_MOTION_NOTIFY;
172
214
      gevent.motion.window = gdk_window;
 
215
#endif
173
216
      break;
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;
 
224
#else
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;
 
229
#endif
180
230
      break;
181
231
    default:
182
232
      g_assert_not_reached ();
184
234
    }
185
235
 
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);
 
241
#else
187
242
  gtk_main_do_event (&gevent);
 
243
#endif
188
244
 
189
245
  return TRUE;
190
246
}
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);
 
365
#endif
308
366
 
309
367
  /* Default depth/visual handles clients with weird visuals; they can
310
368
   * always be children of the root depth/visual obviously, but
317
375
    {
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);
 
380
#endif
321
381
    }
322
382
 
323
383
  attrs.title = NULL;
333
393
  attrs.y = y;
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;
 
398
#endif
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;
345
407
 
 
408
#if GTK_CHECK_VERSION (3, 0, 0)
 
409
  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;
 
410
#else
346
411
  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
 
412
#endif
347
413
 
348
414
  window =
349
415
    gdk_window_new (gdk_screen_get_root_window(screen),
380
446
{
381
447
  GdkWindow *window;
382
448
 
 
449
#if GTK_CHECK_VERSION (3, 0, 0)
 
450
  GdkDisplay *display;
 
451
  display = gdk_x11_lookup_xdisplay (ui->xdisplay);
 
452
  window = gdk_x11_window_lookup_for_display (display, xwindow);
 
453
#else
383
454
  window = gdk_xid_table_lookup (xwindow);
 
455
#endif
384
456
 
385
457
  if (window)
386
458
    gdk_window_show_unraised (window);
392
464
{
393
465
  GdkWindow *window;
394
466
 
 
467
#if GTK_CHECK_VERSION (3, 0, 0)
 
468
  GdkDisplay *display;
 
469
  display = gdk_x11_lookup_xdisplay (ui->xdisplay);
 
470
  window = gdk_x11_window_lookup_for_display (display, xwindow);
 
471
#else
395
472
  window = gdk_xid_table_lookup (xwindow);
 
473
#endif
396
474
 
397
475
  if (window)
398
476
    gdk_window_hide (window);
484
562
  meta_window_menu_free (menu);
485
563
}
486
564
 
 
565
#if !GTK_CHECK_VERSION (3, 0, 0)
487
566
struct _MetaImageWindow
488
567
{
489
568
  GtkWidget *window;
509
588
  gtk_window_set_screen (GTK_WINDOW (iw->window), gscreen);
510
589
 
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,
514
593
                               -1);
515
594
 
547
626
                       int              x,
548
627
                       int              y)
549
628
{
 
629
#if GTK_CHECK_VERSION (3, 0, 0)
550
630
  cairo_t *cr;
 
631
#endif
551
632
 
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.
555
636
   */
556
637
 
 
638
#if !GTK_CHECK_VERSION (3, 0, 0)
557
639
  gdk_draw_pixbuf (iw->pixmap,
558
 
                   iw->window->style->black_gc,
559
 
                   pixbuf,
 
640
                   gtk_widget_get_style (iw->window)->black_gc,
 
641
                   pixbuf,
560
642
                   0, 0,
561
643
                   0, 0,
562
644
                   gdk_pixbuf_get_width (pixbuf),
563
645
                   gdk_pixbuf_get_height (pixbuf),
564
646
                   GDK_RGB_DITHER_NORMAL,
565
647
                   0, 0);
 
648
#else
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);
 
653
#endif
570
654
 
571
 
  gdk_window_set_back_pixmap (iw->window->window,
 
655
  gdk_window_set_back_pixmap (gtk_widget_get_window (iw->window),
572
656
                              iw->pixmap,
573
657
                              FALSE);
574
658
 
575
 
  gdk_window_move_resize (iw->window->window,
 
659
  gdk_window_move_resize (gtk_widget_get_window (iw->window),
576
660
                          x, y,
577
661
                          gdk_pixbuf_get_width (pixbuf),
578
662
                          gdk_pixbuf_get_height (pixbuf));
579
663
 
580
 
  gdk_window_clear (iw->window->window);
 
664
  gdk_window_clear (gtk_widget_get_window (iw->window));
581
665
}
 
666
#endif
582
667
 
 
668
#if !GTK_CHECK_VERSION (3, 0, 0)
583
669
static GdkColormap*
584
670
get_cmap (GdkPixmap *pixmap)
585
671
{
616
702
 
617
703
  return cmap;
618
704
}
 
705
#endif
619
706
 
 
707
#if GTK_CHECK_VERSION (3, 0, 0)
620
708
GdkPixbuf*
621
 
meta_gdk_pixbuf_get_from_window (GdkPixbuf   *dest,
622
 
                                 Window       xwindow,
 
709
meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf   *dest,
 
710
                                 Pixmap       xpixmap,
623
711
                                 int          src_x,
624
712
                                 int          src_y,
625
713
                                 int          dest_x,
627
715
                                 int          width,
628
716
                                 int          height)
629
717
{
630
 
  GdkDrawable *drawable;
 
718
  cairo_surface_t *surface;
 
719
  Display *display;
 
720
  Window root_return;
 
721
  int x_ret, y_ret;
 
722
  unsigned int w_ret, h_ret, bw_ret, depth_ret;
 
723
  XWindowAttributes attrs;
631
724
  GdkPixbuf *retval;
632
 
  GdkColormap *cmap;
633
 
 
634
 
  retval = NULL;
635
 
 
636
 
  drawable = gdk_xid_table_lookup (xwindow);
637
 
 
638
 
  if (drawable)
639
 
    g_object_ref (G_OBJECT (drawable));
 
725
 
 
726
  display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
 
727
 
 
728
  if (!XGetGeometry (display, xpixmap, &root_return,
 
729
                     &x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret))
 
730
    return NULL;
 
731
 
 
732
  if (depth_ret == 1)
 
733
    {
 
734
      surface = cairo_xlib_surface_create_for_bitmap (display,
 
735
                                                      xpixmap,
 
736
                                                      GDK_SCREEN_XSCREEN (gdk_screen_get_default ()),
 
737
                                                      w_ret,
 
738
                                                      h_ret);
 
739
    }
640
740
  else
641
 
    drawable = gdk_window_foreign_new (xwindow);
642
 
 
643
 
  cmap = get_cmap (drawable);
644
 
 
645
 
  retval = gdk_pixbuf_get_from_drawable (dest,
646
 
                                         drawable,
647
 
                                         cmap,
648
 
                                         src_x, src_y,
649
 
                                         dest_x, dest_y,
650
 
                                         width, height);
651
 
 
652
 
  if (cmap)
653
 
    g_object_unref (G_OBJECT (cmap));
654
 
  g_object_unref (G_OBJECT (drawable));
 
741
    {
 
742
      if (!XGetWindowAttributes (display, root_return, &attrs))
 
743
        return NULL;
 
744
 
 
745
      surface = cairo_xlib_surface_create (display,
 
746
                                           xpixmap,
 
747
                                           attrs.visual,
 
748
                                           w_ret, h_ret);
 
749
    }
 
750
 
 
751
  retval = gdk_pixbuf_get_from_surface (surface,
 
752
                                        src_x,
 
753
                                        src_y,
 
754
                                        width,
 
755
                                        height);
 
756
  cairo_surface_destroy (surface);
655
757
 
656
758
  return retval;
657
759
}
658
 
 
 
760
#else
659
761
GdkPixbuf*
660
762
meta_gdk_pixbuf_get_from_pixmap (GdkPixbuf   *dest,
661
763
                                 Pixmap       xpixmap,
668
770
{
669
771
  GdkDrawable *drawable;
670
772
  GdkPixbuf *retval;
 
773
#if !GTK_CHECK_VERSION (3, 0, 0)
671
774
  GdkColormap *cmap;
 
775
#endif
672
776
 
673
777
  retval = NULL;
 
778
#if !GTK_CHECK_VERSION (3, 0, 0)
674
779
  cmap = NULL;
 
780
#endif
675
781
 
 
782
#if GTK_CHECK_VERSION (3, 0, 0)
 
783
  drawable = gdk_x11_window_lookup_for_display (gdk_display_get_default (), xpixmap);
 
784
#else
676
785
  drawable = gdk_xid_table_lookup (xpixmap);
 
786
#endif
677
787
 
678
788
  if (drawable)
679
789
    g_object_ref (G_OBJECT (drawable));
691
801
                                             dest_x, dest_y,
692
802
                                             width, height);
693
803
    }
 
804
#if !GTK_CHECK_VERSION (3, 0, 0)
694
805
  if (cmap)
695
806
    g_object_unref (G_OBJECT (cmap));
 
807
#endif
696
808
  if (drawable)
697
809
    g_object_unref (G_OBJECT (drawable));
698
810
 
699
811
  return retval;
700
812
}
 
813
#endif
701
814
 
702
815
void
703
816
meta_ui_push_delay_exposes (MetaUI *ui)
787
900
{
788
901
  GdkWindow *window;
789
902
 
 
903
#if GTK_CHECK_VERSION (3, 0, 0)
 
904
  window = gdk_x11_window_lookup_for_display (gdk_display_get_default (), xwindow);
 
905
#else
790
906
  window = gdk_xid_table_lookup (xwindow);
 
907
#endif
791
908
 
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)
804
921
{
 
922
#if GTK_CHECK_VERSION (3, 0, 0)
 
923
  GdkDisplay *display;
 
924
#endif
805
925
  char **list;
806
926
  int count;
807
927
  char *retval;
808
928
 
809
929
  list = NULL;
810
930
 
 
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),
 
935
                                                      prop->format,
 
936
                                                      prop->value,
 
937
                                                      prop->nitems,
 
938
                                                      &list);
 
939
#else
811
940
  count = gdk_text_property_to_utf8_list (gdk_x11_xatom_to_atom (prop->encoding),
812
941
                                          prop->format,
813
942
                                          prop->value,
814
943
                                          prop->nitems,
815
944
                                          &list);
 
945
#endif
816
946
 
817
947
  if (count == 0)
818
948
    retval = NULL;
909
1039
  *keycode = 0;
910
1040
  *mask = 0;
911
1041
 
912
 
  if (strcmp (accel, "disabled") == 0)
 
1042
  if (!accel[0] || strcmp (accel, "disabled") == 0)
913
1043
    return TRUE;
914
1044
 
915
1045
  meta_ui_accelerator_parse (accel, &gdk_sym, &gdk_code, &gdk_mask);
996
1126
 
997
1127
  *mask = 0;
998
1128
 
999
 
  if (accel == NULL || strcmp (accel, "disabled") == 0)
 
1129
  if (accel == NULL || !accel[0] || strcmp (accel, "disabled") == 0)
1000
1130
    return TRUE;
1001
1131
 
1002
1132
  meta_ui_accelerator_parse (accel, &gdk_sym, &gdk_code, &gdk_mask);
1039
1169
{
1040
1170
  GdkWindow *window;
1041
1171
 
 
1172
#if GTK_CHECK_VERSION (3, 0, 0)
 
1173
  GdkDisplay *display;
 
1174
  
 
1175
  window = gdk_x11_window_lookup_for_display (display, xwindow);
 
1176
#else
1042
1177
  window = gdk_xid_table_lookup (xwindow);
 
1178
#endif
1043
1179
 
1044
1180
  if (window)
1045
1181
    {
1078
1214
        return META_UI_DIRECTION_LTR;
1079
1215
}
1080
1216
 
 
1217
#if !GTK_CHECK_VERSION (3, 0, 0)
1081
1218
GdkPixbuf* meta_ui_get_pixbuf_from_pixmap(Pixmap pmap)
1082
1219
{
1083
1220
        GdkPixmap* gpmap;
1084
1221
        GdkScreen* screen;
1085
1222
        GdkPixbuf* pixbuf;
 
1223
#if !GTK_CHECK_VERSION (3, 0, 0)
1086
1224
        GdkColormap* cmap;
 
1225
#endif
1087
1226
        int width;
1088
1227
        int height;
1089
1228
        int depth;
1091
1230
        gpmap = gdk_pixmap_foreign_new(pmap);
1092
1231
        screen = gdk_drawable_get_screen(gpmap);
1093
1232
 
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));
1097
 
        #else
1098
 
                gdk_drawable_get_size(GDK_DRAWABLE(gpmap), &width, &height);
1099
 
        #endif
 
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));
 
1236
#else
 
1237
        gdk_drawable_get_size(GDK_DRAWABLE(gpmap), &width, &height);
 
1238
#endif
1100
1239
 
1101
1240
        depth = gdk_drawable_get_depth(GDK_DRAWABLE(gpmap));
1102
1241
 
 
1242
#if !GTK_CHECK_VERSION (3, 0, 0)
1103
1243
        if (depth <= 24)
1104
1244
        {
1105
1245
                cmap = gdk_screen_get_system_colormap(screen);
1108
1248
        {
1109
1249
                cmap = gdk_screen_get_rgba_colormap(screen);
1110
1250
        }
 
1251
#endif
1111
1252
 
1112
1253
        pixbuf = gdk_pixbuf_get_from_drawable(NULL, gpmap, cmap, 0, 0, 0, 0, width, height);
1113
1254
 
1115
1256
 
1116
1257
        return pixbuf;
1117
1258
}
 
1259
#endif