mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-09-09 00:13:20 +02:00
2009-03-17 Christian Hoff <christian_hoff@gmx.net>
* gdk/Property.custom: add new overloads to the Get method for the most common property types * gdk/Global.custom: Use the new overloads of Property.Get instead of glue svn path=/trunk/gtk-sharp/; revision=129618
This commit is contained in:
parent
80d16bd3a2
commit
d7095d495c
@ -1,3 +1,9 @@
|
|||||||
|
2009-03-17 Christian Hoff <christian_hoff@gmx.net>
|
||||||
|
|
||||||
|
* gdk/Property.custom: add new overloads to the Get method
|
||||||
|
for the most common property types
|
||||||
|
* gdk/Global.custom: Use the new overloads of Property.Get instead of glue
|
||||||
|
|
||||||
2009-03-16 Mike Kestner <mkestner@novell.com>
|
2009-03-16 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* gtk/NodeSelection.cs: use new Adapter prop on NodeStore.
|
* gtk/NodeSelection.cs: use new Adapter prop on NodeStore.
|
||||||
|
@ -49,88 +49,61 @@
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport ("gdksharpglue-2")]
|
|
||||||
static extern IntPtr gtksharp_get_gdk_net_supported ();
|
|
||||||
|
|
||||||
public static Gdk.Atom[] SupportedWindowManagerHints {
|
public static Gdk.Atom[] SupportedWindowManagerHints {
|
||||||
get {
|
get {
|
||||||
IntPtr raw_ret = gtksharp_get_gdk_net_supported ();
|
Gdk.Atom[] atoms;
|
||||||
if (raw_ret == IntPtr.Zero)
|
if (!Gdk.Property.Get (Screen.Default.RootWindow, Atom.Intern ("_NET_SUPPORTED", false), false, out atoms))
|
||||||
return new Gdk.Atom [0];
|
throw new ApplicationException ("Unable to get _NET_SUPPORTED property");
|
||||||
GLib.List list = new GLib.List (raw_ret, typeof (Gdk.Atom));
|
|
||||||
Gdk.Atom[] atoms = new Gdk.Atom [list.Count];
|
|
||||||
for (int i = 0; i < list.Count; i++)
|
|
||||||
atoms [i] = list [i] as Gdk.Atom;
|
|
||||||
|
|
||||||
return atoms;
|
return atoms;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport ("gdksharpglue-2")]
|
|
||||||
static extern IntPtr gtksharp_get_gdk_net_client_list (out int count);
|
|
||||||
|
|
||||||
public static Gdk.Window[] WindowManagerClientWindows {
|
public static Gdk.Window[] WindowManagerClientWindows {
|
||||||
get {
|
get {
|
||||||
int count;
|
Gdk.Window [] windows;
|
||||||
IntPtr raw_ret = gtksharp_get_gdk_net_client_list (out count);
|
if (!Gdk.Property.Get (Screen.Default.RootWindow, Atom.Intern ("_NET_CLIENT_LIST", false), false, out windows))
|
||||||
if (raw_ret == IntPtr.Zero)
|
throw new ApplicationException ("Unable to get _NET_CLIENT_LIST property");
|
||||||
return new Gdk.Window [0];
|
|
||||||
Gdk.Window [] windows = new Gdk.Window [count];
|
|
||||||
int offset = 0;
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
int windowID = Marshal.ReadInt32 (raw_ret, offset);
|
|
||||||
Console.WriteLine ("WinID: {0}", windowID);
|
|
||||||
offset += IntPtr.Size;
|
|
||||||
windows [i] = Gdk.Window.ForeignNew ((uint) windowID);
|
|
||||||
}
|
|
||||||
return windows;
|
return windows;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport ("gdksharpglue-2")]
|
|
||||||
static extern int gtksharp_get_gdk_net_number_of_desktops ();
|
|
||||||
|
|
||||||
public static int NumberOfDesktops {
|
public static int NumberOfDesktops {
|
||||||
get {
|
get {
|
||||||
return gtksharp_get_gdk_net_number_of_desktops ();
|
int[] data;
|
||||||
|
if (!Gdk.Property.Get (Screen.Default.RootWindow, Atom.Intern ("_NET_NUMBER_OF_DESKTOPS", false), false, out data))
|
||||||
|
throw new ApplicationException ("Unable to get _NET_NUMBER_OF_DESKTOPS property");
|
||||||
|
|
||||||
|
return data [0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport ("gdksharpglue-2")]
|
|
||||||
static extern int gtksharp_get_gdk_net_current_desktop ();
|
|
||||||
|
|
||||||
public static int CurrentDesktop {
|
public static int CurrentDesktop {
|
||||||
get {
|
get {
|
||||||
return gtksharp_get_gdk_net_current_desktop ();
|
int[] data;
|
||||||
|
if (!Gdk.Property.Get (Screen.Default.RootWindow, Atom.Intern ("_NET_CURRENT_DESKTOP", false), false, out data))
|
||||||
|
throw new ApplicationException ("Unable to get _NET_CURRENT_DESKTOP property");
|
||||||
|
|
||||||
|
return data [0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport ("gdksharpglue-2")]
|
|
||||||
static extern uint gtksharp_get_gdk_net_active_window ();
|
|
||||||
|
|
||||||
public static Gdk.Window ActiveWindow {
|
public static Gdk.Window ActiveWindow {
|
||||||
get {
|
get {
|
||||||
uint windowID = gtksharp_get_gdk_net_active_window ();
|
Gdk.Window [] windows;
|
||||||
if (windowID == 0)
|
if (!Gdk.Property.Get (Screen.Default.RootWindow, Atom.Intern ("_NET_ACTIVE_WINDOW", false), false, out windows))
|
||||||
return Gdk.Global.DefaultRootWindow;
|
throw new ApplicationException ("Unable to get _NET_ACTIVE_WINDOW property");
|
||||||
Console.WriteLine ("Active Window ID: {0}", windowID);
|
|
||||||
Gdk.Window window = Gdk.Window.ForeignNew (windowID);
|
return windows [0];
|
||||||
return window;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport ("gdksharpglue-2")]
|
|
||||||
static extern IntPtr gtksharp_get_gdk_net_workarea ();
|
|
||||||
|
|
||||||
public static Gdk.Rectangle[] DesktopWorkareas {
|
public static Gdk.Rectangle[] DesktopWorkareas {
|
||||||
get {
|
get {
|
||||||
IntPtr raw_ret = gtksharp_get_gdk_net_workarea ();
|
Gdk.Rectangle[] workareas;
|
||||||
if (raw_ret == IntPtr.Zero)
|
if (!Gdk.Property.Get (Screen.Default.RootWindow, Atom.Intern ("_NET_WORKAREA", false), false, out workareas))
|
||||||
return new Gdk.Rectangle [0];
|
throw new ApplicationException ("Unable to get _NET_WORKAREA property");
|
||||||
GLib.List list = new GLib.List (raw_ret, typeof (Gdk.Rectangle));
|
|
||||||
Gdk.Rectangle[] workareas = new Gdk.Rectangle [list.Count];
|
|
||||||
for (int i = 0; i < list.Count; i++)
|
|
||||||
workareas [i] = (Gdk.Rectangle) list [i];
|
|
||||||
|
|
||||||
return workareas;
|
return workareas;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
// Authors: Mike Kestner <mkestner@novell.com>
|
// Authors: Mike Kestner <mkestner@novell.com>
|
||||||
//
|
//
|
||||||
// Copyright (c) 2007 Novell, Inc.
|
// Copyright (c) 2007 Novell, Inc.
|
||||||
|
// Copyright (c) 2009 Christian Hoff
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or
|
// This program is free software; you can redistribute it and/or
|
||||||
// modify it under the terms of version 2 of the Lesser GNU General
|
// modify it under the terms of version 2 of the Lesser GNU General
|
||||||
@ -30,12 +31,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("libgdk-win32-2.0-0.dll")]
|
[DllImport("libgdk-win32-2.0-0.dll")]
|
||||||
static extern bool gdk_property_get(IntPtr window, IntPtr property, IntPtr type, UIntPtr offset, UIntPtr length, int pdelete, out IntPtr actual_property_type, out int actual_format, out int actual_length, out IntPtr data);
|
static extern bool gdk_property_get(IntPtr window, IntPtr property, IntPtr type, UIntPtr offset, UIntPtr length, bool pdelete, out IntPtr actual_property_type, out int actual_format, out int actual_length, out IntPtr data);
|
||||||
|
|
||||||
public static bool Get(Gdk.Window window, Gdk.Atom property, Gdk.Atom type, ulong offset, ulong length, int pdelete, out Gdk.Atom actual_property_type, out int actual_format, out int actual_length, out byte[] data) {
|
public static bool Get(Gdk.Window window, Gdk.Atom property, Gdk.Atom type, ulong offset, ulong length, int pdelete, out Gdk.Atom actual_property_type, out int actual_format, out int actual_length, out byte[] data) {
|
||||||
IntPtr actual_property_type_as_native;
|
IntPtr actual_property_type_as_native;
|
||||||
IntPtr actual_data;
|
IntPtr actual_data;
|
||||||
bool raw_ret = gdk_property_get(window == null ? IntPtr.Zero : window.Handle, property == null ? IntPtr.Zero : property.Handle, type == null ? IntPtr.Zero : type.Handle, new UIntPtr (offset), new UIntPtr (length), pdelete, out actual_property_type_as_native, out actual_format, out actual_length, out actual_data);
|
bool raw_ret = gdk_property_get(window == null ? IntPtr.Zero : window.Handle, property == null ? IntPtr.Zero : property.Handle, type == null ? IntPtr.Zero : type.Handle, new UIntPtr (offset), new UIntPtr (length), pdelete == 0 ? false : true, out actual_property_type_as_native, out actual_format, out actual_length, out actual_data);
|
||||||
data = null;
|
data = null;
|
||||||
if (raw_ret) {
|
if (raw_ret) {
|
||||||
data = new byte [actual_length];
|
data = new byte [actual_length];
|
||||||
@ -48,3 +49,107 @@
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool Get (Gdk.Window window, Gdk.Atom property, Gdk.Atom type, ulong offset, ulong length, bool pdelete, out int[] data) {
|
||||||
|
IntPtr actual_property_type, raw_data;
|
||||||
|
int actual_length, format;
|
||||||
|
bool ret = gdk_property_get(window == null ? IntPtr.Zero : window.Handle, property == null ? IntPtr.Zero : property.Handle, type == null ? IntPtr.Zero : type.Handle, new UIntPtr (offset), new UIntPtr (length), pdelete, out actual_property_type, out format, out actual_length, out raw_data);
|
||||||
|
if (ret) {
|
||||||
|
try {
|
||||||
|
int block_size;
|
||||||
|
if (format == 32) { // data returned in blocks the size of a C long
|
||||||
|
#if WIN64LONGS
|
||||||
|
block_size = int.Size;
|
||||||
|
#else
|
||||||
|
block_size = IntPtr.Size;
|
||||||
|
#endif
|
||||||
|
} else if (format == 8 || format == 16)
|
||||||
|
block_size = format;
|
||||||
|
else
|
||||||
|
throw new NotSupportedException (String.Format ("Unable to read properties in {0}-bit format", format));
|
||||||
|
|
||||||
|
int size = actual_length / block_size;
|
||||||
|
data = new int [size];
|
||||||
|
for (int idx = 0; idx < size; idx++) {
|
||||||
|
IntPtr elem_ptr = new IntPtr (raw_data.ToInt64 () + idx * block_size);
|
||||||
|
switch (format) {
|
||||||
|
case 8:
|
||||||
|
data [idx] = Marshal.ReadByte (elem_ptr);
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
data [idx] = Marshal.ReadInt16 (elem_ptr);
|
||||||
|
break;
|
||||||
|
case 32:
|
||||||
|
data [idx] = Marshal.ReadInt32 (elem_ptr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
GLib.Marshaller.Free (raw_data);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
data = null;
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Get (Gdk.Window window, Gdk.Atom property, bool pdelete, out int[] data) {
|
||||||
|
return Get (window, property, 0, uint.MaxValue - 3, pdelete, out data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Get (Gdk.Window window, Gdk.Atom property, ulong offset, ulong length, bool pdelete, out int[] data) {
|
||||||
|
return Get (window, property, Gdk.Atom.Intern ("CARDINAL", false), offset, length, pdelete, out data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Get (Gdk.Window window, Gdk.Atom property, bool pdelete, out Gdk.Atom[] data) {
|
||||||
|
return Get (window, property, 0, uint.MaxValue - 3, pdelete, out data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Get (Gdk.Window window, Gdk.Atom property, ulong offset, ulong length, bool pdelete, out Gdk.Atom[] atoms) {
|
||||||
|
int[] raw_atoms;
|
||||||
|
if (!Get (window, property, Gdk.Atom.Intern ("ATOM", false), offset, length, pdelete, out raw_atoms)) {
|
||||||
|
atoms = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
atoms = new Gdk.Atom [raw_atoms.GetLength (0)];
|
||||||
|
for (int idx = 0; idx < raw_atoms.GetLength (0); idx++) {
|
||||||
|
atoms [idx] = new Gdk.Atom (new IntPtr (raw_atoms [idx]));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Get (Gdk.Window window, Gdk.Atom property, bool pdelete, out Gdk.Rectangle[] rects) {
|
||||||
|
return Get (window, property, 0, uint.MaxValue - 3, pdelete, out rects);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Get (Gdk.Window window, Gdk.Atom property, ulong offset, ulong length, bool pdelete, out Gdk.Rectangle[] rects) {
|
||||||
|
int[] raw_rects;
|
||||||
|
if (!Get (window, property, Gdk.Atom.Intern ("CARDINAL", false), offset, length, pdelete, out raw_rects)) {
|
||||||
|
rects = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
rects = new Gdk.Rectangle [raw_rects.GetLength (0) / 4];
|
||||||
|
for (int idx = 0; idx < rects.GetLength (0); idx ++) {
|
||||||
|
rects [idx] = new Gdk.Rectangle (raw_rects [idx * 4], raw_rects [idx * 4 + 1], raw_rects [idx * 4 + 2], raw_rects [idx * 4 + 3]);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Get (Gdk.Window window, Gdk.Atom property, bool pdelete, out Gdk.Window[] windows) {
|
||||||
|
return Get (window, property, 0, uint.MaxValue - 3, pdelete, out windows);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Get (Gdk.Window window, Gdk.Atom property, ulong offset, ulong length, bool pdelete, out Gdk.Window[] windows) {
|
||||||
|
int[] raw_windows;
|
||||||
|
if (!Get (window, property, Gdk.Atom.Intern ("WINDOW", false), offset, length, pdelete, out raw_windows)) {
|
||||||
|
windows = null;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
windows = new Gdk.Window [raw_windows.GetLength (0)];
|
||||||
|
for (int idx = 0; idx < raw_windows.GetLength (0); idx ++) {
|
||||||
|
windows [idx] = Gdk.Window.ForeignNew ((uint) raw_windows [idx]);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@ -3,8 +3,7 @@ lib_LTLIBRARIES = libgdksharpglue-2.la
|
|||||||
libgdksharpglue_2_la_SOURCES = \
|
libgdksharpglue_2_la_SOURCES = \
|
||||||
dragcontext.c \
|
dragcontext.c \
|
||||||
device.c \
|
device.c \
|
||||||
vmglueheaders.h \
|
vmglueheaders.h
|
||||||
windowmanager.c
|
|
||||||
|
|
||||||
nodist_libgdksharpglue_2_la_SOURCES = generated.c
|
nodist_libgdksharpglue_2_la_SOURCES = generated.c
|
||||||
|
|
||||||
|
@ -1,276 +0,0 @@
|
|||||||
/* windowmanager.c : Glue to access the extended window
|
|
||||||
* manager hints via the root window properties using
|
|
||||||
* gdk_property_get ()
|
|
||||||
*
|
|
||||||
* This work is based on the specification found here:
|
|
||||||
* http://www.freedesktop.org/standards/wm-spec/
|
|
||||||
*
|
|
||||||
* Author: Boyd Timothy <btimothy@novell.com>
|
|
||||||
*
|
|
||||||
* Copyright (c) 2004 Novell, Inc.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of version 2 of the Lesser GNU General
|
|
||||||
* Public License as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this program; if not, write to the
|
|
||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
||||||
* Boston, MA 02111-1307, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <gdk/gdkscreen.h>
|
|
||||||
#include <gdk/gdkwindow.h>
|
|
||||||
#include <gdk/gdkproperty.h>
|
|
||||||
|
|
||||||
GList * gtksharp_get_gdk_net_supported (void);
|
|
||||||
guint * gtksharp_get_gdk_net_client_list (int *count);
|
|
||||||
gint gtksharp_get_gdk_net_number_of_desktops (void);
|
|
||||||
gint gtksharp_get_gdk_net_current_desktop (void);
|
|
||||||
guint gtksharp_get_gdk_net_active_window (void);
|
|
||||||
GList * gtksharp_get_gdk_net_workarea (void);
|
|
||||||
|
|
||||||
GList *
|
|
||||||
gtksharp_get_gdk_net_supported (void)
|
|
||||||
{
|
|
||||||
GdkAtom actual_property_type;
|
|
||||||
int actual_format;
|
|
||||||
int actual_length;
|
|
||||||
long *data = NULL;
|
|
||||||
GList *list = NULL;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!gdk_property_get (
|
|
||||||
gdk_screen_get_root_window (gdk_screen_get_default ()),
|
|
||||||
gdk_atom_intern ("_NET_SUPPORTED", FALSE),
|
|
||||||
gdk_atom_intern ("ATOM", FALSE),
|
|
||||||
0,
|
|
||||||
G_MAXLONG,
|
|
||||||
FALSE,
|
|
||||||
&actual_property_type,
|
|
||||||
&actual_format,
|
|
||||||
&actual_length,
|
|
||||||
(guchar **) &data)) {
|
|
||||||
gchar *actual_property_type_name;
|
|
||||||
g_critical ("Unable to get _NET_SUPPORTED");
|
|
||||||
actual_property_type_name = gdk_atom_name (actual_property_type);
|
|
||||||
if (actual_property_type_name) {
|
|
||||||
g_message ("actual_property_type: %s", actual_property_type_name);
|
|
||||||
g_free (actual_property_type_name);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Put all of the GdkAtoms into a GList to return */
|
|
||||||
for (i = 0; i < actual_length / sizeof (long); i ++) {
|
|
||||||
list = g_list_append (list, (GdkAtom) data [i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (data);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
guint *
|
|
||||||
gtksharp_get_gdk_net_client_list (int *count)
|
|
||||||
{
|
|
||||||
GdkAtom actual_property_type;
|
|
||||||
int actual_format;
|
|
||||||
int actual_length;
|
|
||||||
long *data = NULL;
|
|
||||||
guint * list = NULL;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!gdk_property_get (
|
|
||||||
gdk_screen_get_root_window (gdk_screen_get_default ()),
|
|
||||||
gdk_atom_intern ("_NET_CLIENT_LIST", FALSE),
|
|
||||||
gdk_atom_intern ("WINDOW", FALSE),
|
|
||||||
0,
|
|
||||||
G_MAXLONG,
|
|
||||||
FALSE,
|
|
||||||
&actual_property_type,
|
|
||||||
&actual_format,
|
|
||||||
&actual_length,
|
|
||||||
(guchar **) &data)) {
|
|
||||||
gchar *actual_property_type_name;
|
|
||||||
g_critical ("Unable to get _NET_CLIENT_LIST");
|
|
||||||
actual_property_type_name = gdk_atom_name (actual_property_type);
|
|
||||||
if (actual_property_type_name) {
|
|
||||||
g_message ("actual_property_type: %s", actual_property_type_name);
|
|
||||||
g_free (actual_property_type_name);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
*count = actual_length / sizeof (long);
|
|
||||||
list = g_malloc (*count * sizeof (guint));
|
|
||||||
/* Put all of the windows into a GList to return */
|
|
||||||
for (i = 0; i < *count; i ++) {
|
|
||||||
list [i] = data [i];
|
|
||||||
g_message ("WinID: %d", list [i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (data);
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
gint
|
|
||||||
gtksharp_get_gdk_net_number_of_desktops (void)
|
|
||||||
{
|
|
||||||
GdkAtom actual_property_type;
|
|
||||||
int actual_format;
|
|
||||||
int actual_length;
|
|
||||||
long *data = NULL;
|
|
||||||
gint num_of_desktops;
|
|
||||||
|
|
||||||
if (!gdk_property_get (
|
|
||||||
gdk_screen_get_root_window (gdk_screen_get_default ()),
|
|
||||||
gdk_atom_intern ("_NET_NUMBER_OF_DESKTOPS", FALSE),
|
|
||||||
gdk_atom_intern ("CARDINAL", FALSE),
|
|
||||||
0,
|
|
||||||
G_MAXLONG,
|
|
||||||
FALSE,
|
|
||||||
&actual_property_type,
|
|
||||||
&actual_format,
|
|
||||||
&actual_length,
|
|
||||||
(guchar **) &data)) {
|
|
||||||
gchar *actual_property_type_name;
|
|
||||||
g_critical ("Unable to get _NET_NUMBER_OF_DESKTOPS");
|
|
||||||
actual_property_type_name = gdk_atom_name (actual_property_type);
|
|
||||||
if (actual_property_type_name) {
|
|
||||||
g_message ("actual_property_type: %s", actual_property_type_name);
|
|
||||||
g_free (actual_property_type_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
num_of_desktops = (gint) data[0];
|
|
||||||
g_free (data);
|
|
||||||
|
|
||||||
return num_of_desktops;
|
|
||||||
}
|
|
||||||
|
|
||||||
gint
|
|
||||||
gtksharp_get_gdk_net_current_desktop (void)
|
|
||||||
{
|
|
||||||
GdkAtom actual_property_type;
|
|
||||||
int actual_format;
|
|
||||||
int actual_length;
|
|
||||||
long *data = NULL;
|
|
||||||
gint current_desktop;
|
|
||||||
|
|
||||||
if (!gdk_property_get (
|
|
||||||
gdk_screen_get_root_window (gdk_screen_get_default ()),
|
|
||||||
gdk_atom_intern ("_NET_CURRENT_DESKTOP", FALSE),
|
|
||||||
gdk_atom_intern ("CARDINAL", FALSE),
|
|
||||||
0,
|
|
||||||
G_MAXLONG,
|
|
||||||
FALSE,
|
|
||||||
&actual_property_type,
|
|
||||||
&actual_format,
|
|
||||||
&actual_length,
|
|
||||||
(guchar **) &data)) {
|
|
||||||
gchar *actual_property_type_name;
|
|
||||||
g_critical ("Unable to get _NET_CURRENT_DESKTOP");
|
|
||||||
actual_property_type_name = gdk_atom_name (actual_property_type);
|
|
||||||
if (actual_property_type_name) {
|
|
||||||
g_message ("actual_property_type: %s", actual_property_type_name);
|
|
||||||
g_free (actual_property_type_name);
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
current_desktop = (gint) data[0];
|
|
||||||
g_free (data);
|
|
||||||
|
|
||||||
return current_desktop;
|
|
||||||
}
|
|
||||||
|
|
||||||
guint
|
|
||||||
gtksharp_get_gdk_net_active_window (void)
|
|
||||||
{
|
|
||||||
GdkAtom actual_property_type;
|
|
||||||
int actual_format;
|
|
||||||
int actual_length;
|
|
||||||
long *data = NULL;
|
|
||||||
guint windowID = 0;
|
|
||||||
|
|
||||||
if (!gdk_property_get (
|
|
||||||
gdk_screen_get_root_window (gdk_screen_get_default ()),
|
|
||||||
gdk_atom_intern ("_NET_ACTIVE_WINDOW", FALSE),
|
|
||||||
gdk_atom_intern ("WINDOW", FALSE),
|
|
||||||
0,
|
|
||||||
G_MAXLONG,
|
|
||||||
FALSE,
|
|
||||||
&actual_property_type,
|
|
||||||
&actual_format,
|
|
||||||
&actual_length,
|
|
||||||
(guchar **) &data)) {
|
|
||||||
gchar *actualPropertyTypeName;
|
|
||||||
g_critical ("Unable to get _NET_ACTIVE_WINDOW");
|
|
||||||
actualPropertyTypeName = gdk_atom_name (actual_property_type);
|
|
||||||
if (actualPropertyTypeName) {
|
|
||||||
g_message ("actual_property_type: %s", actualPropertyTypeName);
|
|
||||||
g_free(actualPropertyTypeName);
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
windowID = (gint) data [0];
|
|
||||||
g_free (data);
|
|
||||||
|
|
||||||
return windowID;
|
|
||||||
}
|
|
||||||
|
|
||||||
GList *
|
|
||||||
gtksharp_get_gdk_net_workarea (void)
|
|
||||||
{
|
|
||||||
GdkAtom actual_property_type;
|
|
||||||
int actual_format;
|
|
||||||
int actual_length;
|
|
||||||
long *data = NULL;
|
|
||||||
int i = 0;
|
|
||||||
GList *list = NULL;
|
|
||||||
|
|
||||||
if (!gdk_property_get (
|
|
||||||
gdk_screen_get_root_window (gdk_screen_get_default ()),
|
|
||||||
gdk_atom_intern ("_NET_WORKAREA", FALSE),
|
|
||||||
gdk_atom_intern ("CARDINAL", FALSE),
|
|
||||||
0,
|
|
||||||
G_MAXLONG,
|
|
||||||
FALSE,
|
|
||||||
&actual_property_type,
|
|
||||||
&actual_format,
|
|
||||||
&actual_length,
|
|
||||||
(guchar **) &data)) {
|
|
||||||
gchar *actualPropertyTypeName;
|
|
||||||
g_critical ("Unable to get _NET_WORKAREA");
|
|
||||||
actualPropertyTypeName = gdk_atom_name (actual_property_type);
|
|
||||||
if (actualPropertyTypeName) {
|
|
||||||
g_message ("actual_property_type: %s", actualPropertyTypeName);
|
|
||||||
g_free(actualPropertyTypeName);
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < actual_length / sizeof (long); i += 4) {
|
|
||||||
GdkRectangle *rectangle = g_malloc(sizeof (GdkRectangle));
|
|
||||||
rectangle->x = (int) data [i];
|
|
||||||
rectangle->y = (int) data [i + 1];
|
|
||||||
rectangle->width = (int) data [i + 2];
|
|
||||||
rectangle->height = (int) data [i + 3];
|
|
||||||
list = g_list_append (list, rectangle);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (data != NULL)
|
|
||||||
g_free(data);
|
|
||||||
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user