/* Returns the number of window for this application that reside on the
   current workspace */
int
LauncherApplication::windowCountOnCurrentWorkspace()
{
    int windowCount = 0;
    WnckWorkspace *current = wnck_screen_get_active_workspace(wnck_screen_get_default());

    for (int i = 0; i < m_application->windows()->size(); i++) {
        BamfWindow *window = m_application->windows()->at(i);
        if (window == NULL) {
            continue;
        }

        /* When geting the wnck window, it's possible we get a NULL
           return value because wnck hasn't updated its internal list yet,
           so we need to force it once to be sure */
        WnckWindow *wnck_window = wnck_window_get(window->xid());
        if (wnck_window == NULL) {
            wnck_screen_force_update(wnck_screen_get_default());
            wnck_window = wnck_window_get(window->xid());
            if (wnck_window == NULL) {
                continue;
            }
        }

        WnckWorkspace *workspace = wnck_window_get_workspace(wnck_window);
        if (workspace == current) {
            windowCount++;
        }
    }
    return windowCount;
}
Beispiel #2
0
/**
 * gva_wnck_listen_for_new_window:
 * @process: a #GvaProcess
 * @game: the game that @process is running
 *
 * Implements spatial MAME windows.
 *
 * This function gets called immediately after a game is started.  It uses
 * libwnck to listen for a new window, and does its best to verify whether
 * it's a MAME window.  If it identifies the window, it restores the size,
 * position and maximize state of that particular game from the previous
 * session and records any further window geometry changes.  The game
 * database is used as the storage medium for window geometries.
 **/
void
gva_wnck_listen_for_new_window (GvaProcess *process,
                                const gchar *game)
{
#ifdef HAVE_WNCK
        g_return_if_fail (GVA_IS_PROCESS (process));
        g_return_if_fail (game != NULL);

        if (window_opened_handler_id > 0)
        {
                g_warning ("GVA can only listen for one new window at a time");
                return;
        }

        g_object_set_data_full (
                G_OBJECT (process), "game",
                g_strdup (game), (GDestroyNotify) g_free);

        /* Keep a weak reference on the process until we can match it
         * to a newly opened window, at which time we'll add a real
         * reference and bind it to the corresponding WnckWindow.
         * If the process exits early we'll know to stop listening. */
        g_object_weak_ref (
                G_OBJECT (process),
                (GWeakNotify) wnck_weak_notify_cb,
                wnck_screen_get_default ());

        window_opened_handler_id = g_signal_connect (
                wnck_screen_get_default (), "window-opened",
                G_CALLBACK (wnck_window_opened_cb), process);

        gva_main_cursor_busy ();
#endif /* HAVE_WNCK */
}
Beispiel #3
0
int main(int argc, char **argv) {
    WnckScreen *screen;
    WnckWindow *active_window;
    GList *window_l;

    gdk_init(&argc, &argv);

    screen = wnck_screen_get_default();

    sleep(5);

    wnck_screen_force_update(screen);

    active_window = wnck_screen_get_active_window(screen);

    for (window_l = wnck_screen_get_windows(screen); window_l != NULL;
        window_l = window_l->next) {
        WnckWindow *window = WNCK_WINDOW(window_l->data);
        if (strcmp(wnck_window_get_name(window), "Terminal") == 0) {
            wnck_window_activate(window, (guint32)time(NULL));
            break;
        }
//        g_print("Name: '%s', PID: %d(%lu)%s\n", wnck_window_get_name(window),
//            wnck_window_get_pid(window), wnck_window_get_xid(window),
//            window == active_window ? " (active)" : "");
    }

    return 0;
}
Beispiel #4
0
int main (int argc, char *argv[])
{
  if(argc > 1)
    for (int i = 1; i < argc; ++i)
    {
        std::string ar(argv[i]);
        if( ar == "-d")
          ad_debug = true;
        else if( ar == "-s")
          simulate = true;
    }

  readfiles();
  
  GMainLoop *loop;
  WnckScreen *screen;

  gdk_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);
  screen = wnck_screen_get_default ();

  g_signal_connect (screen, "window-opened", G_CALLBACK (on_window_opened), NULL);
  g_main_loop_run (loop);
  g_main_loop_unref (loop);

  return 0;
}
Beispiel #5
0
void Application::init() {
    b2Vec2 gravity(0.0f, 10.0f);
    mWorld = QSharedPointer<b2World>(new b2World(gravity));
    mWorld->SetAllowSleeping(false);

    // Get windowing system
    WnckScreen *screen;
    WnckWindow *active_window;
    WnckWorkspace *active_workspace;
    GList *window_l;

    screen = wnck_screen_get_default ();

    wnck_screen_force_update (screen);

    active_window = wnck_screen_get_active_window (screen);
    active_workspace = wnck_screen_get_active_workspace (screen);

    for(window_l = wnck_screen_get_windows (screen); window_l != NULL; window_l = window_l->next) {
        WnckWindow *window = WNCK_WINDOW (window_l->data);
        if(wnck_window_is_on_workspace(window, active_workspace) &&
                !wnck_window_is_minimized(window) &&
                wnck_window_get_window_type(window) == WNCK_WINDOW_NORMAL) {
            mPhysicalWindows.append(QSharedPointer<PhysicalWindow>(new PhysicalWindow(window, mWorld)));
        }
    }

    mPhysicalWindows.append(QSharedPointer<PhysicalWindow>(new PhysicalWindow(100, 100, 100, 100, mWorld)));
}
void init_wnck (WckUtils *win, gboolean only_maximized, gpointer data)
{
    /* save data */
    win->data = data;

    /* get window proprieties */
    win->activescreen = wnck_screen_get_default();
    win->activeworkspace = wnck_screen_get_active_workspace(win->activescreen);
    if (!win->activeworkspace)
        win->activeworkspace = wnck_screen_get_workspace(win->activescreen, 0);
    win->activewindow = wnck_screen_get_active_window(win->activescreen);
    win->umaxwindow = NULL;
    win->controlwindow = NULL;
    win->only_maximized = only_maximized;

    /* Global window tracking */
    g_signal_connect(win->activescreen, "active-window-changed", G_CALLBACK (active_window_changed), win);

    if (win->only_maximized)
    {
        win->sch = g_signal_connect(win->activescreen, "window-closed", G_CALLBACK (on_window_closed), win);
        win->soh = g_signal_connect(win->activescreen, "window-opened", G_CALLBACK (on_window_opened), win);
    }

        win->svh = g_signal_connect(win->activescreen, "viewports-changed", G_CALLBACK (on_viewports_changed), win);
        win->swh = g_signal_connect(win->activescreen, "active-workspace-changed", G_CALLBACK (active_workspace_changed), win);

    /* Get controled window */
    track_controled_window (win);
    
    if (!win->controlwindow)
        on_control_window_changed (NULL, NULL, win->data);
}
Beispiel #7
0
// -----------------------------------------------------------------------------
int g_workspace_count()
{
	DEBUGLOGB;

#if _USEGTK
#if _USEWKSPACE

	int     ret     =  wnck_screen_get_workspace_count(wnck_screen_get_default());

#else  // _USEWKSPACE

#if GTK_CHECK_VERSION(3,0,0)
	Screen* xscreen =  gdk_x11_screen_get_xscreen(gdk_screen_get_default());
#else
	Screen* xscreen =  GDK_SCREEN_XSCREEN(gdk_screen_get_default());
#endif
	int     ret     = _wncki_screen_get_workspace_count(xscreen);

#endif // _USEWKSPACE
#else  // _USEGTK

	int     ret     = 1;

#endif // _USEGTK

	DEBUGLOGE;
	return ret;
}
void sux_init(SuxModule *sm, gchar *args)
{
        GtkWidget *button, *image;
        WnckScreen *screen;
        ShowDesktop *sd;

        sd = g_new0(ShowDesktop, 1);
        
        button = gtk_toggle_button_new();
        gtk_widget_show(button);
        
        image = gtk_image_new_from_file_scaled(IMG_PREFIX "showdesktop.png", 24, 24);
        gtk_widget_show(image);
        gtk_container_add(GTK_CONTAINER(button), image);

        screen = wnck_screen_get_default();
        g_object_set_data(G_OBJECT(screen), "sd", sd);

	sd->tips = gtk_tooltips_new();
        sd->screen = screen;
        sd->is_showing_desktop = wnck_screen_get_showing_desktop(sd->screen);
        sd->button = button;

        update_tooltip(sd);
        
        g_signal_connect(G_OBJECT(button), "toggled",
                         G_CALLBACK(toggle_show_desktop), sd);
        g_signal_connect(G_OBJECT(screen), "showing_desktop_changed",
                         G_CALLBACK(show_desktop_changed), sd);
	
	sm->widget = sd->button;
}
void
LauncherApplication::setIconGeometry(int x, int y, int width, int height, uint xid)
{
    if (m_application == NULL) {
        return;
    }

    QScopedPointer<BamfUintList> xids;
    if (xid == 0) {
        xids.reset(m_application->xids());
    } else {
        QList<uint> list;
        list.append(xid);
        xids.reset(new BamfUintList(list));
    }
    int size = xids->size();
    if (size < 1) {
        return;
    }

    WnckScreen* screen = wnck_screen_get_default();
    wnck_screen_force_update(screen);

    for (int i = 0; i < size; ++i) {
        WnckWindow* window = wnck_window_get(xids->at(i));
        wnck_window_set_icon_geometry(window, x, y, width, height);
    }
}
void
LauncherApplication::show()
{
    if (m_application == NULL) {
        return;
    }

    QScopedPointer<BamfWindowList> windows(m_application->windows());
    int size = windows->size();
    if (size < 1) {
        return;
    }

    /* Pick the most important window.
       The primary criterion to determine the most important window is urgency.
       The secondary criterion is the last_active timestamp (the last time the
       window was activated). */
    BamfWindow* important = windows->at(0);
    for (int i = 0; i < size; ++i) {
        BamfWindow* current = windows->at(i);
        if (current->urgent() && !important->urgent()) {
            important = current;
        } else if (current->urgent() || !important->urgent()) {
            if (current->last_active() > important->last_active()) {
                important = current;
            }
        }
    }

    WnckScreen* screen = wnck_screen_get_default();
    wnck_screen_force_update(screen);

    WnckWindow* window = wnck_window_get(important->xid());
    LauncherUtility::showWindow(window);
}
Beispiel #11
0
int main (int argc, char *argv[])
{
    /* Make sure we exit cleanly (needed for profiling among other things) */
  g_shell_parse_argv(sphinx_command,&argc,&argv,NULL);
     gtk_init(&argc, &argv);
 
     scr = wnck_screen_get_default();
     while(gtk_events_pending()) gtk_main_iteration();
     win = wnck_screen_get_active_window(scr);
      tmp=wnck_screen_get_windows(wnck_window_get_screen(win));
     signal(SIGINT, &sighandler);

    fbs_init (argc, argv);
    
    if ((ad = ad_open_sps (SAMPLE_RATE)) == NULL)
	E_FATAL("ad_open_sps failed\n");

    // E_INFO("%s COMPILED ON: %s, AT: %s\n\n", argv[0], __DATE__, __TIME__);

    if (setjmp(jbuf) == 0) {
      utterance_loop (argc,argv);
    }

    fbs_end ();
    ad_close (ad);

    return 0;
}
int main(int argc, char **argv) {
  gtk_init (&argc, &argv);
  client = gconf_client_get_default ();
  /* which confs to monitor */
  gconf_client_add_dir (client, DEFAULT_BACKGROUND_GCONF_PATH,
			GCONF_CLIENT_PRELOAD_NONE, NULL);
  gconf_client_add_dir (client, MULTI_BACKGROUND_GCONF_PATH,
			GCONF_CLIENT_PRELOAD_NONE, NULL);
  
#define GET_DEFAULT_BACKGROUND(client, type, entry)			\
  default_ ## entry = gconf_client_get_ ## type(client,			\
						DEFAULT_BACKGROUND_GCONF_PATH "/" # entry, \
						NULL)
  
  GET_DEFAULT_BACKGROUND(client, string, color_shading_type);
  GET_DEFAULT_BACKGROUND(client, bool, draw_background);
  GET_DEFAULT_BACKGROUND(client, string, picture_filename);
  GET_DEFAULT_BACKGROUND(client, int, picture_opacity);
  GET_DEFAULT_BACKGROUND(client, string, picture_options);
  GET_DEFAULT_BACKGROUND(client, string, primary_color);
  GET_DEFAULT_BACKGROUND(client, string, secondary_color);

  screen = wnck_screen_get_default ();
  wnck_screen_force_update (screen);	
  
  g_signal_connect(G_OBJECT (screen), "active_workspace_changed",
		   G_CALLBACK (workspace_changed_cb),
		   NULL);
  add_monitors();
  gtk_main ();
  return 0;
}
Beispiel #13
0
// -----------------------------------------------------------------------------
void g_window_workspace(GtkWidget* pWidget, int space)
{
	DEBUGLOGB;

#if !_USEWKSPACE

#if GTK_CHECK_VERSION(3,0,0)
	Screen* xscreen = gdk_x11_screen_get_xscreen(gdk_screen_get_default());
	Window  xwindow = gdk_x11_window_get_xid(gtk_widget_get_window(pWidget));
#else
	Screen* xscreen = GDK_SCREEN_XSCREEN(gdk_screen_get_default());
	Window  xwindow = GDK_WINDOW_XWINDOW(gtk_widget_get_window(pWidget));
#endif

	_wncki_change_workspace(xscreen, xwindow, space);

#else  // !_USEWKSPACE

	WnckScreen* screen = wnck_screen_get_default();

	if( screen )
	{
		DEBUGLOGS("got default screen");
		wnck_screen_force_update(screen);

		DEBUGLOGP("sticky is off and workspace is %d\n", space);
		WnckWindow* window = wnck_window_get(gdk_x11_drawable_get_xid(gtk_widget_get_window(pWidget)));

		if( window && !wnck_window_is_pinned(window) )
		{
			DEBUGLOGS("got non-pinned window");
			WnckWorkspace* trgtWrk = wnck_screen_get_workspace       (screen, space);
			WnckWorkspace* actvWrk = wnck_screen_get_active_workspace(screen);

			if( trgtWrk && actvWrk && trgtWrk != actvWrk )
			{
				DEBUGLOGS("got target workspace is diff from current so moving window to target");
				wnck_window_move_to_workspace(window, trgtWrk);
			}
		}
#ifdef _DEBUGLOG
		else
		{
			DEBUGLOGP("WnckWindow for clock window is%svalid\n", window ? " " : " NOT ");
			guint xw1 = GDK_WINDOW_XWINDOW      (gtk_widget_get_window(pWidget));
			guint xw2 = gdk_x11_drawable_get_xid(gtk_widget_get_window(pWidget));
			DEBUGLOGP("X11 XID1 for clock window is %d\n", (int)xw1);
			DEBUGLOGP("X11 XID2 for clock window is %d\n", (int)xw2);
		}
#endif
	}

#endif // !_USEWKSPACE

	DEBUGLOGE;
}
static void
workspace_browser_init (WorkspaceBrowser* self)
{
  WnckScreen* screen = wnck_screen_get_default ();

  g_signal_connect (screen, "workspace-created",
                    G_CALLBACK (workspace_created_cb), self);
  g_signal_connect (screen, "workspace-destroyed",
                    G_CALLBACK (workspace_destroyed_cb), self);
}
static void
task_title_setup (TaskTitle *title)
{
    TaskTitlePrivate *priv = title->priv;

    priv->screen = wnck_screen_get_default ();
    priv->window = NULL;
    gtk_widget_add_events (GTK_WIDGET (title), GDK_ALL_EVENTS_MASK);
    priv->align = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
    gtk_alignment_set_padding (GTK_ALIGNMENT (priv->align),
        0, 0, 6, 6);
    gtk_container_add (GTK_CONTAINER (title), priv->align);
    priv->grid = gtk_grid_new();
    gtk_grid_set_row_spacing (GTK_GRID(priv->grid), 2);
    gtk_container_add (GTK_CONTAINER (priv->align), priv->grid);
    gtk_widget_set_no_show_all (priv->grid, TRUE);
    gtk_widget_show (priv->grid);

    //Prepare and show the title label
    priv->label = getTitleLabel();
    gtk_grid_attach (GTK_GRID(priv->grid), priv->label, 0, 0, 1, 1);
    gtk_widget_show (priv->label);

    //Create the close button
    priv->button = getCloseButton (title);
    gtk_grid_attach (GTK_GRID(priv->grid), priv->button, 1, 0, 1, 1);
    gtk_widget_show (priv->button);

    g_signal_connect (GTK_WIDGET(title), "draw",
        G_CALLBACK (on_draw), title);

    // Prepare and add the logoff icon to the title
    GdkScreen *gdkscreen = gtk_widget_get_screen (GTK_WIDGET (title));
    GtkIconTheme *theme = gtk_icon_theme_get_for_screen (gdkscreen);
    //this shows a little green exit icon, like the ones on emergency exits
    priv->quit_icon = gtk_icon_theme_load_icon (
        theme, "gnome-logout", 16, 0, NULL
    );
    priv->button_image = gtk_image_new_from_pixbuf (priv->quit_icon);
    gtk_container_add (GTK_CONTAINER (priv->button), priv->button_image);
    gtk_widget_show (priv->button_image);
    gtk_widget_set_tooltip_text (priv->button,
        _("Log off, switch user, lock screen or "
        "power down the computer")
    );
    gtk_widget_set_tooltip_text (GTK_WIDGET (title), _("Home"));
    gtk_widget_add_events (GTK_WIDGET (title), GDK_ALL_EVENTS_MASK);
    g_signal_connect (priv->screen, "active-window-changed",
        G_CALLBACK (on_active_window_changed), title);
    g_signal_connect (title, "button-press-event",
        G_CALLBACK (on_button_press), NULL);
}
Beispiel #16
0
gboolean
dnd_has_one_fullscreen_window (void)
{
	gboolean result;

	WnckScreen *screen = wnck_screen_get_default ();
	wnck_screen_force_update (screen);
	WnckWorkspace *workspace = wnck_screen_get_active_workspace (screen);
	GList *list = wnck_screen_get_windows (screen);
	GList *item = g_list_find_custom (list, workspace, (GCompareFunc) is_fullscreen_cb);
	result = item != NULL;
#ifdef HAVE_WNCK_SHUTDOWN
	wnck_shutdown ();
#endif
	return result;
}
/* FIXME: this will not work with wm using large desktops and viewports
   to implement their workspaces.*/
bool WorkspacesInfo::changeCurrent(int newWorkspace)
{
    WnckScreen *screen = wnck_screen_get_default();
    WnckWorkspace *workspace = wnck_screen_get_workspace(screen, newWorkspace);
    if (workspace == NULL) {
        UQ_WARNING << "Requested activation workspace" << newWorkspace << " but it does not exist.";
        return false;
    }

    if (newWorkspace == current()) {
        return true;
    }

    /* This function will ask the WM to change workspace. However we have no way to know
       if it succeeds or fails. To know that we can only wait to be notified of the workspace
       to actually change, or decide we waited too much and proceed anyway */
    wnck_workspace_activate(workspace, CurrentTime);
    return SignalWaiter().waitForSignal(this, SIGNAL(currentChanged(int)), 50);
}
static void
task_manager_dialog_dispose (GObject *object)
{
  TaskManagerDialogPrivate * priv = GET_PRIVATE (object);
  if (priv->client)
  {
    desktop_agnostic_config_client_unbind_all_for_object (priv->client,
                                                        object,
                                                        NULL);
    priv->client=NULL;
  }
  if ( priv->wm_change_id )
  {
    g_signal_handler_disconnect (wnck_screen_get_default(),priv->wm_change_id);
    priv->wm_change_id = 0;
  }
  
  G_OBJECT_CLASS (task_manager_dialog_parent_class)->dispose (object);
}
Beispiel #19
0
/**
 * ww_apply_layout_by_name
 * @layout_name: The name of the layout to apply
 *
 * Apply a given layout to the default screen by looking up the relevant
 * #WwLayout based on its name.
 */
void
ww_apply_layout_by_name (const gchar * layout_name)
{
	WnckScreen *screen;
	WnckWorkspace   *current_ws;
	GList *windows, *struts;
	WnckWindow *active;
	const WwLayout *layout;
	GError *error;
	
	screen = wnck_screen_get_default ();
	wnck_screen_force_update (screen);
	
	current_ws = wnck_screen_get_active_workspace (screen);
	windows = wnck_screen_get_windows (screen);
	struts = ww_filter_strut_windows (windows, current_ws);
	windows = ww_filter_user_windows (windows, current_ws);
	active = wnck_screen_get_active_window (screen);
	
	/* Check that we know the requested layout */
	layout = ww_get_layout (layout_name);
	if (!layout)
	{
		g_printerr ("No such layout: '%s'. Try running with --layouts to "
					"list possible layouts\n", layout_name);
		return;
	}
	
	/* Apply the layout */
	error = NULL;
	layout->handler (screen, windows, struts, active, &error);
	g_list_free (windows);
	g_list_free (struts);
	
	if (error)
	{
		g_printerr ("Failed to apply layout '%s'. Error was:\n%s",
					layout_name, error->message);
		g_error_free (error);
		return;
	}	
}
Beispiel #20
0
t_xkb_settings *
xkb_new( void )
{
    t_xkb_settings *xkb;
    WnckScreen *wnck_screen;
    wnck_screen = wnck_screen_get_default();

    xkb = g_new0( t_xkb_settings, 1 );

    g_signal_connect( G_OBJECT( wnck_screen ), "active-window-changed",
                      G_CALLBACK (xkb_active_window_changed ), xkb );

    g_signal_connect( G_OBJECT( wnck_screen ), "window-closed",
                      G_CALLBACK (xkb_window_closed ), xkb );

    g_signal_connect( G_OBJECT( wnck_screen ), "application-closed",
                      G_CALLBACK (xkb_application_closed ), xkb );

    return xkb;
}
Beispiel #21
0
static void
style_updated (GtkWidget *widget,
               void      *user_data)
{
    GdkDisplay *gdkdisplay;
    GdkScreen  *gdkscreen;
    WnckScreen *screen;

    PangoContext *context = (PangoContext *) user_data;

    gdkdisplay = gdk_display_get_default ();
    gdkscreen  = gdk_display_get_default_screen (gdkdisplay);
    screen     = wnck_screen_get_default ();

    update_style (widget);

    pango_cairo_context_set_resolution (context, gdk_screen_get_resolution (gdkscreen));

    decorations_changed (screen);
}
Beispiel #22
0
int main (int argc, char **argv)
{

  gdk_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);
  screen = wnck_screen_get_default ();

  signal(SIGINT, INThandler);


  g_signal_connect(screen, "active-window-changed",
  		  G_CALLBACK(on_active_window_changed), NULL);

  g_main_loop_run (loop);

  stop_application();

  return 0;
}
static void
task_manager_dialog_constructed (GObject *object)
{
  TaskManagerDialogPrivate * priv = GET_PRIVATE (object);
  GError             *error=NULL;
  
  G_OBJECT_CLASS (task_manager_dialog_parent_class)->constructed (object);

  priv->client = awn_config_get_default_for_applet (priv->applet, &error);
  if (error)
  {
    g_debug ("%s: %s",__func__,error->message);
    g_error_free (error);
    error=NULL;
  }
  desktop_agnostic_config_client_bind (priv->client,
                                       DESKTOP_AGNOSTIC_CONFIG_GROUP_DEFAULT,
                                       "dialog_mode",
                                       object, "dialog mode", TRUE,
                                       DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,
                                       NULL);

  desktop_agnostic_config_client_bind (priv->client,
                                       DESKTOP_AGNOSTIC_CONFIG_GROUP_DEFAULT,
                                       "dialog_scale",
                                       object, "dialog scale", TRUE,
                                       DESKTOP_AGNOSTIC_CONFIG_BIND_METHOD_FALLBACK,
                                       NULL);
  priv->children = NULL;
  priv->main_box = gtk_vbox_new (FALSE,3);
  priv->items_box = gtk_hbox_new (FALSE,3);
  priv->current_dialog_mode = priv->dialog_mode;
  gtk_container_add (GTK_CONTAINER (priv->main_box),priv->items_box);
  gtk_container_add (GTK_CONTAINER (object),priv->main_box);
  gtk_widget_show_all (priv->main_box);

  task_manager_dialog_analyze_wm (TASK_MANAGER_DIALOG(object));
  priv->wm_change_id = g_signal_connect_swapped (wnck_screen_get_default(),"window-manager-changed",
                            G_CALLBACK(task_manager_dialog_analyze_wm),object);
  
}
void
LauncherApplication::close()
{
    if (m_application == NULL) {
        return;
    }

    QScopedPointer<BamfUintList> xids(m_application->xids());
    int size = xids->size();
    if (size < 1) {
        return;
    }

    WnckScreen* screen = wnck_screen_get_default();
    wnck_screen_force_update(screen);

    for (int i = 0; i < size; ++i) {
        WnckWindow* window = wnck_window_get(xids->at(i));
        wnck_window_close(window, CurrentTime);
    }
}
Beispiel #25
0
static void wibuti_watcher_init(WibutiWatcher *self) {
	self->only_maximized = FALSE;
	self->tracked = NULL;
	self->screen = wnck_screen_get_default();
	wnck_screen_force_update(self->screen);

	wibuti_watcher_find_window(self);
	
	g_signal_connect(G_OBJECT(self->screen), "active-workspace-changed",
	                 G_CALLBACK(wibuti_watcher_active_workspace_changed_cb), self);
	g_signal_connect(G_OBJECT(self->screen), "active-window-changed",
	                 G_CALLBACK(wibuti_watcher_active_window_changed_cb), self);
	g_signal_connect(G_OBJECT(self->screen), "viewports-changed",
	                 G_CALLBACK(wibuti_watcher_viewports_changed_cb), self);
	g_signal_connect(G_OBJECT(self->screen), "window-closed",
	                 G_CALLBACK(wibuti_watcher_window_closed_cb), self);
	g_signal_connect(G_OBJECT(self->screen), "window-opened",
	                 G_CALLBACK(wibuti_watcher_window_opened_cb), self);
	
	g_signal_emit_by_name(self, WIBUTI_SIGNAL_WINDOW_CHANGED);
}
void
Application::connectWindowSignals()
{
    if (m_application == NULL || m_application->running() == false) {
        return;
    }

    QScopedPointer<BamfWindowList> windows(m_application->windows());
    const int size = windows->size();
    if (size < 1) {
        return;
    }

    WnckScreen* screen = wnck_screen_get_default();
    wnck_screen_force_update(screen);

    for (int i = 0; i < size; ++i) {
        BamfWindow *window = windows->at(i);
        onWindowAdded(window);
    }
}
int
main (int    argc,
      char **argv)
{
  GMainLoop *loop;
  WnckScreen *screen;

  gdk_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);
  screen = wnck_screen_get_default ();

  g_signal_connect (screen, "window-opened",
                    G_CALLBACK (on_window_opened), NULL);
  g_signal_connect (screen, "active-window-changed",
                    G_CALLBACK (on_active_window_changed), NULL);

  g_main_loop_run (loop);

  g_main_loop_unref (loop);

  return 0;
}
Beispiel #28
0
int
main (int argc, char **argv)
{
  static const GOptionEntry options[] = {
    { "also-trigger-on-caps-lock", 'c', 0, G_OPTION_ARG_NONE,
      &also_trigger_on_caps_lock,
      "Make the Caps Lock key also switch windows (as well as the Super key)",
      NULL },
    { "only-trigger-on-caps-lock", 'C', 0, G_OPTION_ARG_NONE,
      &only_trigger_on_caps_lock,
      "Make only the Caps Lock key switch windows (instead of the Super key)",
      NULL },
    { "version", 'v', 0, G_OPTION_ARG_NONE, &show_version_and_exit,
      "Show the version number and exit", NULL },
#ifdef HAVE_XCOMPOSITE
    { "show-window-thumbnails", 't', 0, G_OPTION_ARG_NONE,
      &show_window_thumbnails,
      "EXPERIMENTAL - Show window thumbnails (instead of icons)", NULL },
#endif
    { NULL }
  };

  GdkWindow *root;
  GOptionContext *context;
  GError *error;

  gtk_init (&argc, &argv);

  context = g_option_context_new ("");
  error = NULL;
  g_option_context_add_main_entries (context, options, NULL);
  g_option_context_parse (context, &argc, &argv, &error);

  if (error) {
    g_printerr ("%s\n", error->message);
    g_error_free (error);
    exit (ABNORMAL_EXIT_CODE_UNKNOWN_COMMAND_LINE_OPTION);
  }

  if (show_version_and_exit) {
    // VERSION comes from the Makefile generated by autogen.sh and configure.in.
    printf ("SuperSwitcher version %s\n", VERSION);
    return 0;
  }

#ifdef HAVE_DBUS_GLIB
  // Note that this may exit(...) if another instance is already running.
  init_superswitcher_dbus ();
#endif

#ifdef HAVE_XCOMPOSITE
  if (show_window_thumbnails) {
    show_window_thumbnails = init_composite ();
  }
#endif

  root = gdk_get_default_root_window ();
  x_root_window = GDK_WINDOW_XWINDOW (root);

  gdk_window_add_filter (root, filter_func, NULL);
  if (!only_trigger_on_caps_lock) {
    grab (XK_Super_L);
    grab (XK_Super_R);
  }
  if (also_trigger_on_caps_lock || only_trigger_on_caps_lock) {
    disable_caps_lock_default_behavior ();
    grab (XK_Caps_Lock);
  }

  screen = ss_screen_new (wnck_screen_get_default (),
                          GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
                          x_root_window);

  gtk_main ();

#ifdef HAVE_XCOMPOSITE
  if (show_window_thumbnails) {
    uninit_composite ();
  }
#endif

  return 0;
}
Beispiel #29
0
/* Do the actual applet initialization */
static void init_wtapplet (PanelApplet *applet) {
	WTApplet *wtapplet = g_new0 (WTApplet, 1);

	wtapplet->applet = applet;
	wtapplet->prefs = loadPreferences(wtapplet);
	wtapplet->activescreen = wnck_screen_get_default();
	wnck_screen_force_update(wtapplet->activescreen);
	wtapplet->activeworkspace = wnck_screen_get_active_workspace(wtapplet->activescreen);
	wtapplet->activewindow = wnck_screen_get_active_window(wtapplet->activescreen);
	wtapplet->umaxedwindow = getUpperMaximized(wtapplet);
	wtapplet->rootwindow = getRootWindow(wtapplet->activescreen);
	wtapplet->prefbuilder = gtk_builder_new();
	wtapplet->box = GTK_BOX(gtk_hbox_new(FALSE, 0));
	wtapplet->icon = GTK_IMAGE(gtk_image_new());
	wtapplet->title = GTK_LABEL(gtk_label_new(NULL));
	wtapplet->eb_icon = GTK_EVENT_BOX(gtk_event_box_new());
	wtapplet->eb_title = GTK_EVENT_BOX(gtk_event_box_new());
	wtapplet->orient = panel_applet_get_orient(wtapplet->applet);
	wtapplet->size_hints = g_new(gint,2);

	// Widgets to eventboxes, eventboxes to box
	gtk_widget_set_can_focus(GTK_WIDGET(wtapplet->icon), TRUE);
	gtk_widget_set_can_focus(GTK_WIDGET(wtapplet->title), TRUE);
	gtk_container_add (GTK_CONTAINER (wtapplet->eb_icon), GTK_WIDGET(wtapplet->icon));
	gtk_container_add (GTK_CONTAINER (wtapplet->eb_title), GTK_WIDGET(wtapplet->title));
	gtk_event_box_set_visible_window (wtapplet->eb_icon, FALSE);
	gtk_event_box_set_visible_window (wtapplet->eb_title, FALSE);

	// Rotate & place elements
	setAlignment(wtapplet, (gfloat)wtapplet->prefs->alignment);
	placeWidgets(wtapplet);

	// Add box to applet
	gtk_container_add (GTK_CONTAINER(wtapplet->applet), GTK_WIDGET(wtapplet->box));

	// Set event handling (icon & title clicks)
	g_signal_connect(G_OBJECT (wtapplet->eb_icon), "button-press-event", G_CALLBACK (icon_clicked), wtapplet);
	g_signal_connect(G_OBJECT (wtapplet->eb_title), "button-press-event", G_CALLBACK (title_clicked), wtapplet);
	
	// Global window tracking
	g_signal_connect(wtapplet->activescreen, "active-window-changed", G_CALLBACK (active_window_changed), wtapplet); // <-- this thing is crashing with compiz !!!
	g_signal_connect(wtapplet->activescreen, "viewports-changed", G_CALLBACK (viewports_changed), wtapplet);
	g_signal_connect(wtapplet->activescreen, "active-workspace-changed", G_CALLBACK (active_workspace_changed), wtapplet);
	g_signal_connect(wtapplet->activescreen, "window-closed", G_CALLBACK (window_closed), wtapplet);
	g_signal_connect(wtapplet->activescreen, "window-opened", G_CALLBACK (window_opened), wtapplet);

	// g_signal_connect(G_OBJECT (wtapplet->title), "size-request", G_CALLBACK (applet_title_size_request), wtapplet);
	g_signal_connect(G_OBJECT (wtapplet->applet), "size-allocate", G_CALLBACK (applet_size_allocate), wtapplet);

	g_signal_connect(G_OBJECT (wtapplet->applet), "change-background", G_CALLBACK (applet_change_background), wtapplet);
	g_signal_connect(G_OBJECT (wtapplet->applet), "change-orient", G_CALLBACK (applet_change_orient), wtapplet);
	g_signal_connect(G_OBJECT (wtapplet->applet), "change-size", G_CALLBACK (applet_change_pixel_size), wtapplet);
	
	// Track active window changes
	wtapplet->active_handler_state = 
		g_signal_connect(G_OBJECT (wtapplet->activewindow), "state-changed", G_CALLBACK (active_window_state_changed), wtapplet);
	wtapplet->active_handler_name = 
		g_signal_connect(G_OBJECT (wtapplet->activewindow), "name-changed", G_CALLBACK (active_window_nameicon_changed), wtapplet);
	wtapplet->active_handler_icon = 
		g_signal_connect(G_OBJECT (wtapplet->activewindow), "icon-changed", G_CALLBACK (active_window_nameicon_changed), wtapplet);

	
	// Setup applet right-click menu
	GtkActionGroup *action_group = gtk_action_group_new ("WindowButtons Applet Actions");
	gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
	gtk_action_group_add_actions (action_group, windowtitle_menu_actions, G_N_ELEMENTS (windowtitle_menu_actions), wtapplet);
	panel_applet_setup_menu (applet, windowtitle_menu_items, action_group);
	panel_applet_set_background_widget (wtapplet->applet, GTK_WIDGET (wtapplet->applet)); // Automatic background update
	
	toggleExpand  (wtapplet);
	toggleHidden  (wtapplet);	// Properly hide or show stuff
	updateTitle   (wtapplet);
}
int main (int argc, char **argv)
{
    GdkWindow *rootwindow;		 /* RootWindow of X11*/
    GMainLoop *loop;                       /* the event loop */
    char *pw_dir;
    char *xml_file;
    uid_t uid;
    struct passwd *pass;

    /* inits some gdk stuff */
    gdk_init(&argc, &argv);

#ifdef ENABLE_LIBWNCK
    screen = wnck_screen_get_default ();
    wnck_screen_force_update (screen);  
#endif
  
    parse_options(&argc, &argv);
  
    uid = getuid();
    pass = getpwuid (uid);
    pw_dir = pass->pw_dir;
  
    xml_file = (char*) malloc (sizeof (char) * (strlen (XML_FILE) + strlen (pw_dir) + 1));
    sprintf (xml_file, "%s%s", pw_dir, XML_FILE);
    
    eventlist = parseDoc (xml_file);
    if (eventlist == NULL)
    {
	g_print ("xml error or no elements in list\n");
	exit (1);
    }
    free (xml_file);

    rootwindow = gdk_window_foreign_new (gdk_x11_get_default_root_xwindow());
    /*rootwindow = gdk_window_foreign_new (0x1200002); */

    if (rootwindow == NULL)
    {
	g_print ("rootwindow == NULL\n");
	exit (1);
    }
  
    /* check if GDK_BUTTON_PRESS_MASK is available */
    gdk_error_trap_push ();

    /* ... Call the X function which may cause an error here ... */
    gdk_window_set_events (rootwindow, GDK_BUTTON_PRESS_MASK);
    gdk_window_set_events (rootwindow, GDK_SCROLL_MASK);
  
    /* Flush the X queue to catch errors now. */
    gdk_flush ();

    if (gdk_error_trap_pop ())
    {
	char error[] = "grootevent: an error occured while querying the X server.\n"
	    "A window manager or an application is already grapping\n"
	    "the buttons from the root window.\n\n"
	    "Please read the documentation to get more help about this.\n";
	g_print (error);
	exit (1);
    }
    
    gdk_event_handler_set (event_func, NULL, NULL);

    loop = g_main_loop_new (NULL, FALSE);
    g_main_loop_run (loop);
   
    return 0;
}