~darkxst/ubuntu/saucy/gnome-shell/upstart_log

« back to all changes in this revision

Viewing changes to src/shell-global.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-05-31 12:01:12 UTC
  • mfrom: (1.1.49) (19.1.36 experimental)
  • Revision ID: package-import@ubuntu.com-20130531120112-ew91khxf051x9i2r
Tags: 3.8.2-1ubuntu1
* Merge with Debian (LP: #1185869, #1185721). Remaining changes:
  - debian/control.in:
    + Build-depend on libsystemd-login-dev & libsystemd-daemon-dev
    + Depend on gdm instead of gdm3
    + Don't recommend gnome-session-fallback
  - debian/patches/40_change-pam-name-to-match-gdm.patch:
  - debian/patches/revert-suspend-break.patch:
    + Disabled, not needed on Ubuntu
  - debian/patches/ubuntu-lightdm-user-switching.patch:
    + Allow user switching when using LightDM. Thanks Gerhard Stein
      for rebasing against gnome-shell 3.8!
  - debian/patches/ubuntu_lock_on_suspend.patch
    + Respect Ubuntu's lock-on-suspend setting.
      Disabled until it can be rewritten.
  - debian/patches/git_relock_screen_after_crash.patch:
    + Add Upstream fix for unlocked session after crash (LP: #1064584)
* Note that the new GNOME Classic mode (which requires installing
  gnome-shell-extensions) won't work until gnome-session 3.8 is
  available in Ubuntu

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#ifdef HAVE_SYS_RESOURCE_H
14
14
#include <sys/resource.h>
15
15
#endif
 
16
#include <locale.h>
16
17
 
17
18
#include <X11/extensions/Xfixes.h>
18
 
#include <cogl-pango/cogl-pango.h>
19
19
#include <canberra.h>
 
20
#include <canberra-gtk.h>
20
21
#include <clutter/glx/clutter-glx.h>
21
22
#include <clutter/x11/clutter-x11.h>
22
23
#include <gdk/gdkx.h>
34
35
 
35
36
#include "shell-enum-types.h"
36
37
#include "shell-global-private.h"
37
 
#include "shell-jsapi-compat-private.h"
38
38
#include "shell-perf-log.h"
39
39
#include "shell-window-tracker.h"
40
40
#include "shell-wm.h"
109
109
  PROP_STAGE,
110
110
  PROP_STAGE_INPUT_MODE,
111
111
  PROP_WINDOW_GROUP,
112
 
  PROP_BACKGROUND_ACTOR,
 
112
  PROP_TOP_WINDOW_GROUP,
113
113
  PROP_WINDOW_MANAGER,
114
114
  PROP_SETTINGS,
115
115
  PROP_DATADIR,
205
205
    case PROP_WINDOW_GROUP:
206
206
      g_value_set_object (value, meta_get_window_group_for_screen (global->meta_screen));
207
207
      break;
208
 
    case PROP_BACKGROUND_ACTOR:
209
 
      g_value_set_object (value, meta_get_background_actor_for_screen (global->meta_screen));
 
208
    case PROP_TOP_WINDOW_GROUP:
 
209
      g_value_set_object (value, meta_get_top_window_group_for_screen (global->meta_screen));
210
210
      break;
211
211
    case PROP_WINDOW_MANAGER:
212
212
      g_value_set_object (value, global->wm);
284
284
 
285
285
  global->input_mode = SHELL_STAGE_INPUT_MODE_NORMAL;
286
286
 
287
 
  ca_context_create (&global->sound_context);
288
 
  ca_context_change_props (global->sound_context, CA_PROP_APPLICATION_NAME, PACKAGE_NAME, CA_PROP_APPLICATION_ID, "org.gnome.Shell", NULL);
 
287
  global->sound_context = ca_gtk_context_get ();
 
288
  ca_context_change_props (global->sound_context,
 
289
                           CA_PROP_APPLICATION_NAME, "GNOME Shell",
 
290
                           CA_PROP_APPLICATION_ID, "org.gnome.Shell",
 
291
                           CA_PROP_APPLICATION_ICON_NAME, "start-here",
 
292
                           CA_PROP_APPLICATION_LANGUAGE, setlocale (LC_MESSAGES, NULL),
 
293
                           NULL);
289
294
  ca_context_open (global->sound_context);
290
295
 
291
296
  if (!shell_js)
438
443
                                                        "Actor holding window actors",
439
444
                                                        CLUTTER_TYPE_ACTOR,
440
445
                                                        G_PARAM_READABLE));
 
446
 
441
447
  g_object_class_install_property (gobject_class,
442
 
                                   PROP_BACKGROUND_ACTOR,
443
 
                                   g_param_spec_object ("background-actor",
444
 
                                                        "Background Actor",
445
 
                                                        "Actor drawing root window background",
446
 
                                                        CLUTTER_TYPE_ACTOR,
447
 
                                                        G_PARAM_READABLE));
 
448
                                     PROP_TOP_WINDOW_GROUP,
 
449
                                     g_param_spec_object ("top-window-group",
 
450
                                                          "Top Window Group",
 
451
                                                          "Actor holding override-redirect windows",
 
452
                                                          CLUTTER_TYPE_ACTOR,
 
453
                                                          G_PARAM_READABLE));
 
454
 
448
455
  g_object_class_install_property (gobject_class,
449
456
                                   PROP_WINDOW_MANAGER,
450
457
                                   g_param_spec_object ("window-manager",
636
643
    case SHELL_CURSOR_POINTING_HAND:
637
644
      name = "hand";
638
645
      break;
 
646
    case SHELL_CURSOR_CROSSHAIR:
 
647
      name = "crosshair";
 
648
      break;
639
649
    default:
640
650
      g_return_if_reached ();
641
651
    }
658
668
        case SHELL_CURSOR_POINTING_HAND:
659
669
          cursor_type = GDK_HAND2;
660
670
          break;
 
671
        case SHELL_CURSOR_CROSSHAIR:
 
672
          cursor_type = GDK_CROSSHAIR;
 
673
          break;
661
674
        case SHELL_CURSOR_DND_UNSUPPORTED_TARGET:
662
675
          cursor_type = GDK_X_CURSOR;
663
676
          break;
809
822
  g_object_notify (G_OBJECT (global), "screen-height");
810
823
}
811
824
 
812
 
static void
813
 
global_stage_before_paint (ClutterStage *stage,
814
 
                           ShellGlobal  *global)
 
825
static gboolean
 
826
global_stage_before_paint (gpointer data)
815
827
{
816
828
  shell_perf_log_event (shell_perf_log_get_default (),
817
829
                        "clutter.stagePaintStart");
 
830
 
 
831
  return TRUE;
818
832
}
819
833
 
820
 
static void
821
 
global_stage_after_paint (ClutterStage *stage,
822
 
                          ShellGlobal  *global)
 
834
static gboolean
 
835
global_stage_after_paint (gpointer data)
823
836
{
824
837
  shell_perf_log_event (shell_perf_log_get_default (),
825
838
                        "clutter.stagePaintDone");
826
 
}
827
 
 
828
 
static void
829
 
shell_fonts_init (ClutterStage *stage)
830
 
{
831
 
  CoglPangoFontMap *fontmap;
832
 
 
833
 
  /* Disable text mipmapping; it causes problems on pre-GEM Intel
834
 
   * drivers and we should just be rendering text at the right
835
 
   * size rather than scaling it. If we do effects where we dynamically
836
 
   * zoom labels, then we might want to reconsider.
837
 
   */
838
 
  fontmap = COGL_PANGO_FONT_MAP (clutter_get_font_map ());
839
 
  cogl_pango_font_map_set_use_mipmapping (fontmap, FALSE);
 
839
 
 
840
  return TRUE;
840
841
}
841
842
 
842
843
/* This is an IBus workaround. The flow of events with IBus is that every time
960
961
  g_signal_connect (global->stage, "notify::height",
961
962
                    G_CALLBACK (global_stage_notify_height), global);
962
963
 
963
 
  g_signal_connect (global->stage, "paint",
964
 
                    G_CALLBACK (global_stage_before_paint), global);
965
 
  g_signal_connect_after (global->stage, "paint",
966
 
                          G_CALLBACK (global_stage_after_paint), global);
 
964
  clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_PRE_PAINT,
 
965
                                         global_stage_before_paint,
 
966
                                         NULL, NULL);
 
967
 
 
968
  clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_POST_PAINT,
 
969
                                         global_stage_after_paint,
 
970
                                         NULL, NULL);
967
971
 
968
972
  shell_perf_log_define_event (shell_perf_log_get_default(),
969
973
                               "clutter.stagePaintStart",
977
981
  g_signal_connect (global->meta_display, "notify::focus-window",
978
982
                    G_CALLBACK (focus_window_changed), global);
979
983
 
980
 
  shell_fonts_init (global->stage);
981
 
 
982
984
  gdk_event_handler_set (gnome_shell_gdk_event_handler, global->stage, NULL);
983
985
 
984
986
  global->focus_manager = st_focus_manager_get_for_stage (global->stage);
1027
1029
  meta_plugin_end_modal (global->plugin, timestamp);
1028
1030
}
1029
1031
 
1030
 
/**
1031
 
 * shell_global_create_pointer_barrier:
1032
 
 * @global: a #ShellGlobal
1033
 
 * @x1: left X coordinate
1034
 
 * @y1: top Y coordinate
1035
 
 * @x2: right X coordinate
1036
 
 * @y2: bottom Y coordinate
1037
 
 * @directions: The directions we're allowed to pass through
1038
 
 *
1039
 
 * If supported by X creates a pointer barrier.
1040
 
 *
1041
 
 * Return value: value you can pass to shell_global_destroy_pointer_barrier()
1042
 
 */
1043
 
guint32
1044
 
shell_global_create_pointer_barrier (ShellGlobal *global,
1045
 
                                     int x1, int y1, int x2, int y2,
1046
 
                                     int directions)
1047
 
{
1048
 
#if HAVE_XFIXESCREATEPOINTERBARRIER
1049
 
  return (guint32)
1050
 
    XFixesCreatePointerBarrier (global->xdisplay,
1051
 
                                DefaultRootWindow (global->xdisplay),
1052
 
                                x1, y1,
1053
 
                                x2, y2,
1054
 
                                directions,
1055
 
                                0, NULL);
1056
 
#else
1057
 
  return 0;
1058
 
#endif
1059
 
}
1060
 
 
1061
 
/**
1062
 
 * shell_global_destroy_pointer_barrier:
1063
 
 * @global: a #ShellGlobal
1064
 
 * @barrier: a pointer barrier
1065
 
 *
1066
 
 * Destroys the @barrier created by shell_global_create_pointer_barrier().
1067
 
 */
1068
 
void
1069
 
shell_global_destroy_pointer_barrier (ShellGlobal *global, guint32 barrier)
1070
 
{
1071
 
#if HAVE_XFIXESCREATEPOINTERBARRIER
1072
 
  g_return_if_fail (barrier > 0);
1073
 
 
1074
 
  XFixesDestroyPointerBarrier (global->xdisplay, (PointerBarrier)barrier);
1075
 
#endif
1076
 
}
1077
 
 
1078
1032
/* Code to close all file descriptors before we exec; copied from gspawn.c in GLib.
1079
1033
 *
1080
1034
 * Authors: Padraig O'Briain, Matthias Clasen, Lennart Poettering
1424
1378
shell_global_get_current_time (ShellGlobal *global)
1425
1379
{
1426
1380
  guint32 time;
1427
 
  const ClutterEvent *clutter_event;
1428
1381
 
1429
1382
  /* In case we have a xdnd timestamp use it */
1430
1383
  if (global->xdnd_timestamp != 0)
1435
1388
     from some Clutter event callbacks.
1436
1389
 
1437
1390
     clutter_get_current_event_time() will return the correct time
1438
 
     from a Clutter event callback, but may return an out-of-date
 
1391
     from a Clutter event callback, but may return CLUTTER_CURRENT_TIME
1439
1392
     timestamp if called at other times.
1440
1393
 
1441
1394
     So we try meta_display_get_current_time() first, since we
1445
1398
 
1446
1399
  time = meta_display_get_current_time (global->meta_display);
1447
1400
  if (time != CLUTTER_CURRENT_TIME)
1448
 
      return time;
1449
 
  /*
1450
 
   * We don't use clutter_get_current_event_time as it can give us a
1451
 
   * too old timestamp if there is no current event.
1452
 
   */
1453
 
  clutter_event = clutter_get_current_event ();
 
1401
    return time;
1454
1402
 
1455
 
  if (clutter_event != NULL)
1456
 
    return clutter_event_get_time (clutter_event);
1457
 
  else
1458
 
    return CLUTTER_CURRENT_TIME;
 
1403
  return clutter_get_current_event_time ();
1459
1404
}
1460
1405
 
1461
1406
/**
1617
1562
    schedule_leisure_functions (global);
1618
1563
}
1619
1564
 
 
1565
static void
 
1566
build_ca_proplist_for_event (ca_proplist  *props,
 
1567
                             const char   *event_property,
 
1568
                             const char   *event_id,
 
1569
                             const char   *event_description,
 
1570
                             ClutterEvent *for_event)
 
1571
{
 
1572
  ca_proplist_sets (props, event_property, event_id);
 
1573
  ca_proplist_sets (props, CA_PROP_EVENT_DESCRIPTION, event_description);
 
1574
  ca_proplist_sets (props, CA_PROP_CANBERRA_CACHE_CONTROL, "volatile");
 
1575
 
 
1576
  if (for_event)
 
1577
    {
 
1578
      if (clutter_event_type (for_event) != CLUTTER_KEY_PRESS &&
 
1579
          clutter_event_type (for_event) != CLUTTER_KEY_RELEASE)
 
1580
        {
 
1581
          ClutterPoint point;
 
1582
 
 
1583
          clutter_event_get_position (for_event, &point);
 
1584
 
 
1585
          ca_proplist_setf (props, CA_PROP_EVENT_MOUSE_X, "%d", (int)point.x);
 
1586
          ca_proplist_setf (props, CA_PROP_EVENT_MOUSE_Y, "%d", (int)point.y);
 
1587
        }
 
1588
 
 
1589
      if (clutter_event_type (for_event) == CLUTTER_BUTTON_PRESS ||
 
1590
          clutter_event_type (for_event) == CLUTTER_BUTTON_RELEASE)
 
1591
        {
 
1592
          gint button;
 
1593
 
 
1594
          button = clutter_event_get_button (for_event);
 
1595
          ca_proplist_setf (props, CA_PROP_EVENT_MOUSE_BUTTON, "%d", button);
 
1596
        }
 
1597
    }
 
1598
}
 
1599
 
1620
1600
/**
1621
1601
 * shell_global_play_theme_sound:
1622
1602
 * @global: the #ShellGlobal
1623
1603
 * @id: an id, used to cancel later (0 if not needed)
1624
1604
 * @name: the sound name
1625
 
 *
1626
 
 * Plays a simple sound picked according to Freedesktop sound theme.
1627
 
 * Really just a workaround for libcanberra not being introspected.
1628
 
 */
1629
 
void
1630
 
shell_global_play_theme_sound (ShellGlobal *global,
1631
 
                               guint        id,
1632
 
                               const char  *name)
1633
 
{
1634
 
  ca_context_play (global->sound_context, id, CA_PROP_EVENT_ID, name, NULL);
 
1605
 * @for_event: (allow-none): a #ClutterEvent in response to which the sound is played
 
1606
 *
 
1607
 * Plays a simple sound picked according to Freedesktop sound theme.
 
1608
 * Really just a workaround for libcanberra not being introspected.
 
1609
 */
 
1610
void
 
1611
shell_global_play_theme_sound (ShellGlobal  *global,
 
1612
                               guint         id,
 
1613
                               const char   *name,
 
1614
                               const char   *description,
 
1615
                               ClutterEvent *for_event)
 
1616
{
 
1617
  ca_proplist *props;
 
1618
 
 
1619
  ca_proplist_create (&props);
 
1620
  build_ca_proplist_for_event (props, CA_PROP_EVENT_ID, name, description, for_event);
 
1621
 
 
1622
  ca_context_play_full (global->sound_context, id, props, NULL, NULL);
 
1623
 
 
1624
  ca_proplist_destroy (props);
 
1625
}
 
1626
 
 
1627
/**
 
1628
 * shell_global_play_theme_sound_full:
 
1629
 * @global: the #ShellGlobal
 
1630
 * @id: an id, used to cancel later (0 if not needed)
 
1631
 * @name: the sound name
 
1632
 * @description: the localized description of the event that triggered this alert
 
1633
 * @for_event: (allow-none): a #ClutterEvent in response to which the sound is played
 
1634
 * @application_id: application on behalf of which the sound is played
 
1635
 * @application_name:
 
1636
 *
 
1637
 * Plays a simple sound picked according to Freedesktop sound theme.
 
1638
 * Really just a workaround for libcanberra not being introspected.
 
1639
 */
 
1640
void
 
1641
shell_global_play_theme_sound_full (ShellGlobal  *global,
 
1642
                                    guint         id,
 
1643
                                    const char   *name,
 
1644
                                    const char   *description,
 
1645
                                    ClutterEvent *for_event,
 
1646
                                    const char   *application_id,
 
1647
                                    const char   *application_name)
 
1648
{
 
1649
  ca_proplist *props;
 
1650
 
 
1651
  ca_proplist_create (&props);
 
1652
  build_ca_proplist_for_event (props, CA_PROP_EVENT_ID, name, description, for_event);
 
1653
  ca_proplist_sets (props, CA_PROP_APPLICATION_ID, application_id);
 
1654
  ca_proplist_sets (props, CA_PROP_APPLICATION_NAME, application_name);
 
1655
 
 
1656
  ca_context_play_full (global->sound_context, id, props, NULL, NULL);
 
1657
 
 
1658
  ca_proplist_destroy (props);
 
1659
}
 
1660
 
 
1661
/**
 
1662
 * shell_global_play_sound_file_full:
 
1663
 * @global: the #ShellGlobal
 
1664
 * @id: an id, used to cancel later (0 if not needed)
 
1665
 * @file_name: the file name to play
 
1666
 * @description: the localized description of the event that triggered this alert
 
1667
 * @for_event: (allow-none): a #ClutterEvent in response to which the sound is played
 
1668
 * @application_id: application on behalf of which the sound is played
 
1669
 * @application_name:
 
1670
 *
 
1671
 * Like shell_global_play_theme_sound_full(), but with an explicit path
 
1672
 * instead of a themed sound.
 
1673
 */
 
1674
void
 
1675
shell_global_play_sound_file_full  (ShellGlobal  *global,
 
1676
                                    guint         id,
 
1677
                                    const char   *file_name,
 
1678
                                    const char   *description,
 
1679
                                    ClutterEvent *for_event,
 
1680
                                    const char   *application_id,
 
1681
                                    const char   *application_name)
 
1682
{
 
1683
  ca_proplist *props;
 
1684
 
 
1685
  ca_proplist_create (&props);
 
1686
  build_ca_proplist_for_event (props, CA_PROP_MEDIA_FILENAME, file_name, description, for_event);
 
1687
  ca_proplist_sets (props, CA_PROP_APPLICATION_ID, application_id);
 
1688
  ca_proplist_sets (props, CA_PROP_APPLICATION_NAME, application_name);
 
1689
 
 
1690
  ca_context_play_full (global->sound_context, id, props, NULL, NULL);
 
1691
 
 
1692
  ca_proplist_destroy (props);
 
1693
}
 
1694
 
 
1695
/**
 
1696
 * shell_global_play_sound_file:
 
1697
 * @global: the #ShellGlobal
 
1698
 * @id: an id, used to cancel later (0 if not needed)
 
1699
 * @file_name: the file name to play
 
1700
 * @description: the localized description of the event that triggered this alert
 
1701
 * @for_event: (allow-none): a #ClutterEvent in response to which the sound is played
 
1702
 *
 
1703
 * Like shell_global_play_theme_sound(), but with an explicit path
 
1704
 * instead of a themed sound.
 
1705
 */
 
1706
void
 
1707
shell_global_play_sound_file (ShellGlobal  *global,
 
1708
                              guint         id,
 
1709
                              const char   *file_name,
 
1710
                              const char   *description,
 
1711
                              ClutterEvent *for_event)
 
1712
{
 
1713
  ca_proplist *props;
 
1714
 
 
1715
  ca_proplist_create (&props);
 
1716
  build_ca_proplist_for_event (props, CA_PROP_MEDIA_FILENAME, file_name, description, for_event);
 
1717
 
 
1718
  ca_context_play_full (global->sound_context, id, props, NULL, NULL);
 
1719
 
 
1720
  ca_proplist_destroy (props);
1635
1721
}
1636
1722
 
1637
1723
/**
1714
1800
  return global->session_mode;
1715
1801
}
1716
1802
 
1717
 
/**
1718
 
 * shell_global_create_xrootpmap_texture:
1719
 
 * @global: The #ShellGlobal
1720
 
 *
1721
 
 * This returns the _XROOTPMAP_ID pixmap that gdm should have stuffed
1722
 
 * in the root window. The goal here is to allow a smooth fade between
1723
 
 * plymouth and the shell greeter. This is also a workaround for gjs not
1724
 
 * supporting raw xlib types.
1725
 
 *
1726
 
 * Returns: (transfer floating): A #ClutterActor that represents the
1727
 
 * _XROOTPMAP_ID pixmap property from the root window.
1728
 
 */
1729
 
ClutterActor *
1730
 
shell_global_create_xrootpmap_texture (ShellGlobal *global)
1731
 
{
1732
 
  Atom res_type;
1733
 
  int res_format;
1734
 
  unsigned long res_nitems, bytesafter;
1735
 
  unsigned char *data;
1736
 
  Pixmap root_pixmap_id = None;
1737
 
 
1738
 
  g_return_val_if_fail (SHELL_IS_GLOBAL (global), NULL);
1739
 
 
1740
 
  if (XGetWindowProperty (global->xdisplay,
1741
 
                          DefaultRootWindow (global->xdisplay),
1742
 
                          XInternAtom (global->xdisplay, "_XROOTPMAP_ID", False),
1743
 
                          0, G_MAXLONG, False, XA_PIXMAP,
1744
 
                          &res_type, &res_format, &res_nitems, &bytesafter, &data) == Success)
1745
 
    {
1746
 
      if (res_type == XA_PIXMAP && res_format == 32 && res_nitems == 1)
1747
 
        root_pixmap_id = * (Pixmap *) data;
1748
 
      XFree (data);
1749
 
    }
1750
 
 
1751
 
  if (root_pixmap_id != None)
1752
 
    return clutter_x11_texture_pixmap_new_with_pixmap (root_pixmap_id);
1753
 
  else
1754
 
    return NULL;
1755
 
}
1756
 
 
1757
1803
static GFile *
1758
1804
get_runtime_state_path (ShellGlobal  *global,
1759
1805
                        const char   *property_name)