~ubuntu-branches/ubuntu/trusty/libxfce4ui/trusty

« back to all changes in this revision

Viewing changes to libxfce4ui/xfce-gdk-extensions.c

  • Committer: Package Import Robot
  • Author(s): Yves-Alexis Perez
  • Date: 2013-05-21 21:32:57 UTC
  • mfrom: (6.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20130521213257-q5nqhxkutb9ze4ld
Tags: 4.10.0-2
* Upload to unstable.
* debian/rules:
  - enable all hardening flags.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id$ */
2
 
/*-
 
1
/*
3
2
 * Copyright (c) 2003-2007 Benedikt Meurer <benny@xfce.org>
4
3
 * Copyright (c) 2007      The Xfce Development Team
5
4
 *
14
13
 * Library General Public License for more details.
15
14
 *
16
15
 * You should have received a copy of the GNU Library General Public
17
 
 * License along with this library; if not, write to the
18
 
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19
 
 * Boston, MA 02111-1307, USA.
 
16
 * License along with this library; if not, write to the Free Software
 
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
18
 * MA 02110-1301 USA
20
19
 */
21
20
 
22
21
#ifdef HAVE_CONFIG_H
50
49
GdkScreen *
51
50
xfce_gdk_screen_get_active (gint *monitor_return)
52
51
{
53
 
#ifdef GDK_WINDOWING_X11
54
 
  GdkScreen *screen;
55
 
  Window     child;
56
 
  Window     root;
57
 
  GSList    *displays;
58
 
  GSList    *lp;
59
 
  guint      xmask;
60
 
  gint       rootx, rooty;
61
 
  gint       winx, winy;
62
 
  gint       n;
63
 
 
64
 
  /* determine the list of active displays */
65
 
  displays = gdk_display_manager_list_displays (gdk_display_manager_get ());
66
 
  for (lp = displays; lp != NULL; lp = lp->next)
67
 
    {
68
 
      /* check all screens on this display */
69
 
      for (n = 0; n < gdk_display_get_n_screens (lp->data); ++n)
70
 
        {
71
 
          /* check if this screen contains the pointer */
72
 
          screen = gdk_display_get_screen (lp->data, n);
73
 
          if (XQueryPointer (GDK_SCREEN_XDISPLAY (screen),
74
 
                             GDK_DRAWABLE_XID (gdk_screen_get_root_window (screen)),
75
 
                             &root, &child, &rootx, &rooty, &winx, &winy, &xmask))
76
 
            {
77
 
              /* return the monitor number */
78
 
              if (monitor_return != NULL)
79
 
                *monitor_return = gdk_screen_get_monitor_at_point (screen, rootx, rooty);
80
 
 
81
 
              /* yap, this screen contains the pointer, hence it's the active screen */
82
 
              goto out;
83
 
            }
84
 
        }
85
 
    }
86
 
 
87
 
  /* nothing found, fallback to default screen */
88
 
  screen = gdk_screen_get_default ();
89
 
  if (monitor_return != NULL)
90
 
    *monitor_return = 0;
91
 
 
92
 
out:
93
 
  g_slist_free (displays);
 
52
  GdkDisplay *display;
 
53
  gint        rootx, rooty;
 
54
  GdkScreen  *screen;
 
55
 
 
56
  display = gdk_display_get_default ();
 
57
  gdk_display_get_pointer (display, &screen, &rootx, &rooty, NULL);
 
58
 
 
59
  if (G_UNLIKELY (screen == NULL))
 
60
    {
 
61
      screen = gdk_screen_get_default ();
 
62
      if (monitor_return != NULL)
 
63
        *monitor_return = 0;
 
64
    }
 
65
  else
 
66
    {
 
67
      /* return the monitor number */
 
68
      if (monitor_return != NULL)
 
69
        *monitor_return = gdk_screen_get_monitor_at_point (screen, rootx, rooty);
 
70
    }
94
71
 
95
72
  return screen;
96
 
#else
97
 
  /* dunno what to do on non-X11 window systems */
98
 
  return gdk_screen_get_default ();
99
 
#endif
100
73
}
101
74
 
102
75