[libwnck/wip/muktupavels/widgets] move widgets to separate library




commit 486d2b9c14d3fe88c11c762bd070355a3fcb3e23
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Wed Feb 23 01:00:16 2022 +0200

    move widgets to separate library

 libwnck/libwnck.h                                  |   5 -
 libwnck/meson.build                                |  30 +-
 libwnck/private.h                                  |  44 +--
 libwnck/screen.c                                   |  53 +--
 libwnck/screen.h                                   |  14 +-
 libwnck/util.c                                     |  53 +--
 libwnck/widgets/libwnck-3.map                      |   6 +
 libwnck/widgets/meson.build                        | 116 ++++++
 libwnck/{ => widgets}/pager-accessible-factory.c   |   0
 libwnck/{ => widgets}/pager-accessible-factory.h   |   0
 libwnck/{ => widgets}/pager-accessible.c           |   0
 libwnck/{ => widgets}/pager-accessible.h           |   2 -
 libwnck/{ => widgets}/pager.c                      |  19 +-
 libwnck/{ => widgets}/pager.h                      |   2 +-
 libwnck/widgets/private.h                          |  60 ++++
 libwnck/{ => widgets}/selector.c                   |  10 +-
 libwnck/{ => widgets}/selector.h                   |   0
 libwnck/{ => widgets}/tasklist.c                   |  62 +++-
 libwnck/{ => widgets}/tasklist.h                   |   2 +-
 libwnck/{ => widgets}/test-pager.c                 |   2 +
 libwnck/{ => widgets}/test-selector.c              |   2 +
 libwnck/{ => widgets}/test-tasklist.c              |   2 +
 libwnck/widgets/util.c                             | 141 ++++++++
 libwnck/{ => widgets}/window-action-menu.c         |   0
 libwnck/{ => widgets}/window-action-menu.h         |   2 +-
 .../{ => widgets}/wnck-image-menu-item-private.h   |   2 +-
 libwnck/{ => widgets}/wnck-image-menu-item.c       |   0
 libwnck/{ => widgets}/wnck.css                     |   0
 libwnck/widgets/wnck.gresource.xml                 |   6 +
 .../{ => widgets}/workspace-accessible-factory.c   |   0
 .../{ => widgets}/workspace-accessible-factory.h   |   0
 libwnck/{ => widgets}/workspace-accessible.c       |   0
 libwnck/{ => widgets}/workspace-accessible.h       |   2 -
 libwnck/widgets/xutils.c                           | 394 +++++++++++++++++++++
 libwnck/widgets/xutils.h                           |  87 +++++
 libwnck/window.c                                   |  10 +-
 libwnck/window.h                                   |   8 +
 libwnck/wnck-handle.c                              |   6 +
 libwnck/wnck.gresource.xml                         |   1 -
 libwnck/workspace.c                                |  24 +-
 libwnck/xutils.h                                   |   2 +-
 41 files changed, 941 insertions(+), 228 deletions(-)
---
diff --git a/libwnck/libwnck.h b/libwnck/libwnck.h
index 20f89f6f..e9d8a803 100644
--- a/libwnck/libwnck.h
+++ b/libwnck/libwnck.h
@@ -29,11 +29,6 @@
 #include <libwnck/workspace.h>
 #include <libwnck/screen.h>
 
-#include <libwnck/pager.h>
-#include <libwnck/tasklist.h>
-#include <libwnck/selector.h>
-
-#include <libwnck/window-action-menu.h>
 #include <libwnck/util.h>
 
 #include <libwnck/version.h>
diff --git a/libwnck/meson.build b/libwnck/meson.build
index 9f714d0a..bb345ef3 100644
--- a/libwnck/meson.build
+++ b/libwnck/meson.build
@@ -30,15 +30,11 @@ version_data.set('WNCK_MICRO_VERSION', micro_version)
 
 headers = [
   'libwnck.h',
-  'pager.h',
   'application.h',
   'class-group.h',
   'screen.h',
-  'selector.h',
-  'tasklist.h',
   'util.h',
   'window.h',
-  'window-action-menu.h',
   'workspace.h',
 ]
 
@@ -50,36 +46,19 @@ headers += configure_file(
 sources = [
   'application.c',
   'class-group.c',
-  'pager.c',
   'screen.c',
-  'selector.c',
-  'tasklist.c',
   'util.c',
-  'window-action-menu.c',
   'window.c',
   'wnck-handle-private.h',
   'wnck-handle.c',
   'wnck-icon-cache-private.h',
   'wnck-icon-cache.c',
-  'wnck-image-menu-item-private.h',
-  'wnck-image-menu-item.c',
   'wnck-resource-usage-private.h',
   'wnck-resource-usage.c',
   'workspace.c',
   'xutils.c',
 ]
 
-a11y_sources = [
-  'pager-accessible.c',
-  'pager-accessible.h',
-  'pager-accessible-factory.c',
-  'pager-accessible-factory.h',
-  'workspace-accessible.c',
-  'workspace-accessible.h',
-  'workspace-accessible-factory.c',
-  'workspace-accessible-factory.h',
-]
-
 enum_types = gnome.mkenums_simple('wnck-enum-types',
   sources : headers,
   install_header: true,
@@ -122,7 +101,7 @@ libwnck_dep = declare_dependency(
 
 libwnck_lib = shared_library(LIBNAME,
   dependencies: libwnck_dep,
-  sources: sources + a11y_sources + enum_types + resources,
+  sources: sources + enum_types + resources,
   version: '@0@.@1@.@2@'.format(LIBWNCK_SOVERSION, LIBWNCK_CURRENT, LIBWNCK_REVISION),
   soversion: LIBWNCK_SOVERSION,
   link_depends: mapfile,
@@ -137,7 +116,7 @@ if not introspection.disabled()
     namespace: 'Wnck',
     nsversion: MODULE_VERSION,
     export_packages: PACKAGE_NAME,
-    includes: ['GObject-2.0', 'GdkPixbuf-2.0', 'Gtk-3.0'],
+    includes: ['GObject-2.0', 'GdkPixbuf-2.0'],
     extra_args: '--c-include=@0@/@0@.h'.format(meson.project_name()),
     install: true
   )
@@ -155,9 +134,6 @@ endif
 
 test_progs = [
   'test-wnck',
-  'test-tasklist',
-  'test-selector',
-  'test-pager',
   'test-urgent',
   'test-shutdown',
 ]
@@ -170,3 +146,5 @@ foreach prog: progs + test_progs
     install: progs.contains(prog) and get_option('install_tools'),
     install_dir: bindir)
 endforeach
+
+subdir('widgets')
diff --git a/libwnck/private.h b/libwnck/private.h
index 3336f38c..4b029bfe 100644
--- a/libwnck/private.h
+++ b/libwnck/private.h
@@ -28,17 +28,11 @@
 #include "workspace.h"
 #include "application.h"
 #include "xutils.h"
-#include "pager.h"
 #include "util.h"
 #include "wnck-handle-private.h"
-#ifdef HAVE_STARTUP_NOTIFICATION
-#include <libsn/sn.h>
-#endif
 
 G_BEGIN_DECLS
 
-#define WNCK_ACTIVATE_TIMEOUT 1
-
 WnckHandle *_wnck_get_handle (void);
 
 WnckClientType _wnck_get_client_type (void);
@@ -62,13 +56,12 @@ void        _wnck_window_destroy (WnckWindow *window);
 
 void        _wnck_window_load_icons (WnckWindow *window);
 
-char*       _wnck_window_get_name_for_display (WnckWindow *window,
-                                               gboolean    use_icon_name,
-                                               gboolean    use_state_decorations);
-const char* _wnck_window_get_startup_id (WnckWindow *window);
+char*       wnck_window_get_name_for_display (WnckWindow *window,
+                                              gboolean    use_icon_name,
+                                              gboolean    use_state_decorations);
+const char* wnck_window_get_startup_id (WnckWindow *window);
 
 time_t      _wnck_window_get_needs_attention_time (WnckWindow *window);
-time_t      _wnck_window_or_transient_get_needs_attention_time (WnckWindow *window);
 
 WnckWorkspace* _wnck_workspace_create  (int            number, 
                                         WnckScreen    *screen);
@@ -80,11 +73,6 @@ void _wnck_window_set_application    (WnckWindow      *window,
 void _wnck_window_set_class_group (WnckWindow     *window,
                                   WnckClassGroup *class_group);
 
-/* this one is in pager.c since it needs code from there to draw the icon */
-void _wnck_window_set_as_drag_icon (WnckWindow     *window,
-                                    GdkDragContext *context,
-                                    GtkWidget      *drag_source);
-
 void _wnck_application_add_window    (WnckApplication *app,
                                       WnckWindow      *window);
 void _wnck_application_remove_window (WnckApplication *app,
@@ -127,32 +115,8 @@ Window     _wnck_screen_get_xroot      (WnckScreen *screen);
 Screen    *_wnck_screen_get_xscreen    (WnckScreen *screen);
 GdkScreen *_wnck_screen_get_gdk_screen (WnckScreen *screen);
 
-#ifdef HAVE_STARTUP_NOTIFICATION
-SnDisplay* _wnck_screen_get_sn_display (WnckScreen *screen);
-#endif
-
 WnckHandle    *_wnck_screen_get_handle          (WnckScreen    *screen);
 
-void           _wnck_pager_activate_workspace   (WnckWorkspace *wspace,
-                                                 guint32        timestamp);
-int            _wnck_pager_get_n_workspaces     (WnckPager     *pager);
-const char*    _wnck_pager_get_workspace_name   (WnckPager     *pager,
-                                                 int            i);
-WnckWorkspace* _wnck_pager_get_active_workspace (WnckPager     *pager);
-WnckWorkspace* _wnck_pager_get_workspace        (WnckPager     *pager,
-                                                 int            i);
-void           _wnck_pager_get_workspace_rect   (WnckPager     *pager,
-                                                 int            i,
-                                                 GdkRectangle  *rect);
-
-void           _make_gtk_label_bold   (GtkLabel *label);
-void           _make_gtk_label_normal (GtkLabel *label);
-
-void           _wnck_selector_set_window_icon   (GtkWidget     *image,
-                                                 WnckWindow    *window);
-
-void           _wnck_ensure_fallback_style      (void);
-
 G_END_DECLS
 
 #endif /* WNCK_PRIVATE_H */
diff --git a/libwnck/screen.c b/libwnck/screen.c
index 094f23ef..f1029438 100644
--- a/libwnck/screen.c
+++ b/libwnck/screen.c
@@ -103,14 +103,10 @@ struct _WnckScreenPrivate
 
   guint update_handler;
 
-#ifdef HAVE_STARTUP_NOTIFICATION
-  SnDisplay *sn_display;
-#endif
-
   guint showing_desktop : 1;
 
   guint vertical_workspaces : 1;
-  _WnckLayoutCorner starting_corner;
+  WnckLayoutCorner starting_corner;
   gint rows_of_workspaces;
   gint columns_of_workspaces;
 
@@ -498,30 +494,9 @@ wnck_screen_finalize (GObject *object)
   g_free (screen->priv->wm_name);
   screen->priv->wm_name = NULL;
 
-#ifdef HAVE_STARTUP_NOTIFICATION
-  sn_display_unref (screen->priv->sn_display);
-  screen->priv->sn_display = NULL;
-#endif
-
   G_OBJECT_CLASS (wnck_screen_parent_class)->finalize (object);
 }
 
-#ifdef HAVE_STARTUP_NOTIFICATION
-static void
-sn_error_trap_push (SnDisplay *display,
-                    Display   *xdisplay)
-{
-  _wnck_error_trap_push (xdisplay);
-}
-
-static void
-sn_error_trap_pop (SnDisplay *display,
-                   Display   *xdisplay)
-{
-  _wnck_error_trap_pop (xdisplay);
-}
-#endif /* HAVE_STARTUP_NOTIFICATION */
-
 void
 _wnck_screen_construct (WnckScreen *screen,
                         WnckHandle *handle,
@@ -535,12 +510,6 @@ _wnck_screen_construct (WnckScreen *screen,
   screen->priv->xscreen = ScreenOfDisplay (display, number);
   screen->priv->number = number;
 
-#ifdef HAVE_STARTUP_NOTIFICATION
-  screen->priv->sn_display = sn_display_new (display,
-                                             sn_error_trap_push,
-                                             sn_error_trap_pop);
-#endif
-
   screen->priv->bg_pixmap = None;
 
   screen->priv->orig_event_mask = _wnck_select_input (screen->priv->xscreen,
@@ -2460,11 +2429,11 @@ _wnck_screen_get_xscreen (WnckScreen *screen)
  * to make it really better, use a WnckScreenLayout struct. We might also want
  * to wait for deprecation of WnckWorkspaceLayout. */
 void
-_wnck_screen_get_workspace_layout (WnckScreen             *screen,
-                                   _WnckLayoutOrientation *orientation,
-                                   int                    *rows,
-                                   int                    *columns,
-                                   _WnckLayoutCorner      *starting_corner)
+wnck_screen_get_workspace_layout (WnckScreen            *screen,
+                                  WnckLayoutOrientation *orientation,
+                                  int                   *rows,
+                                  int                   *columns,
+                                  WnckLayoutCorner      *starting_corner)
 {
   g_return_if_fail (WNCK_IS_SCREEN (screen));
 
@@ -2618,16 +2587,6 @@ wnck_screen_move_viewport (WnckScreen *screen,
   _wnck_change_viewport (screen->priv->xscreen, x, y);
 }
 
-#ifdef HAVE_STARTUP_NOTIFICATION
-SnDisplay*
-_wnck_screen_get_sn_display (WnckScreen *screen)
-{
-  g_return_val_if_fail (WNCK_IS_SCREEN (screen), NULL);
-
-  return screen->priv->sn_display;
-}
-#endif /* HAVE_STARTUP_NOTIFICATION */
-
 void
 _wnck_screen_change_workspace_name (WnckScreen *screen,
                                     int         number,
diff --git a/libwnck/screen.h b/libwnck/screen.h
index 3140ea51..25942201 100644
--- a/libwnck/screen.h
+++ b/libwnck/screen.h
@@ -167,7 +167,7 @@ typedef enum
 {
   WNCK_LAYOUT_ORIENTATION_HORIZONTAL,
   WNCK_LAYOUT_ORIENTATION_VERTICAL
-} _WnckLayoutOrientation;
+} WnckLayoutOrientation;
 
 /**
  * WnckLayoutCorner:
@@ -189,7 +189,7 @@ typedef enum
   WNCK_LAYOUT_CORNER_TOPRIGHT,
   WNCK_LAYOUT_CORNER_BOTTOMRIGHT,
   WNCK_LAYOUT_CORNER_BOTTOMLEFT
-} _WnckLayoutCorner;
+} WnckLayoutCorner;
 
 GType wnck_screen_get_type (void) G_GNUC_CONST;
 
@@ -221,11 +221,11 @@ void           wnck_screen_toggle_showing_desktop   (WnckScreen *screen,
 void           wnck_screen_move_viewport            (WnckScreen *screen,
                                                      int         x,
                                                      int         y);
-void           _wnck_screen_get_workspace_layout     (WnckScreen             *screen,
-                                                      _WnckLayoutOrientation *orientation,
-                                                      int                    *rows,
-                                                      int                    *columns,
-                                                      _WnckLayoutCorner      *starting_corner);
+void           wnck_screen_get_workspace_layout     (WnckScreen            *screen,
+                                                     WnckLayoutOrientation *orientation,
+                                                     int                   *rows,
+                                                     int                   *columns,
+                                                     WnckLayoutCorner      *starting_corner);
 int            wnck_screen_try_set_workspace_layout (WnckScreen *screen,
                                                      int         current_token,
                                                      int         rows,
diff --git a/libwnck/util.c b/libwnck/util.c
index 64f796e5..aa73eac5 100644
--- a/libwnck/util.c
+++ b/libwnck/util.c
@@ -29,6 +29,10 @@
 #include <gdk/gdkx.h>
 #include <string.h>
 
+#ifdef HAVE_STARTUP_NOTIFICATION
+#include <libsn/sn.h>
+#endif
+
 /**
  * SECTION:resource
  * @short_description: reading resource usage of X clients.
@@ -235,32 +239,6 @@ _wnck_get_default_mini_icon_size (void)
   return _wnck_handle_get_default_mini_icon_size (_wnck_get_handle ());
 }
 
-/**
- * _make_gtk_label_bold:
- * @label: The label.
- *
- * Switches the font of label to a bold equivalent.
- **/
-void
-_make_gtk_label_bold (GtkLabel *label)
-{
-  GtkStyleContext *context;
-
-  _wnck_ensure_fallback_style ();
-
-  context = gtk_widget_get_style_context (GTK_WIDGET (label));
-  gtk_style_context_add_class (context, "wnck-needs-attention");
-}
-
-void
-_make_gtk_label_normal (GtkLabel *label)
-{
-  GtkStyleContext *context;
-
-  context = gtk_widget_get_style_context (GTK_WIDGET (label));
-  gtk_style_context_remove_class (context, "wnck-needs-attention");
-}
-
 #ifdef HAVE_STARTUP_NOTIFICATION
 static gboolean
 _wnck_util_sn_utf8_validator (const char *str,
@@ -328,26 +306,3 @@ wnck_shutdown (void)
 
   _wnck_read_resources_shutdown_all ();
 }
-
-void
-_wnck_ensure_fallback_style (void)
-{
-  static gboolean css_loaded = FALSE;
-  GtkCssProvider *provider;
-  guint priority;
-
-  if (css_loaded)
-    return;
-
-  provider = gtk_css_provider_new ();
-  gtk_css_provider_load_from_resource (provider, "/org/gnome/libwnck/wnck.css");
-
-  priority = GTK_STYLE_PROVIDER_PRIORITY_FALLBACK;
-  gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
-                                             GTK_STYLE_PROVIDER (provider),
-                                             priority);
-
-  g_object_unref (provider);
-
-  css_loaded = TRUE;
-}
diff --git a/libwnck/widgets/libwnck-3.map b/libwnck/widgets/libwnck-3.map
new file mode 100644
index 00000000..7b17479e
--- /dev/null
+++ b/libwnck/widgets/libwnck-3.map
@@ -0,0 +1,6 @@
+{
+global:
+    wnck_*;
+local:
+    *;
+};
diff --git a/libwnck/widgets/meson.build b/libwnck/widgets/meson.build
new file mode 100644
index 00000000..ceaa95d1
--- /dev/null
+++ b/libwnck/widgets/meson.build
@@ -0,0 +1,116 @@
+gnome = import('gnome')
+
+libwnck_includedir = join_paths(PACKAGE_NAME, meson.project_name())
+
+headers = [
+  'pager.h',
+  'selector.h',
+  'tasklist.h',
+  'window-action-menu.h',
+]
+
+sources = [
+  'pager.c',
+  'selector.c',
+  'tasklist.c',
+  'util.c',
+  'window-action-menu.c',
+  'wnck-image-menu-item-private.h',
+  'wnck-image-menu-item.c',
+  'xutils.c',
+]
+
+a11y_sources = [
+  'pager-accessible.c',
+  'pager-accessible.h',
+  'pager-accessible-factory.c',
+  'pager-accessible-factory.h',
+  'workspace-accessible.c',
+  'workspace-accessible.h',
+  'workspace-accessible-factory.c',
+  'workspace-accessible-factory.h',
+]
+
+enum_types = gnome.mkenums_simple('wnck-widgets-enum-types',
+  sources : headers,
+  install_header: true,
+  install_dir: join_paths(includedir, libwnck_includedir)
+)
+
+resources = gnome.compile_resources(
+  '@0@-resources'.format(meson.project_name()),
+  'wnck.gresource.xml',
+  source_dir: '.',
+  c_name: meson.project_name()
+)
+
+libwnck_cflags = [
+  '-DG_LOG_DOMAIN="Wnck"',
+  '-DWNCK_I_KNOW_THIS_IS_UNSTABLE',
+  '-DWNCK_LOCALEDIR="@0@"'.format(localedir),
+  '-DWNCK_COMPILATION',
+  '-DSN_API_NOT_YET_FROZEN=1'
+]
+
+mapfile = MODULE_NAME + '.map'
+libwnck_ldflags = [
+  '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile),
+]
+
+if get_option('deprecation_flags')
+  foreach domain: ['G', 'ATK', 'GDK', 'GDK_PIXBUF', 'GTK', 'WNCK']
+    libwnck_cflags += '-D@0@_DISABLE_DEPRECATED'.format(domain)
+  endforeach
+endif
+
+libwnck_widgets_dep = declare_dependency(
+  link_with: libwnck_lib,
+  include_directories: default_includes,
+  dependencies: LIBWNCK_DEPS,
+  compile_args: libwnck_cflags,
+  sources: headers + [enum_types[1]],
+  link_args: libwnck_ldflags,
+)
+
+MODULE_NAME_W = meson.project_name() + '-widgets-@0@'.format(LIBWNCK_CURRENT)
+LIBNAME_W = MODULE_NAME_W.split('lib')[1]
+
+libwnck_widgets_lib = shared_library(LIBNAME_W,
+  dependencies: libwnck_widgets_dep,
+  sources: sources + a11y_sources + enum_types + resources,
+  version: '@0@.@1@.@2@'.format(LIBWNCK_SOVERSION, LIBWNCK_CURRENT, LIBWNCK_REVISION),
+  soversion: LIBWNCK_SOVERSION,
+  link_depends: mapfile,
+  install: true,
+)
+
+introspection = get_option('introspection')
+if not introspection.disabled()
+  find_program('g-ir-scanner', required: introspection.enabled())
+  gnome.generate_gir(libwnck_widgets_lib,
+    sources: headers + sources + enum_types,
+    namespace: 'Wnck',
+    nsversion: MODULE_VERSION,
+    export_packages: PACKAGE_NAME,
+    includes: ['GObject-2.0', 'GdkPixbuf-2.0', 'Gtk-3.0'],
+    extra_args: '--c-include=@0@/@0@.h'.format(meson.project_name()),
+    install: true
+  )
+endif
+
+install_headers(headers, subdir: libwnck_includedir)
+
+test_progs = [
+  'test-tasklist',
+  'test-selector',
+  'test-pager',
+]
+
+foreach prog: test_progs
+  executable(prog, [prog + '.c'],
+    include_directories: default_includes,
+    dependencies: libwnck_widgets_dep,
+    link_with: libwnck_widgets_lib,
+    install: false,
+    install_dir: bindir)
+endforeach
diff --git a/libwnck/pager-accessible-factory.c b/libwnck/widgets/pager-accessible-factory.c
similarity index 100%
rename from libwnck/pager-accessible-factory.c
rename to libwnck/widgets/pager-accessible-factory.c
diff --git a/libwnck/pager-accessible-factory.h b/libwnck/widgets/pager-accessible-factory.h
similarity index 100%
rename from libwnck/pager-accessible-factory.h
rename to libwnck/widgets/pager-accessible-factory.h
diff --git a/libwnck/pager-accessible.c b/libwnck/widgets/pager-accessible.c
similarity index 100%
rename from libwnck/pager-accessible.c
rename to libwnck/widgets/pager-accessible.c
diff --git a/libwnck/pager-accessible.h b/libwnck/widgets/pager-accessible.h
similarity index 98%
rename from libwnck/pager-accessible.h
rename to libwnck/widgets/pager-accessible.h
index fd3dac6a..0f0909e4 100644
--- a/libwnck/pager-accessible.h
+++ b/libwnck/widgets/pager-accessible.h
@@ -21,8 +21,6 @@
 
 #include <gtk/gtk.h>
 #include <atk/atk.h>
-#include "pager.h"
-#include "screen.h"
 
 G_BEGIN_DECLS
 
diff --git a/libwnck/pager.c b/libwnck/widgets/pager.c
similarity index 99%
rename from libwnck/pager.c
rename to libwnck/widgets/pager.c
index c769d62c..b0e0811c 100644
--- a/libwnck/pager.c
+++ b/libwnck/widgets/pager.c
@@ -28,8 +28,6 @@
 #include <glib/gi18n-lib.h>
 
 #include "pager.h"
-#include "workspace.h"
-#include "window.h"
 #include "xutils.h"
 #include "pager-accessible-factory.h"
 #include "workspace-accessible-factory.h"
@@ -58,6 +56,7 @@
  */
 
 #define N_SCREEN_CONNECTIONS 11
+#define WNCK_NO_MANAGER_TOKEN 0
 
 struct _WnckPagerPrivate
 {
@@ -300,14 +299,14 @@ _wnck_pager_set_screen (WnckPager *pager)
 
   if (!wnck_pager_set_layout_hint (pager))
     {
-      _WnckLayoutOrientation orientation;
+      WnckLayoutOrientation orientation;
 
       /* we couldn't set the layout on the screen. This means someone else owns
        * it. Let's at least show the correct layout. */
-      _wnck_screen_get_workspace_layout (pager->priv->screen,
-                                         &orientation,
-                                         &pager->priv->n_rows,
-                                         NULL, NULL);
+      wnck_screen_get_workspace_layout (pager->priv->screen,
+                                        &orientation,
+                                        &pager->priv->n_rows,
+                                        NULL, NULL);
 
       /* test in this order to default to horizontal in case there was in issue
        * when fetching the layout */
@@ -2857,9 +2856,13 @@ wnck_pager_get_background (WnckPager *pager,
 
   if (p != None)
     {
+      GdkDisplay *display;
       Screen *xscreen;
 
-      xscreen = WNCK_SCREEN_XSCREEN (pager->priv->screen);
+      //xscreen = WNCK_SCREEN_XSCREEN (pager->priv->screen);
+
+      display = gdk_display_get_default ();
+      xscreen = gdk_x11_screen_get_xscreen (gdk_display_get_default_screen (display));
       pix = _wnck_gdk_pixbuf_get_from_pixmap (xscreen, p);
     }
 
diff --git a/libwnck/pager.h b/libwnck/widgets/pager.h
similarity index 99%
rename from libwnck/pager.h
rename to libwnck/widgets/pager.h
index c67f2fa3..9a92ac5e 100644
--- a/libwnck/pager.h
+++ b/libwnck/widgets/pager.h
@@ -27,7 +27,7 @@
 #define WNCK_PAGER_H
 
 #include <gtk/gtk.h>
-#include <libwnck/screen.h>
+#include <libwnck/libwnck.h>
 
 G_BEGIN_DECLS
 
diff --git a/libwnck/widgets/private.h b/libwnck/widgets/private.h
new file mode 100644
index 00000000..e00c8192
--- /dev/null
+++ b/libwnck/widgets/private.h
@@ -0,0 +1,60 @@
+/* Private stuff */
+/* vim: set sw=2 et: */
+
+/*
+ * Copyright (C) 2001 Havoc Pennington
+ * Copyright (C) 2006-2007 Vincent Untz
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef WNCK_PRIVATE_H
+#define WNCK_PRIVATE_H
+
+#include <libwnck/libwnck.h>
+#include "pager.h"
+
+G_BEGIN_DECLS
+
+#define WNCK_ACTIVATE_TIMEOUT 1
+
+
+/* this one is in pager.c since it needs code from there to draw the icon */
+void _wnck_window_set_as_drag_icon (WnckWindow     *window,
+                                    GdkDragContext *context,
+                                    GtkWidget      *drag_source);
+
+void           _make_gtk_label_bold   (GtkLabel *label);
+void           _make_gtk_label_normal (GtkLabel *label);
+
+void           _wnck_pager_activate_workspace   (WnckWorkspace *wspace,
+                                                 guint32        timestamp);
+int            _wnck_pager_get_n_workspaces     (WnckPager     *pager);
+const char*    _wnck_pager_get_workspace_name   (WnckPager     *pager,
+                                                 int            i);
+WnckWorkspace* _wnck_pager_get_active_workspace (WnckPager     *pager);
+WnckWorkspace* _wnck_pager_get_workspace        (WnckPager     *pager,
+                                                 int            i);
+void           _wnck_pager_get_workspace_rect   (WnckPager     *pager,
+                                                 int            i,
+                                                 GdkRectangle  *rect);
+
+void           _wnck_selector_set_window_icon   (GtkWidget     *image,
+                                                 WnckWindow    *window);
+
+void           _wnck_ensure_fallback_style      (void);
+
+G_END_DECLS
+
+#endif /* WNCK_PRIVATE_H */
diff --git a/libwnck/selector.c b/libwnck/widgets/selector.c
similarity index 99%
rename from libwnck/selector.c
rename to libwnck/widgets/selector.c
index b975b27f..708b7ae7 100644
--- a/libwnck/selector.c
+++ b/libwnck/widgets/selector.c
@@ -28,11 +28,11 @@
 #include <config.h>
 
 #include <gtk/gtk.h>
+#include <gdk/gdkx.h>
 
 #include <glib/gi18n-lib.h>
 #include "selector.h"
-#include "libwnck.h"
-#include "screen.h"
+#include <libwnck/libwnck.h>
 #include "wnck-image-menu-item-private.h"
 #include "private.h"
 
@@ -356,7 +356,7 @@ wnck_selector_window_name_changed (WnckWindow *window,
   item = g_hash_table_lookup (selector->priv->window_hash, window);
   if (item != NULL)
     {
-      window_name = _wnck_window_get_name_for_display (window, FALSE, TRUE);
+      window_name = wnck_window_get_name_for_display (window, FALSE, TRUE);
       gtk_menu_item_set_label (GTK_MENU_ITEM (item), window_name);
       g_free (window_name);
     }
@@ -410,7 +410,7 @@ wnck_selector_window_state_changed (WnckWindow *window,
   if (changed_mask &
       (WNCK_WINDOW_STATE_MINIMIZED | WNCK_WINDOW_STATE_SHADED))
     {
-      window_name = _wnck_window_get_name_for_display (window, FALSE, TRUE);
+      window_name = wnck_window_get_name_for_display (window, FALSE, TRUE);
       gtk_menu_item_set_label (GTK_MENU_ITEM (item), window_name);
       g_free (window_name);
     }
@@ -627,7 +627,7 @@ wnck_selector_create_window (WnckSelector *selector, WnckWindow *window)
   GtkWidget *item;
   char *name;
 
-  name = _wnck_window_get_name_for_display (window, FALSE, TRUE);
+  name = wnck_window_get_name_for_display (window, FALSE, TRUE);
 
   item = wnck_selector_item_new (selector, name, window);
   g_free (name);
diff --git a/libwnck/selector.h b/libwnck/widgets/selector.h
similarity index 100%
rename from libwnck/selector.h
rename to libwnck/widgets/selector.h
diff --git a/libwnck/tasklist.c b/libwnck/widgets/tasklist.c
similarity index 98%
rename from libwnck/tasklist.c
rename to libwnck/widgets/tasklist.c
index 8791b103..885cab58 100644
--- a/libwnck/tasklist.c
+++ b/libwnck/widgets/tasklist.c
@@ -28,14 +28,15 @@
 #include <stdio.h>
 #include <glib/gi18n-lib.h>
 #include "tasklist.h"
-#include "window.h"
-#include "class-group.h"
 #include "window-action-menu.h"
 #include "wnck-image-menu-item-private.h"
-#include "workspace.h"
 #include "xutils.h"
 #include "private.h"
 
+#ifdef HAVE_STARTUP_NOTIFICATION
+#include <libsn/sn.h>
+#endif
+
 /**
  * SECTION:tasklist
  * @short_description: a tasklist widget, showing the list of windows as a list
@@ -92,7 +93,7 @@ typedef struct _WnckTaskClass   WnckTaskClass;
 
 #define DEFAULT_GROUPING_LIMIT 80
 
-#define MINI_ICON_SIZE _wnck_get_default_mini_icon_size ()
+#define MINI_ICON_SIZE 16 /*_wnck_get_default_mini_icon_size ()*/
 #define TASKLIST_BUTTON_PADDING 4
 #define TASKLIST_TEXT_MAX_WIDTH 25 /* maximum width in characters */
 
@@ -228,6 +229,10 @@ struct _WnckTasklistPrivate
   void *icon_loader_data;
   GDestroyNotify free_icon_loader_data;
 
+#ifdef HAVE_STARTUP_NOTIFICATION
+  SnDisplay *sn_display;
+#endif
+
 #ifdef HAVE_STARTUP_NOTIFICATION
   SnMonitorContext *sn_context;
   guint startup_sequence_timeout;
@@ -2137,21 +2142,45 @@ foreach_tasklist (WnckTasklist *tasklist,
   wnck_tasklist_update_lists (tasklist);
 }
 
+#ifdef HAVE_STARTUP_NOTIFICATION
+static void
+sn_error_trap_push (SnDisplay *display,
+                    Display   *xdisplay)
+{
+  _wnck_error_trap_push (xdisplay);
+}
+
+static void
+sn_error_trap_pop (SnDisplay *display,
+                   Display   *xdisplay)
+{
+  _wnck_error_trap_pop (xdisplay);
+}
+#endif /* HAVE_STARTUP_NOTIFICATION */
+
 static void
 wnck_tasklist_realize (GtkWidget *widget)
 {
   WnckTasklist *tasklist;
   GdkScreen *gdkscreen;
+  GdkDisplay *gdkdisplay;
 
   tasklist = WNCK_TASKLIST (widget);
 
   gdkscreen = gtk_widget_get_screen (widget);
+  gdkdisplay = gdk_screen_get_display (gdkscreen);
   tasklist->priv->screen = wnck_screen_get (gdk_x11_screen_get_screen_number (gdkscreen));
   g_assert (tasklist->priv->screen != NULL);
 
+#ifdef HAVE_STARTUP_NOTIFICATION
+  tasklist->priv->sn_display = sn_display_new (gdk_x11_display_get_xdisplay (gdkdisplay),
+                                               sn_error_trap_push,
+                                               sn_error_trap_pop);
+#endif
+
 #ifdef HAVE_STARTUP_NOTIFICATION
   tasklist->priv->sn_context =
-    sn_monitor_context_new (_wnck_screen_get_sn_display (tasklist->priv->screen),
+    sn_monitor_context_new (tasklist->priv->sn_display,
                             wnck_screen_get_number (tasklist->priv->screen),
                             wnck_tasklist_sn_event,
                             tasklist,
@@ -2183,6 +2212,11 @@ wnck_tasklist_unrealize (GtkWidget *widget)
   tasklist->priv->sn_context = NULL;
 #endif
 
+#ifdef HAVE_STARTUP_NOTIFICATION
+  sn_display_unref (tasklist->priv->sn_display);
+  tasklist->priv->sn_display = NULL;
+#endif
+
   (* GTK_WIDGET_CLASS (wnck_tasklist_parent_class)->unrealize) (widget);
 
   tasklist_instances = g_slist_remove (tasklist_instances, tasklist);
@@ -3485,8 +3519,8 @@ wnck_task_popup_menu (WnckTask *task,
                               0);
     }
 
-  gtk_menu_set_screen (GTK_MENU (menu),
-                      _wnck_screen_get_gdk_screen (task->tasklist->priv->screen));
+  /*gtk_menu_set_screen (GTK_MENU (menu),
+                      _wnck_screen_get_gdk_screen (task->tasklist->priv->screen));*/
 
   gtk_widget_show (menu);
   gtk_menu_popup_at_widget (GTK_MENU (menu), task->button,
@@ -3550,8 +3584,8 @@ wnck_task_get_text (WnckTask *task,
                                g_list_length (task->windows));
 
     case WNCK_TASK_WINDOW:
-      return _wnck_window_get_name_for_display (task->window,
-                                                icon_text, include_state);
+      return wnck_window_get_name_for_display (task->window,
+                                               icon_text, include_state);
       break;
 
     case WNCK_TASK_STARTUP_SEQUENCE:
@@ -3743,7 +3777,7 @@ wnck_task_get_needs_attention (WnckTask *task)
          if (wnck_window_or_transient_needs_attention (win_task->window))
            {
              needs_attention = TRUE;
-              task->start_needs_attention = MAX (task->start_needs_attention, 
_wnck_window_or_transient_get_needs_attention_time (win_task->window));
+              task->start_needs_attention = MAX (task->start_needs_attention, 
wnck_window_or_transient_get_needs_attention_time (win_task->window));
              break;
            }
 
@@ -3754,7 +3788,7 @@ wnck_task_get_needs_attention (WnckTask *task)
     case WNCK_TASK_WINDOW:
       needs_attention =
        wnck_window_or_transient_needs_attention (task->window);
-      task->start_needs_attention = _wnck_window_or_transient_get_needs_attention_time (task->window);
+      task->start_needs_attention = wnck_window_or_transient_get_needs_attention_time (task->window);
       break;
 
     case WNCK_TASK_STARTUP_SEQUENCE:
@@ -4146,8 +4180,8 @@ wnck_task_button_press_event (GtkWidget         *widget,
           g_object_add_weak_pointer (G_OBJECT (task->action_menu),
                                      (void**) &task->action_menu);
 
-          gtk_menu_set_screen (GTK_MENU (task->action_menu),
-                               _wnck_screen_get_gdk_screen (task->tasklist->priv->screen));
+          /*gtk_menu_set_screen (GTK_MENU (task->action_menu),
+                               _wnck_screen_get_gdk_screen (task->tasklist->priv->screen));*/
 
           gtk_widget_show (task->action_menu);
           gtk_menu_popup_at_widget (GTK_MENU (task->action_menu), task->button,
@@ -4605,7 +4639,7 @@ remove_startup_sequences_for_window (WnckTasklist *tasklist,
   const char *win_id;
   GList *tmp;
 
-  win_id = _wnck_window_get_startup_id (window);
+  win_id = wnck_window_get_startup_id (window);
   if (win_id == NULL)
     return;
 
diff --git a/libwnck/tasklist.h b/libwnck/widgets/tasklist.h
similarity index 99%
rename from libwnck/tasklist.h
rename to libwnck/widgets/tasklist.h
index 0659f9d6..75c058af 100644
--- a/libwnck/tasklist.h
+++ b/libwnck/widgets/tasklist.h
@@ -27,7 +27,7 @@
 #define WNCK_TASKLIST_H
 
 #include <gtk/gtk.h>
-#include <libwnck/screen.h>
+#include <libwnck/libwnck.h>
 
 G_BEGIN_DECLS
 
diff --git a/libwnck/test-pager.c b/libwnck/widgets/test-pager.c
similarity index 99%
rename from libwnck/test-pager.c
rename to libwnck/widgets/test-pager.c
index d60b0476..03d2130b 100644
--- a/libwnck/test-pager.c
+++ b/libwnck/widgets/test-pager.c
@@ -3,6 +3,8 @@
 #include <libwnck/libwnck.h>
 #include <gtk/gtk.h>
 
+#include "pager.h"
+
 static int n_rows = 1;
 static gboolean only_current = FALSE;
 static gboolean rtl = FALSE;
diff --git a/libwnck/test-selector.c b/libwnck/widgets/test-selector.c
similarity index 98%
rename from libwnck/test-selector.c
rename to libwnck/widgets/test-selector.c
index fb27ea38..ba672055 100644
--- a/libwnck/test-selector.c
+++ b/libwnck/widgets/test-selector.c
@@ -3,6 +3,8 @@
 #include <libwnck/libwnck.h>
 #include <gtk/gtk.h>
 
+#include "selector.h"
+
 static gboolean skip_tasklist = FALSE;
 
 static GOptionEntry entries[] = {
diff --git a/libwnck/test-tasklist.c b/libwnck/widgets/test-tasklist.c
similarity index 99%
rename from libwnck/test-tasklist.c
rename to libwnck/widgets/test-tasklist.c
index 6b27f5a9..9bb27cef 100644
--- a/libwnck/test-tasklist.c
+++ b/libwnck/widgets/test-tasklist.c
@@ -3,6 +3,8 @@
 #include <libwnck/libwnck.h>
 #include <gtk/gtk.h>
 
+#include "tasklist.h"
+
 static gboolean display_all = FALSE;
 static gboolean never_group = FALSE;
 static gboolean always_group = FALSE;
diff --git a/libwnck/widgets/util.c b/libwnck/widgets/util.c
new file mode 100644
index 00000000..4af6eaf2
--- /dev/null
+++ b/libwnck/widgets/util.c
@@ -0,0 +1,141 @@
+/* util header */
+/* vim: set sw=2 et: */
+
+/*
+ * Copyright (C) 2001 Havoc Pennington
+ * Copyright (C) 2006-2007 Vincent Untz
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include <glib/gi18n-lib.h>
+#include "xutils.h"
+#include "private.h"
+#include <gdk/gdkx.h>
+#include <string.h>
+
+#ifdef HAVE_STARTUP_NOTIFICATION
+#include <libsn/sn.h>
+#endif
+
+/**
+ * SECTION:misc
+ * @short_description: other additional features.
+ * @stability: Unstable
+ *
+ * These functions are utility functions providing some additional features to
+ * libwnck users.
+ */
+
+/**
+ * SECTION:icons
+ * @short_description: icons related functions.
+ * @stability: Unstable
+ *
+ * These functions are utility functions to manage icons for #WnckWindow and
+ * #WnckApplication.
+ */
+
+/**
+ * _make_gtk_label_bold:
+ * @label: The label.
+ *
+ * Switches the font of label to a bold equivalent.
+ **/
+void
+_make_gtk_label_bold (GtkLabel *label)
+{
+  GtkStyleContext *context;
+
+  _wnck_ensure_fallback_style ();
+
+  context = gtk_widget_get_style_context (GTK_WIDGET (label));
+  gtk_style_context_add_class (context, "wnck-needs-attention");
+}
+
+void
+_make_gtk_label_normal (GtkLabel *label)
+{
+  GtkStyleContext *context;
+
+  context = gtk_widget_get_style_context (GTK_WIDGET (label));
+  gtk_style_context_remove_class (context, "wnck-needs-attention");
+}
+
+#ifdef HAVE_STARTUP_NOTIFICATION
+static gboolean
+_wnck_util_sn_utf8_validator (const char *str,
+                              int         max_len)
+{
+  return g_utf8_validate (str, max_len, NULL);
+}
+#endif /* HAVE_STARTUP_NOTIFICATION */
+
+void
+_wnck_init (void)
+{
+  static gboolean done = FALSE;
+
+  if (!done)
+    {
+      bindtextdomain (GETTEXT_PACKAGE, WNCK_LOCALEDIR);
+      bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+
+#ifdef HAVE_STARTUP_NOTIFICATION
+      sn_set_utf8_validator (_wnck_util_sn_utf8_validator);
+#endif /* HAVE_STARTUP_NOTIFICATION */
+
+      done = TRUE;
+    }
+}
+
+Display *
+_wnck_get_default_display (void)
+{
+  GdkDisplay *display = gdk_display_get_default ();
+  /* FIXME: when we fix libwnck to not use the GDK default display, we will
+   * need to fix wnckprop accordingly. */
+  if (!GDK_IS_X11_DISPLAY (display))
+    {
+      g_warning ("libwnck is designed to work in X11 only, no valid display found");
+      return NULL;
+    }
+
+  return GDK_DISPLAY_XDISPLAY (display);
+}
+
+void
+_wnck_ensure_fallback_style (void)
+{
+  static gboolean css_loaded = FALSE;
+  GtkCssProvider *provider;
+  guint priority;
+
+  if (css_loaded)
+    return;
+
+  provider = gtk_css_provider_new ();
+  gtk_css_provider_load_from_resource (provider, "/org/gnome/libwnck/wnck.css");
+
+  priority = GTK_STYLE_PROVIDER_PRIORITY_FALLBACK;
+  gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
+                                             GTK_STYLE_PROVIDER (provider),
+                                             priority);
+
+  g_object_unref (provider);
+
+  css_loaded = TRUE;
+}
diff --git a/libwnck/window-action-menu.c b/libwnck/widgets/window-action-menu.c
similarity index 100%
rename from libwnck/window-action-menu.c
rename to libwnck/widgets/window-action-menu.c
diff --git a/libwnck/window-action-menu.h b/libwnck/widgets/window-action-menu.h
similarity index 98%
rename from libwnck/window-action-menu.h
rename to libwnck/widgets/window-action-menu.h
index da6a33db..73847e18 100644
--- a/libwnck/window-action-menu.h
+++ b/libwnck/widgets/window-action-menu.h
@@ -26,7 +26,7 @@
 #ifndef WNCK_WINDOW_ACTION_MENU_H
 #define WNCK_WINDOW_ACTION_MENU_H
 
-#include <libwnck/window.h>
+#include <libwnck/libwnck.h>
 #include <gtk/gtk.h>
 
 G_BEGIN_DECLS
diff --git a/libwnck/wnck-image-menu-item-private.h b/libwnck/widgets/wnck-image-menu-item-private.h
similarity index 98%
rename from libwnck/wnck-image-menu-item-private.h
rename to libwnck/widgets/wnck-image-menu-item-private.h
index 265289db..5d333782 100644
--- a/libwnck/wnck-image-menu-item-private.h
+++ b/libwnck/widgets/wnck-image-menu-item-private.h
@@ -19,7 +19,7 @@
 #define WNCK_IMAGE_MENU_ITEM_PRIVATE_H
 
 #include <gtk/gtk.h>
-#include "window.h"
+#include <libwnck/libwnck.h>
 
 G_BEGIN_DECLS
 
diff --git a/libwnck/wnck-image-menu-item.c b/libwnck/widgets/wnck-image-menu-item.c
similarity index 100%
rename from libwnck/wnck-image-menu-item.c
rename to libwnck/widgets/wnck-image-menu-item.c
diff --git a/libwnck/wnck.css b/libwnck/widgets/wnck.css
similarity index 100%
rename from libwnck/wnck.css
rename to libwnck/widgets/wnck.css
diff --git a/libwnck/widgets/wnck.gresource.xml b/libwnck/widgets/wnck.gresource.xml
new file mode 100644
index 00000000..2bef3c57
--- /dev/null
+++ b/libwnck/widgets/wnck.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/libwnck">
+    <file>wnck.css</file>
+  </gresource>
+</gresources>
diff --git a/libwnck/workspace-accessible-factory.c b/libwnck/widgets/workspace-accessible-factory.c
similarity index 100%
rename from libwnck/workspace-accessible-factory.c
rename to libwnck/widgets/workspace-accessible-factory.c
diff --git a/libwnck/workspace-accessible-factory.h b/libwnck/widgets/workspace-accessible-factory.h
similarity index 100%
rename from libwnck/workspace-accessible-factory.h
rename to libwnck/widgets/workspace-accessible-factory.h
diff --git a/libwnck/workspace-accessible.c b/libwnck/widgets/workspace-accessible.c
similarity index 100%
rename from libwnck/workspace-accessible.c
rename to libwnck/widgets/workspace-accessible.c
diff --git a/libwnck/workspace-accessible.h b/libwnck/widgets/workspace-accessible.h
similarity index 97%
rename from libwnck/workspace-accessible.h
rename to libwnck/widgets/workspace-accessible.h
index 51b07e4e..d20cee40 100644
--- a/libwnck/workspace-accessible.h
+++ b/libwnck/widgets/workspace-accessible.h
@@ -21,8 +21,6 @@
 
 #include <gtk/gtk.h>
 #include <atk/atk.h>
-#include "workspace.h"
-#include "pager-accessible.h"
 
 G_BEGIN_DECLS
 
diff --git a/libwnck/widgets/xutils.c b/libwnck/widgets/xutils.c
new file mode 100644
index 00000000..96e686c6
--- /dev/null
+++ b/libwnck/widgets/xutils.c
@@ -0,0 +1,394 @@
+/* Xlib utils */
+/* vim: set sw=2 et: */
+
+/*
+ * Copyright (C) 2001 Havoc Pennington
+ * Copyright (C) 2005-2007 Vincent Untz
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include "xutils.h"
+#include <string.h>
+#include <stdio.h>
+#include <cairo-xlib.h>
+#if HAVE_CAIRO_XLIB_XRENDER
+#include <cairo-xlib-xrender.h>
+#endif
+#include "private.h"
+
+gboolean
+_wnck_get_window (Screen *screen,
+                  Window  xwindow,
+                  Atom    atom,
+                  Window *val)
+{
+  Display *display;
+  Atom type;
+  int format;
+  gulong nitems;
+  gulong bytes_after;
+  Window *w;
+  int err, result;
+
+  display = DisplayOfScreen (screen);
+
+  *val = 0;
+
+  _wnck_error_trap_push (display);
+  type = None;
+  result = XGetWindowProperty (display,
+                              xwindow,
+                              atom,
+                              0, G_MAXLONG,
+                              False, XA_WINDOW, &type, &format, &nitems,
+                              &bytes_after, (void*)&w);
+  err = _wnck_error_trap_pop (display);
+  if (err != Success ||
+      result != Success)
+    return FALSE;
+
+  if (type != XA_WINDOW)
+    {
+      XFree (w);
+      return FALSE;
+    }
+
+  *val = *w;
+
+  XFree (w);
+
+  return TRUE;
+}
+
+gboolean
+_wnck_get_atom (Screen *screen,
+                Window  xwindow,
+                Atom    atom,
+                Atom   *val)
+{
+  Display *display;
+  Atom type;
+  int format;
+  gulong nitems;
+  gulong bytes_after;
+  Atom *a;
+  int err, result;
+
+  display = DisplayOfScreen (screen);
+
+  *val = 0;
+
+  _wnck_error_trap_push (display);
+  type = None;
+  result = XGetWindowProperty (display,
+                              xwindow,
+                              atom,
+                              0, G_MAXLONG,
+                              False, XA_ATOM, &type, &format, &nitems,
+                              &bytes_after, (void*)&a);
+  err = _wnck_error_trap_pop (display);
+  if (err != Success ||
+      result != Success)
+    return FALSE;
+
+  if (type != XA_ATOM)
+    {
+      XFree (a);
+      return FALSE;
+    }
+
+  *val = *a;
+
+  XFree (a);
+
+  return TRUE;
+}
+
+void
+_wnck_error_trap_push (Display *display)
+{
+  GdkDisplay *gdk_display;
+
+  gdk_display = gdk_x11_lookup_xdisplay (display);
+  g_assert (gdk_display != NULL);
+
+  gdk_x11_display_error_trap_push (gdk_display);
+}
+
+int
+_wnck_error_trap_pop (Display *display)
+{
+  GdkDisplay *gdk_display;
+
+  gdk_display = gdk_x11_lookup_xdisplay (display);
+  g_assert (gdk_display != NULL);
+
+  gdk_display_flush (gdk_display);
+  return gdk_x11_display_error_trap_pop (gdk_display);
+}
+
+cairo_surface_t *
+_wnck_cairo_surface_get_from_pixmap (Screen *screen,
+                                     Pixmap  xpixmap)
+{
+  cairo_surface_t *surface;
+  Display *display;
+  Window root_return;
+  int x_ret, y_ret;
+  unsigned int w_ret, h_ret, bw_ret, depth_ret;
+  XWindowAttributes attrs;
+
+  surface = NULL;
+  display = DisplayOfScreen (screen);
+
+  _wnck_error_trap_push (display);
+
+  if (!XGetGeometry (display, xpixmap, &root_return,
+                     &x_ret, &y_ret, &w_ret, &h_ret, &bw_ret, &depth_ret))
+    goto TRAP_POP;
+
+  if (depth_ret == 1)
+    {
+      surface = cairo_xlib_surface_create_for_bitmap (display,
+                                                      xpixmap,
+                                                      screen,
+                                                      w_ret,
+                                                      h_ret);
+    }
+  else
+    {
+      if (!XGetWindowAttributes (display, root_return, &attrs))
+        goto TRAP_POP;
+
+      if (depth_ret == (unsigned int) attrs.depth)
+       {
+         surface = cairo_xlib_surface_create (display,
+                                              xpixmap,
+                                              attrs.visual,
+                                              w_ret, h_ret);
+       }
+      else
+       {
+#if HAVE_CAIRO_XLIB_XRENDER
+         int std;
+
+         switch (depth_ret) {
+         case 1: std = PictStandardA1; break;
+         case 4: std = PictStandardA4; break;
+         case 8: std = PictStandardA8; break;
+         case 24: std = PictStandardRGB24; break;
+         case 32: std = PictStandardARGB32; break;
+         default: goto TRAP_POP;
+         }
+
+         surface = cairo_xlib_surface_create_with_xrender_format (display,
+                                                                  xpixmap,
+                                                                  attrs.screen,
+                                                                  XRenderFindStandardFormat (display, std),
+                                                                  w_ret, h_ret);
+#endif
+       }
+    }
+
+TRAP_POP:
+  _wnck_error_trap_pop (display);
+
+  return surface;
+}
+
+GdkPixbuf*
+_wnck_gdk_pixbuf_get_from_pixmap (Screen *screen,
+                                  Pixmap  xpixmap)
+{
+  cairo_surface_t *surface;
+  GdkPixbuf *retval;
+
+  surface = _wnck_cairo_surface_get_from_pixmap (screen, xpixmap);
+
+  if (surface == NULL)
+    return NULL;
+
+  retval = gdk_pixbuf_get_from_surface (surface,
+                                        0,
+                                        0,
+                                        cairo_xlib_surface_get_width (surface),
+                                        cairo_xlib_surface_get_height (surface));
+  cairo_surface_destroy (surface);
+
+  return retval;
+}
+
+static GdkPixbuf*
+default_icon_at_size (int size)
+{
+  GdkPixbuf *base;
+
+  base = gdk_pixbuf_new_from_resource ("/org/gnome/libwnck/default_icon.png", NULL);
+
+  g_assert (base);
+
+  if (gdk_pixbuf_get_width (base) == size &&
+      gdk_pixbuf_get_height (base) == size)
+    {
+      return base;
+    }
+  else
+    {
+      GdkPixbuf *scaled;
+
+      scaled = gdk_pixbuf_scale_simple (base, size, size, GDK_INTERP_BILINEAR);
+      g_object_unref (G_OBJECT (base));
+
+      return scaled;
+    }
+}
+
+void
+_wnck_get_fallback_icons (GdkPixbuf **iconp,
+                          int         ideal_size,
+                          GdkPixbuf **mini_iconp,
+                          int         ideal_mini_size)
+{
+  if (iconp)
+    *iconp = default_icon_at_size (ideal_size);
+
+  if (mini_iconp)
+    *mini_iconp = default_icon_at_size (ideal_mini_size);
+}
+
+void
+_wnck_get_window_geometry (Screen *screen,
+                          Window  xwindow,
+                           int    *xp,
+                           int    *yp,
+                           int    *widthp,
+                           int    *heightp)
+{
+  Display *display;
+  int x, y;
+  unsigned int width, height, bw, depth;
+  Window root_window;
+
+  width = 1;
+  height = 1;
+
+  display = DisplayOfScreen (screen);
+
+  _wnck_error_trap_push (display);
+
+  XGetGeometry (display,
+                xwindow,
+                &root_window,
+                &x, &y, &width, &height, &bw, &depth);
+
+  _wnck_error_trap_pop (display);
+
+  _wnck_get_window_position (screen, xwindow, xp, yp);
+
+  if (widthp)
+    *widthp = width;
+  if (heightp)
+    *heightp = height;
+}
+
+void
+_wnck_get_window_position (Screen *screen,
+                          Window  xwindow,
+                           int    *xp,
+                           int    *yp)
+{
+  Display *display;
+  Window   root;
+  int      x, y;
+  Window   child;
+
+  x = 0;
+  y = 0;
+
+  display = DisplayOfScreen (screen);
+  root = RootWindowOfScreen (screen);
+
+  _wnck_error_trap_push (display);
+  XTranslateCoordinates (display,
+                         xwindow,
+                        root,
+                         0, 0,
+                         &x, &y, &child);
+  _wnck_error_trap_pop (display);
+
+  if (xp)
+    *xp = x;
+  if (yp)
+    *yp = y;
+}
+
+void
+_wnck_set_icon_geometry  (Screen *screen,
+                          Window  xwindow,
+                         int     x,
+                         int     y,
+                         int     width,
+                         int     height)
+{
+  Display *display;
+  gulong data[4];
+
+  display = DisplayOfScreen (screen);
+
+  data[0] = x;
+  data[1] = y;
+  data[2] = width;
+  data[3] = height;
+
+  _wnck_error_trap_push (display);
+
+  XChangeProperty (display,
+                  xwindow,
+                  _wnck_atom_get ("_NET_WM_ICON_GEOMETRY"),
+                  XA_CARDINAL, 32, PropModeReplace,
+                  (guchar *)&data, 4);
+
+  _wnck_error_trap_pop (display);
+}
+
+GdkDisplay*
+_wnck_gdk_display_lookup_from_display (Display *display)
+{
+  GdkDisplay *gdkdisplay = NULL;
+
+  gdkdisplay = gdk_x11_lookup_xdisplay (display);
+
+  if (!gdkdisplay)
+    g_warning ("No GdkDisplay matching Display \"%s\" was found.\n",
+               DisplayString (display));
+
+  return gdkdisplay;
+}
+
+GdkWindow*
+_wnck_gdk_window_lookup_from_window (Screen *screen,
+                                     Window  xwindow)
+{
+  Display    *display;
+  GdkDisplay *gdkdisplay;
+
+  display = DisplayOfScreen (screen);
+  gdkdisplay = _wnck_gdk_display_lookup_from_display (display);
+  if (!gdkdisplay)
+    return NULL;
+
+  return gdk_x11_window_lookup_for_display (gdkdisplay, xwindow);
+}
diff --git a/libwnck/widgets/xutils.h b/libwnck/widgets/xutils.h
new file mode 100644
index 00000000..01acaf9c
--- /dev/null
+++ b/libwnck/widgets/xutils.h
@@ -0,0 +1,87 @@
+/* Xlib utilities */
+/* vim: set sw=2 et: */
+
+/*
+ * Copyright (C) 2001 Havoc Pennington
+ * Copyright (C) 2005-2007 Vincent Untz
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef WNCK_XUTILS_H
+#define WNCK_XUTILS_H
+
+#include <glib.h>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <gdk/gdk.h>
+#include <gdk/gdkx.h>
+#include <libwnck/libwnck.h>
+
+G_BEGIN_DECLS
+
+#define WNCK_APP_WINDOW_EVENT_MASK (PropertyChangeMask | StructureNotifyMask)
+
+gboolean _wnck_get_window        (Screen *screen,
+                                  Window  xwindow,
+                                  Atom    atom,
+                                  Window *val);
+gboolean _wnck_get_atom          (Screen *screen,
+                                  Window  xwindow,
+                                  Atom    atom,
+                                  Atom   *val);
+void _wnck_error_trap_push (Display *display);
+int  _wnck_error_trap_pop  (Display *display);
+
+#define _wnck_atom_get(atom_name) gdk_x11_get_xatom_by_name (atom_name)
+#define _wnck_atom_name(atom)     gdk_x11_get_xatom_name (atom)
+
+void _wnck_get_fallback_icons (GdkPixbuf **iconp,
+                               int         ideal_size,
+                               GdkPixbuf **mini_iconp,
+                               int         ideal_mini_size);
+
+void _wnck_get_window_geometry (Screen *screen,
+                               Window  xwindow,
+                                int    *xp,
+                                int    *yp,
+                                int    *widthp,
+                                int    *heightp);
+
+void _wnck_get_window_position (Screen *screen,
+                               Window  xwindow,
+                                int    *xp,
+                                int    *yp);
+
+void _wnck_set_icon_geometry  (Screen *screen,
+                               Window  xwindow,
+                              int     x,
+                              int     y,
+                              int     width,
+                              int     height);
+
+cairo_surface_t *_wnck_cairo_surface_get_from_pixmap (Screen *screen,
+                                                      Pixmap  xpixmap);
+
+GdkPixbuf* _wnck_gdk_pixbuf_get_from_pixmap (Screen *screen,
+                                             Pixmap  xpixmap);
+
+GdkDisplay* _wnck_gdk_display_lookup_from_display (Display *display);
+
+GdkWindow* _wnck_gdk_window_lookup_from_window (Screen *screen,
+                                                Window  xwindow);
+
+G_END_DECLS
+
+#endif /* WNCK_XUTILS_H */
diff --git a/libwnck/window.c b/libwnck/window.c
index 8f6c8b77..1a487d05 100644
--- a/libwnck/window.c
+++ b/libwnck/window.c
@@ -679,9 +679,9 @@ wnck_window_get_icon_name (WnckWindow *window)
 }
 
 char *
-_wnck_window_get_name_for_display (WnckWindow *window,
-                                   gboolean    use_icon_name,
-                                   gboolean    use_state_decorations)
+wnck_window_get_name_for_display (WnckWindow *window,
+                                  gboolean    use_icon_name,
+                                  gboolean    use_state_decorations)
 {
   const char *name;
 
@@ -1082,7 +1082,7 @@ transient_needs_attention (WnckWindow *window)
 }
 
 time_t
-_wnck_window_or_transient_get_needs_attention_time (WnckWindow *window)
+wnck_window_or_transient_get_needs_attention_time (WnckWindow *window)
 {
   g_return_val_if_fail (WNCK_IS_WINDOW (window), 0);
 
@@ -1154,7 +1154,7 @@ wnck_window_is_maximized_vertically   (WnckWindow *window)
 }
 
 const char*
-_wnck_window_get_startup_id (WnckWindow *window)
+wnck_window_get_startup_id (WnckWindow *window)
 {
   g_return_val_if_fail (WNCK_IS_WINDOW (window), NULL);
 
diff --git a/libwnck/window.h b/libwnck/window.h
index 72545aad..55693f25 100644
--- a/libwnck/window.h
+++ b/libwnck/window.h
@@ -418,6 +418,14 @@ gboolean wnck_window_is_on_workspace         (WnckWindow    *window,
 gboolean wnck_window_is_in_viewport          (WnckWindow    *window,
                                               WnckWorkspace *workspace);
 
+char*       wnck_window_get_name_for_display (WnckWindow *window,
+                                              gboolean    use_icon_name,
+                                              gboolean    use_state_decorations);
+
+const char* wnck_window_get_startup_id (WnckWindow *window);
+
+time_t      wnck_window_or_transient_get_needs_attention_time (WnckWindow *window);
+
 G_END_DECLS
 
 #endif /* WNCK_WINDOW_H */
diff --git a/libwnck/wnck-handle.c b/libwnck/wnck-handle.c
index 157aabea..b948a34f 100644
--- a/libwnck/wnck-handle.c
+++ b/libwnck/wnck-handle.c
@@ -28,6 +28,10 @@
 #include "wnck-enum-types.h"
 #include "xutils.h"
 
+#ifdef HAVE_STARTUP_NOTIFICATION
+#include <libsn/sn.h>
+#endif
+
 #define WNCK_TYPE_HANDLE (wnck_handle_get_type ())
 G_DECLARE_FINAL_TYPE (WnckHandle, wnck_handle, WNCK, HANDLE, GObject)
 
@@ -122,6 +126,7 @@ filter_func (GdkXEvent *gdkxevent,
 
     case ClientMessage:
 #ifdef HAVE_STARTUP_NOTIFICATION
+#if 0
       /* We're cheating as officially libsn requires
        * us to send all events through sn_display_process_event
        */
@@ -140,6 +145,7 @@ filter_func (GdkXEvent *gdkxevent,
 
           ++i;
         }
+#endif
 #endif /* HAVE_STARTUP_NOTIFICATION */
       break;
 
diff --git a/libwnck/wnck.gresource.xml b/libwnck/wnck.gresource.xml
index 2dd9737c..a1eb5363 100644
--- a/libwnck/wnck.gresource.xml
+++ b/libwnck/wnck.gresource.xml
@@ -2,6 +2,5 @@
 <gresources>
   <gresource prefix="/org/gnome/libwnck">
     <file>default_icon.png</file>
-    <file>wnck.css</file>
   </gresource>
 </gresources>
diff --git a/libwnck/workspace.c b/libwnck/workspace.c
index 4bfcd1c9..1f8af96c 100644
--- a/libwnck/workspace.c
+++ b/libwnck/workspace.c
@@ -424,16 +424,16 @@ wnck_workspace_is_virtual (WnckWorkspace *space)
 int
 wnck_workspace_get_layout_row (WnckWorkspace *space)
 {
-  _WnckLayoutOrientation orientation;
-  _WnckLayoutCorner corner;
+  WnckLayoutOrientation orientation;
+  WnckLayoutCorner corner;
   int n_rows;
   int n_cols;
   int row;
 
   g_return_val_if_fail (WNCK_IS_WORKSPACE (space), -1);
 
-  _wnck_screen_get_workspace_layout (space->priv->screen,
-                                     &orientation, &n_rows, &n_cols, &corner);
+  wnck_screen_get_workspace_layout (space->priv->screen,
+                                    &orientation, &n_rows, &n_cols, &corner);
 
   if (orientation == WNCK_LAYOUT_ORIENTATION_HORIZONTAL)
     row = space->priv->number / n_cols;
@@ -464,16 +464,16 @@ wnck_workspace_get_layout_row (WnckWorkspace *space)
 int
 wnck_workspace_get_layout_column (WnckWorkspace *space)
 {
-  _WnckLayoutOrientation orientation;
-  _WnckLayoutCorner corner;
+  WnckLayoutOrientation orientation;
+  WnckLayoutCorner corner;
   int n_rows;
   int n_cols;
   int col;
 
   g_return_val_if_fail (WNCK_IS_WORKSPACE (space), -1);
 
-  _wnck_screen_get_workspace_layout (space->priv->screen,
-                                     &orientation, &n_rows, &n_cols, &corner);
+  wnck_screen_get_workspace_layout (space->priv->screen,
+                                    &orientation, &n_rows, &n_cols, &corner);
 
   if (orientation == WNCK_LAYOUT_ORIENTATION_HORIZONTAL)
     col = space->priv->number % n_cols;
@@ -505,8 +505,8 @@ WnckWorkspace*
 wnck_workspace_get_neighbor (WnckWorkspace       *space,
                              WnckMotionDirection  direction)
 {
-  _WnckLayoutOrientation orientation;
-  _WnckLayoutCorner corner;
+  WnckLayoutOrientation orientation;
+  WnckLayoutCorner corner;
   int n_rows;
   int n_cols;
   int row;
@@ -516,8 +516,8 @@ wnck_workspace_get_neighbor (WnckWorkspace       *space,
 
   g_return_val_if_fail (WNCK_IS_WORKSPACE (space), NULL);
 
-  _wnck_screen_get_workspace_layout (space->priv->screen,
-                                     &orientation, &n_rows, &n_cols, &corner);
+  wnck_screen_get_workspace_layout (space->priv->screen,
+                                    &orientation, &n_rows, &n_cols, &corner);
 
   row = wnck_workspace_get_layout_row (space);
   col = wnck_workspace_get_layout_column (space);
diff --git a/libwnck/xutils.h b/libwnck/xutils.h
index 4e5c6204..be3f089c 100644
--- a/libwnck/xutils.h
+++ b/libwnck/xutils.h
@@ -27,7 +27,7 @@
 #include <X11/Xatom.h>
 #include <gdk/gdk.h>
 #include <gdk/gdkx.h>
-#include <libwnck/screen.h>
+#include <libwnck/libwnck.h>
 
 G_BEGIN_DECLS
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]