GtkWidget * awn_window_new( AwnSettings *set ) { static gboolean type_registered = FALSE; settings = set; AwnWindow *this = g_object_new(AWN_WINDOW_TYPE, "type", GTK_WINDOW_TOPLEVEL, "type-hint", GDK_WINDOW_TYPE_HINT_DOCK, NULL); if (!type_registered) { wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER); type_registered = TRUE; } _on_alpha_screen_changed (GTK_WIDGET(this), NULL, NULL); gtk_widget_set_app_paintable (GTK_WIDGET(this), TRUE); gtk_window_resize (GTK_WINDOW(this), AWN_WINDOW_DEFAULT_WIDTH, (set->bar_height + 2) * 2); g_signal_connect (G_OBJECT (this), "expose-event", G_CALLBACK (_on_expose), NULL); g_signal_connect (G_OBJECT (this), "configure-event", G_CALLBACK (_on_configure), NULL); g_signal_connect (G_OBJECT (this), "screen-changed", G_CALLBACK (_on_alpha_screen_changed), NULL); #if GTK_CHECK_VERSION(2,9,0) _update_input_shape (GTK_WIDGET(this), AWN_WINDOW_DEFAULT_WIDTH, (set->bar_height + 2) * 2); #endif g_timeout_add(5000, (GSourceFunc)_position_timeout, NULL); return GTK_WIDGET(this); }
static gboolean wncklet_factory (PanelApplet *applet, const char *iid, gpointer data) { gboolean retval = FALSE; static gboolean type_registered = FALSE; if (!type_registered) { wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER); type_registered = TRUE; } if (!strcmp (iid, "WindowMenuApplet")) retval = window_menu_applet_fill (applet); else if (!strcmp (iid, "WorkspaceSwitcherApplet")|| !strcmp (iid, "PagerApplet")) retval = workspace_switcher_applet_fill (applet); else if (!strcmp (iid, "WindowListApplet") || !strcmp (iid, "TasklistApplet")) retval = window_list_applet_fill (applet); else if (!strcmp (iid, "ShowDesktopApplet")) retval = show_desktop_applet_fill (applet); return retval; }
// Initial function that draws the applet static gboolean windowtitle_applet_factory (PanelApplet *applet, const gchar *iid, gpointer data) { if (strcmp (iid, APPLET_OAFIID) != 0) return FALSE; wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER); init_wtapplet (applet); return TRUE; }
// Initial function that draws the applet static gboolean windowtitle_applet_factory (PanelApplet *applet, const gchar *iid, gpointer data) { if (strcmp (iid, APPLET_OAFIID) != 0) return FALSE; g_set_application_name (APPLET_NAME); //GLib-WARNING **: g_set_application_name() called multiple times panel_applet_add_preferences (applet, GCONF_PREFS, NULL); wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER); init_wtapplet (applet); return TRUE; }
void Unity2dPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) { Q_UNUSED(uri); // XSetErrorHandler(_x_errhandler); engine->addImageProvider(QString("blended"), new BlendedImageProvider(engine->baseUrl())); engine->addImageProvider(QString("window"), new WindowImageProvider); engine->addImageProvider(QString("icons"), new IconImageProvider); /* ScreenInfo is exposed as a context property as it's a singleton and therefore not creatable directly in QML */ engine->rootContext()->setContextProperty("desktop", DesktopInfo::instance()); engine->rootContext()->setContextProperty("iconUtilities", new IconUtilities(engine)); /* Expose QConf objects as a context property not to initialize it multiple times */ engine->rootContext()->setContextProperty("unity2dConfiguration", &unity2dConfiguration()); engine->rootContext()->setContextProperty("unityConfiguration", &unityConfiguration()); engine->rootContext()->setContextProperty("launcher2dConfiguration", &launcher2dConfiguration()); engine->rootContext()->setContextProperty("dash2dConfiguration", &dash2dConfiguration()); /* Critically important to set the client type to pager because wnck will pass that type over to the window manager through XEvents. Window managers tend to respect orders from pagers to the letter by for example bypassing focus stealing prevention. Compiz does exactly that in src/event.c:handleEvent(...) in the ClientMessage case (line 1702). Metacity has a similar policy in src/core/window.c:window_activate(...) (line 2951). */ wnck_set_client_type(WNCK_CLIENT_TYPE_PAGER); /* Configure translations */ Unity2dTr::init("unity-2d", INSTALL_PREFIX "/share/locale"); Unity2dTr::qmlInit(engine->rootContext()); /* Define the charset that Qt assumes C-strings (char *) and std::string to be in. After that definition, using QString::fromStdString and QString::toStdString will properly convert from and to std::string encoded in UTF-8 as it is the case in Unity's shared backend. Ref.: http://developer.qt.nokia.com/wiki/QtStrings */ QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); }
int main (int argc, char *argv[]) { GdkDisplay *gdkdisplay; Display *xdisplay; GdkScreen *gdkscreen; WnckScreen *screen; gint i, j, status; gboolean replace = FALSE; unsigned int nchildren; Window root_ret, parent_ret; Window *children = NULL; GList *windows, *win; decor_frame_t *bare_p, *switcher_p; const char *option_meta_theme = NULL; gint option_blur_type = 0; program_name = argv[0]; gtk_init (&argc, &argv); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); for (i = 0; i < argc; i++) { if (strcmp (argv[i], "--minimal") == 0) { minimal = TRUE; } else if (strcmp (argv[i], "--replace") == 0) { replace = TRUE; } else if (strcmp (argv[i], "--blur") == 0) { if (argc > ++i) { if (strcmp (argv[i], "titlebar") == 0) option_blur_type = BLUR_TYPE_TITLEBAR; else if (strcmp (argv[i], "all") == 0) option_blur_type = BLUR_TYPE_ALL; } } #ifdef USE_METACITY else if (strcmp (argv[i], "--metacity-theme") == 0) { if (argc > ++i) option_meta_theme = argv[i]; } #endif else if (strcmp (argv[i], "--help") == 0) { fprintf (stderr, "%s " "[--minimal] " "[--replace] " "[--blur none|titlebar|all] " #ifdef USE_METACITY "[--metacity-theme THEME] " #endif "[--help]" "\n", program_name); return 0; } } gdkdisplay = gdk_display_get_default (); xdisplay = gdk_x11_display_get_xdisplay (gdkdisplay); gdkscreen = gdk_display_get_default_screen (gdkdisplay); frame_input_window_atom = XInternAtom (xdisplay, DECOR_INPUT_FRAME_ATOM_NAME, FALSE); frame_output_window_atom = XInternAtom (xdisplay, DECOR_OUTPUT_FRAME_ATOM_NAME, FALSE); win_decor_atom = XInternAtom (xdisplay, DECOR_WINDOW_ATOM_NAME, FALSE); win_blur_decor_atom = XInternAtom (xdisplay, DECOR_BLUR_ATOM_NAME, FALSE); wm_move_resize_atom = XInternAtom (xdisplay, "_NET_WM_MOVERESIZE", FALSE); restack_window_atom = XInternAtom (xdisplay, "_NET_RESTACK_WINDOW", FALSE); select_window_atom = XInternAtom (xdisplay, DECOR_SWITCH_WINDOW_ATOM_NAME, FALSE); mwm_hints_atom = XInternAtom (xdisplay, "_MOTIF_WM_HINTS", FALSE); switcher_fg_atom = XInternAtom (xdisplay, DECOR_SWITCH_FOREGROUND_COLOR_ATOM_NAME, FALSE); compiz_shadow_info_atom = XInternAtom (xdisplay, "_COMPIZ_NET_CM_SHADOW_PROPERTIES", FALSE); compiz_shadow_color_atom = XInternAtom (xdisplay, "_COMPIZ_NET_CM_SHADOW_COLOR", FALSE); toolkit_action_atom = XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION", FALSE); toolkit_action_window_menu_atom = XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION_WINDOW_MENU", FALSE); toolkit_action_force_quit_dialog_atom = XInternAtom (xdisplay, "_COMPIZ_TOOLKIT_ACTION_FORCE_QUIT_DIALOG", FALSE); net_wm_state_atom = XInternAtom (xdisplay,"_NET_WM_STATE", 0); net_wm_state_modal_atom = XInternAtom (xdisplay, "_NET_WM_STATE_MODAL", 0); decor_request_atom = XInternAtom (xdisplay, "_COMPIZ_DECOR_REQUEST", 0); decor_pending_atom = XInternAtom (xdisplay, "_COMPIZ_DECOR_PENDING", 0); decor_delete_pixmap_atom = XInternAtom (xdisplay, "_COMPIZ_DECOR_DELETE_PIXMAP", 0); status = decor_acquire_dm_session (xdisplay, gdk_screen_get_number (gdkscreen), "gwd", replace, &dm_sn_timestamp); if (status != DECOR_ACQUIRE_STATUS_SUCCESS) { if (status == DECOR_ACQUIRE_STATUS_FAILED) { fprintf (stderr, "%s: Could not acquire decoration manager " "selection on screen %d display \"%s\"\n", program_name, gdk_screen_get_number (gdkscreen), DisplayString (xdisplay)); } else if (status == DECOR_ACQUIRE_STATUS_OTHER_DM_RUNNING) { fprintf (stderr, "%s: Screen %d on display \"%s\" already " "has a decoration manager; try using the " "--replace option to replace the current " "decoration manager.\n", program_name, gdk_screen_get_number (gdkscreen), DisplayString (xdisplay)); } return 1; } screen = wnck_screen_get_default (); initialize_decorations (); notified = gwd_settings_notified_impl_new (screen); if (!notified) return 1; writable = GWD_SETTINGS_WRITABLE_INTERFACE (gwd_settings_impl_new (option_blur_type != BLUR_TYPE_NONE ? &option_blur_type : NULL, option_meta_theme ? &option_meta_theme : NULL, notified)); if (!writable) { g_object_unref (notified); return 1; } settings = GWD_SETTINGS_INTERFACE (writable); gwd_settings_writable_freeze_updates (writable); if (!init_settings (writable, screen)) { g_object_unref (writable); fprintf (stderr, "%s: Failed to get necessary gtk settings\n", argv[0]); return 1; } for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { if (cursor[i][j].shape != XC_left_ptr) cursor[i][j].cursor = XCreateFontCursor (xdisplay, cursor[i][j].shape); } } xformat_rgba = XRenderFindStandardFormat (xdisplay, PictStandardARGB32); xformat_rgb = XRenderFindStandardFormat (xdisplay, PictStandardRGB24); frame_table = g_hash_table_new (NULL, NULL); destroyed_pixmaps_table = g_hash_table_new (NULL, NULL); if (!create_tooltip_window ()) { g_object_unref (writable); free (settings); fprintf (stderr, "%s, Couldn't create tooltip window\n", argv[0]); return 1; } wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER); gdk_window_add_filter (NULL, selection_event_filter_func, NULL); if (!minimal) { GdkWindow *root = create_foreign_window (gdk_x11_get_default_root_xwindow ()); gdk_window_add_filter (NULL, event_filter_func, NULL); XQueryTree (xdisplay, gdk_x11_get_default_root_xwindow (), &root_ret, &parent_ret, &children, &nchildren); for (i = 0; i < nchildren; i++) { GdkWindow *toplevel = create_foreign_window (children[i]); /* Need property notify on all windows */ gdk_window_set_events (toplevel, gdk_window_get_events (toplevel) | GDK_PROPERTY_CHANGE_MASK); } /* Need MapNotify on new windows */ gdk_window_set_events (root, gdk_window_get_events (root) | GDK_STRUCTURE_MASK | GDK_PROPERTY_CHANGE_MASK | GDK_VISIBILITY_NOTIFY_MASK | GDK_SUBSTRUCTURE_MASK); connect_screen (screen); } decor_set_dm_check_hint (xdisplay, gdk_screen_get_number (gdkscreen), WINDOW_DECORATION_TYPE_PIXMAP | WINDOW_DECORATION_TYPE_WINDOW); /* Update the decorations based on the settings */ gwd_settings_writable_thaw_updates (writable); /* Keep the default, bare and switcher decorations around * since otherwise they will be spuriously recreated */ bare_p = gwd_get_decor_frame ("bare"); switcher_p = gwd_get_decor_frame ("switcher"); update_default_decorations (gdkscreen); gtk_main (); win = windows = wnck_screen_get_windows (screen); while (win != NULL) { WnckWindow *w = (WnckWindow *) win->data; window_closed (screen, w); win = g_list_next (win); } g_list_free (windows); if (tip_label) gtk_widget_destroy (GTK_WIDGET (tip_label)); if (tip_window) gtk_widget_destroy (GTK_WIDGET (tip_window)); gwd_decor_frame_unref (bare_p); gwd_decor_frame_unref (switcher_p); fini_settings (); return 0; }
static gboolean cw_applet_fill (MatePanelApplet *applet, const gchar *iid, gpointer data) { WinPickerApp *app; GtkWidget *eb, *tasks, *title; gchar *ui_path; GtkActionGroup *action_group; GObjectClass *object_class; if (strcmp (iid, "MateWindowPicker") != 0) return FALSE; bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); /* Have our background automatically painted. */ mate_panel_applet_set_background_widget (MATE_PANEL_APPLET (applet), GTK_WIDGET (applet)); wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER); app = g_slice_new0 (WinPickerApp); mainapp = app; object_class = G_OBJECT_GET_CLASS (G_OBJECT(applet)); object_class->finalize = cw_applet_finalize; parent_class = g_type_class_peek_parent (object_class); /* gsettings prefs */ app->settings = mate_panel_applet_settings_new (applet, APPLET_SCHEMA); g_signal_connect (app->settings, "changed::" SHOW_WIN_KEY, G_CALLBACK (on_show_all_windows_changed), app); g_signal_connect (app->settings, "changed::" SHOW_HOME_TITLE_KEY, G_CALLBACK (on_show_home_title_changed), app); g_signal_connect (app->settings, "changed::" BOLD_WINDOW_TITLE_KEY, G_CALLBACK (on_bold_window_title_changed), app); app->applet = GTK_WIDGET (applet); force_no_focus_padding (GTK_WIDGET (applet)); gtk_container_set_border_width (GTK_CONTAINER (applet), 0); eb = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_container_add (GTK_CONTAINER (applet), eb); gtk_container_set_border_width (GTK_CONTAINER (eb), 0); tasks = app->tasks = task_list_get_default (); gtk_box_pack_start (GTK_BOX (eb), tasks, FALSE, FALSE, 0); title = app->title = task_title_new (); gtk_box_pack_start (GTK_BOX (eb), title, TRUE, TRUE, 0); gtk_widget_show_all (GTK_WIDGET (applet)); on_show_all_windows_changed (app->settings, SHOW_WIN_KEY, app); on_show_home_title_changed (app->settings, SHOW_HOME_TITLE_KEY, app); on_bold_window_title_changed (app->settings, BOLD_WINDOW_TITLE_KEY, app); action_group = gtk_action_group_new ("MateWindowPicker Applet Actions"); gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (action_group, window_picker_menu_actions, G_N_ELEMENTS (window_picker_menu_actions), app); ui_path = g_build_filename (MATEWINDOWPICKER_MENU_UI_DIR, "mate-window-picker-applet-menu.xml", NULL); mate_panel_applet_setup_menu_from_file (MATE_PANEL_APPLET (app->applet), ui_path, action_group); g_free (ui_path); g_object_unref (action_group); mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet), MATE_PANEL_APPLET_EXPAND_MAJOR | MATE_PANEL_APPLET_EXPAND_MINOR | MATE_PANEL_APPLET_HAS_HANDLE); return TRUE; }
int main (int argc, char **argv) { DBusGConnection *connection; GError *error = NULL; GObject *deskmenu; #if !GLIB_CHECK_VERSION(2,36,0) g_type_init (); #endif connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error); if (connection == NULL) { g_printerr ("Failed to open connection to bus: %s", error->message); g_error_free (error); exit (1); } g_print ("Starting the daemon...\n"); GOptionContext *context; gchar *file = NULL; GOptionEntry entries[] = { { "config", 'c', 0, G_OPTION_ARG_FILENAME, &file, "Use FILE instead of the default daemon configuration", "FILE" }, { NULL, 0, 0, 0, NULL, NULL, NULL } }; context = g_option_context_new (NULL); g_option_context_add_main_entries (context, entries, NULL); error = NULL; if (!g_option_context_parse (context, &argc, &argv, &error)) { g_printerr ("option parsing failed: %s", error->message); g_error_free (error); return 1; } g_set_prgname ("Compiz Boxmenu"); g_option_context_free (context); #if HAVE_WNCK wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER); #endif gtk_init (&argc, &argv); deskmenu = g_object_new (DESKMENU_TYPE, NULL); dbus_g_connection_register_g_object (connection, DESKMENU_PATH_DBUS, deskmenu); if (!dbus_bus_request_name (dbus_g_connection_get_connection (connection), DESKMENU_SERVICE_DBUS, DBUS_NAME_FLAG_REPLACE_EXISTING, NULL)) return 1; set_up_element_hash(); set_up_item_hash(); deskmenu_precache(DESKMENU(deskmenu), file); gtk_main (); return 0; }