예제 #1
0
파일: wnck-test.c 프로젝트: TCC-FEI/VC
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;
}
예제 #2
0
파일: main.c 프로젝트: ashokgujju/speech
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;
}
예제 #3
0
/**
 * wnck_set_default_mini_icon_size:
 * @size: the default size for windows and application mini icons.
 *
 * The default main icon size is %WNCK_DEFAULT_MINI_ICON_SIZE. This function
 * allows to change this value.
 *
 * Since: 2.4.6
 */
void
wnck_set_default_mini_icon_size (gsize size)
{
  int default_screen;
  WnckScreen *screen;
  GList *l;

  default_mini_icon_size = size;

  default_screen = DefaultScreen (_wnck_get_default_display ());
  screen = _wnck_screen_get_existing (default_screen);

  if (WNCK_IS_SCREEN (screen))
    {
      /* Make applications and icons to reload their icons */
      for (l = wnck_screen_get_windows (screen); l; l = l->next)
        {
          WnckWindow *window = WNCK_WINDOW (l->data);
          WnckApplication *application = wnck_window_get_application (window);

          _wnck_window_load_icons (window);

          if (WNCK_IS_APPLICATION (application))
            _wnck_application_load_icons (application);
        }
    }
}
예제 #4
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)));
}
예제 #5
0
dlle___ void for__(int*err,void* shangji,const char*code,WnckScreen *screen){
	GList *window_l;
	char p1[32];
	for (window_l = wnck_screen_get_windows (screen); window_l != NULL; window_l = window_l->next){
		WnckWindow *window = WNCK_WINDOW (window_l->data);
		sprintf(p1,"%lx",(long)window);
		cb_(jsq_,shangji,err,code,false,1,p1);
	}
}
예제 #6
0
static void continue_all(WnckScreen *screen)
{
	GList *window_l;
	for (window_l = wnck_screen_get_windows(screen); window_l != NULL; window_l = window_l->next) {
		WnckWindow *window = WNCK_WINDOW(window_l->data);
		int pid = wnck_window_get_pid(window);
		cont_pid(pid);
	}
}
예제 #7
0
static void
button_toggled_cb (GtkToggleButton* button)
{
  if (gtk_toggle_button_get_active (button))
    {
      GtkWidget* item = NULL;
      GList    * window;

      g_return_if_fail (!menu);

      menu = g_object_ref_sink (gtk_menu_new ());
      item = gtk_menu_item_new_with_label (wnck_workspace_get_name (PRIV (button)->workspace));
      gtk_widget_set_sensitive (item, FALSE);
#if 0
      g_signal_connect (item, "select",
                        G_CALLBACK (select_cb), PRIV (button)->workspace);
      g_signal_connect (item, "deselect",
                        G_CALLBACK (unselect_cb), PRIV (button)->workspace);
#endif
      gtk_widget_show (item);
      gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

      item = gtk_separator_menu_item_new ();
      gtk_widget_show (item);
      gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);

      for (window = wnck_screen_get_windows (wnck_workspace_get_screen (PRIV (button)->workspace)); window; window = window->next)
        {
          if (!wnck_window_is_on_workspace (window->data, PRIV (button)->workspace) ||
              (wnck_window_get_state (window->data) & WNCK_WINDOW_STATE_SKIP_TASKLIST))
            {
              continue;
            }

          item = window_menu_item_new (window->data);
          gtk_widget_show (item);
          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
        }

      gtk_menu_attach_to_widget (GTK_MENU (menu),
                                 GTK_WIDGET (button),
                                 NULL);

      gtk_menu_set_screen (GTK_MENU (menu),
                           gtk_widget_get_screen (GTK_WIDGET (button)));
      gtk_menu_popup (GTK_MENU (menu),
                      NULL, NULL,
                      menu_position_func, button,
                      0, gtk_get_current_event_time ());

      g_object_add_weak_pointer (G_OBJECT (menu), (gpointer*)&menu);

      g_signal_connect (menu, "selection-done",
                        G_CALLBACK (untoggle), button);
    }
}
예제 #8
0
static void add_all(MacMenu* mmb)
{
  GList* windows = wnck_screen_get_windows(mmb->screen);
  GList* node = windows;
  while (node != NULL) {
    WnckWindow* wnckwin = (WnckWindow*) node->data;
    if (is_menubar(wnckwin))
      add_menubar(mmb, wnckwin);
    node = node->next;
  }
}
예제 #9
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;
}
예제 #10
0
static void
wnck_selector_unrealize (GtkWidget *widget)
{
  WnckSelector *selector;
  WnckScreen   *screen;
  GList        *l;

  selector = WNCK_SELECTOR (widget);
  screen = wnck_selector_get_screen (selector);

  wnck_selector_disconnect_from_screen (selector, screen);

  for (l = wnck_screen_get_windows (screen); l; l = l->next)
    wnck_selector_disconnect_from_window (selector, l->data);

  GTK_WIDGET_CLASS (wnck_selector_parent_class)->unrealize (widget);
}
예제 #11
0
파일: layout.c 프로젝트: jpinon/bonnye
static void get_workspace_geometry(int spaceid,
                                   int *x,
                                   int *y,
                                   int *width,
                                   int *height)
{
    workspace_t *workspace = workspace_get(spaceid);
    workspace_geometry_t *g = &workspace->geometry;
    WnckWorkspace *space = workspace->workspace;
    time_t now = time(NULL);

    if (now > g->last_update + CACHE_DURATION) {
        WnckWindow *window;
        GList      *l;
        GList *all_windows = wnck_screen_get_windows (wnck_workspace_get_screen (space));
        int left   = 0;
        int right  = 0;
        int top    = 0;
        int bottom = 0;
        for (l = all_windows; l; l = l->next) {
            window = WNCK_WINDOW (l->data);
            if (wnck_window_get_workspace(window) == space ||
                    wnck_window_is_pinned(window)) {
                int tl, tr, tt, tb;
                if (get_window_strut(window, &tl, &tr, &tt, &tb)) {
                    if (tl > left  ) left   = tl;
                    if (tr > right ) right  = tr;
                    if (tt > top   ) top    = tt;
                    if (tb > bottom) bottom = tb;
                }
            }
        }
        g->x      = wnck_workspace_get_viewport_x(space) + left;
        g->y      = wnck_workspace_get_viewport_y(space) + top;
        g->width  = wnck_workspace_get_width(space) - left - right;
        g->height = wnck_workspace_get_height(space) - top - bottom;
        g->last_update = now;
    }

    *x = g->x;
    *y = g->y;
    *width = g->width;
    *height = g->height;
}
예제 #12
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;
	}	
}
예제 #13
0
static void
wnck_pid_read_resource_usage_no_cache (GdkDisplay        *gdisplay,
                                       gulong             pid,
                                       WnckResourceUsage *usage)
{
  Display *xdisplay;
  int i;

  xdisplay = GDK_DISPLAY_XDISPLAY (gdisplay);

  i = 0;
  while (i < ScreenCount (xdisplay))
    {
      WnckScreen *screen;
      GList *windows;
      GList *tmp;

      screen = wnck_screen_get (i);

      g_assert (screen != NULL);

      windows = wnck_screen_get_windows (screen);
      tmp = windows;
      while (tmp != NULL)
        {
          if (wnck_window_get_pid (tmp->data) == pid)
            {
              wnck_xid_read_resource_usage (gdisplay,
                                            wnck_window_get_xid (tmp->data),
                                            usage);

              /* stop on first window found */
              return;
            }

          tmp = tmp->next;
        }

      ++i;
    }
}
예제 #14
0
static void
wnck_selector_realize (GtkWidget *widget)
{
  WnckSelector *selector;
  WnckScreen   *screen;
  WnckWindow   *window;
  GList        *l;

  GTK_WIDGET_CLASS (wnck_selector_parent_class)->realize (widget);

  selector = WNCK_SELECTOR (widget);
  screen = wnck_selector_get_screen (selector);

  window = wnck_screen_get_active_window (screen);
  wnck_selector_set_active_window (selector, window);

  for (l = wnck_screen_get_windows (screen); l; l = l->next)
    wnck_selector_connect_to_window (selector, l->data);

  wnck_selector_connect_to_screen (selector, screen);
}
예제 #15
0
static void on_active_window_changed(WnckScreen *screen,
		WnckWindow *previously_active_window,
		gpointer user_data)
{
	GList *window_l;
	WnckWindow *active_window = wnck_screen_get_active_window(screen);
	WnckWorkspace *active_workspace = wnck_screen_get_active_workspace(screen);
	GList *pids_current = NULL;
	GList *pids_other = NULL;

	for (window_l = wnck_screen_get_windows(screen); window_l != NULL; window_l = window_l->next) {
		WnckWindow *window = WNCK_WINDOW(window_l->data);
		WnckApplication *app = wnck_application_get(wnck_window_get_group_leader(window));
		WnckWorkspace *w_workspace = wnck_window_get_workspace(window);
		if (!w_workspace)
			continue;
		GList *app_window_l;

		int w_pid = wnck_application_get_pid(app);
		if (w_workspace == active_workspace) {
			GList *g = g_list_find(pids_current, GINT_TO_POINTER(w_pid));
			if (!g) pids_current = g_list_append(pids_current, GINT_TO_POINTER(w_pid));
		} else {
			GList *g = g_list_find(pids_other, GINT_TO_POINTER(w_pid));
			if (!g) pids_other = g_list_append(pids_other, GINT_TO_POINTER(w_pid));
		}
	}
	for (; pids_other != NULL; pids_other = pids_other->next) {
		GList *g = g_list_find(pids_current, pids_other->data);
		if (g)
			g_print("Another window of this application is active\n");
		else
			g_print("PID: %d\n", stop_pid(GPOINTER_TO_INT(pids_other->data)));
	}
	for (; pids_current != NULL; pids_current = pids_current->next) {
		cont_pid(GPOINTER_TO_INT(pids_current->data));
	}
	g_print("-----\n");
}
예제 #16
0
파일: gedit.c 프로젝트: TCC-FEI/VC
guint32 raise_window(gpointer data) {
    guint32 status;

    GList* list;
    WnckWindow* window;
    WnckApplication* app;

    control_plugin_t* self = (control_plugin_t*) data;

    if (!self)
        return CTRL_INVALID_SELF;

    if (!self->vcwm.screen)
        return CTRL_INVALID_SCREEN;

    status = CTRL_WINDOW_NOT_FOUND;
    list = wnck_screen_get_windows(self->vcwm.screen);

    for (list; list != NULL; list = list->next) {
        window = WNCK_WINDOW(list->data);

        if (!window)
            continue;

        app = wnck_window_get_application(window);

        if (!app)
            continue;

        if (strcmp(wnck_application_get_name(app), "gedit") == 0) {
            wnck_window_activate(window, (guint32) time(NULL));
            status = CTRL_SUCCESS;
            break;
        }
    }

    return status;
}
예제 #17
0
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;
}
예제 #18
0
파일: main.c 프로젝트: ashokgujju/speech
static void utterance_loop(int argc,char *argv[])
{
  int16 adbuf[4096];
  int32 k, fr, ts, rem;
  char *hyp;
  cont_ad_t *cont;
  int count=0,i=1,flag;
  char word[256];
  /* Initialize continuous listening module */
  if ((cont = cont_ad_init (ad, ad_read)) == NULL)
    E_FATAL("cont_ad_init failed\n");
  if (ad_start_rec (ad) < 0)
    E_FATAL("ad_start_rec failed\n");
  if (cont_ad_calib (cont) < 0)
    E_FATAL("cont_ad_calib failed\n");
  
  for (;;)
    {
           /* Indicate listening for next utterance */
      printf ("READY....\n");
      fflush (stdout); fflush (stderr);
      
      /* Await data for next utterance */
      while ((k = cont_ad_read (cont, adbuf, 4096)) == 0)
	sleep_msec(200);
      
      if (k < 0)
	E_FATAL("cont_ad_read failed\n");
      
      /*
       * Non-zero amount of data received; start recognition of new utterance.
       * NULL argument to uttproc_begin_utt => automatic generation of utterance-id.
       */
      if (uttproc_begin_utt (NULL) < 0)
	E_FATAL("uttproc_begin_utt() failed\n");
      uttproc_rawdata (adbuf, k, 0);
      printf ("Listening...\n"); fflush (stdout);
      
      /* Note timestamp for this first block of data */
      ts = cont->read_ts;
      
      /* Decode utterance until end (marked by a "long" silence, >1sec) */
      for (;;) {
	/* Read non-silence audio data, if any, from continuous listening module */
	if ((k = cont_ad_read (cont, adbuf, 4096)) < 0)
	  E_FATAL("cont_ad_read failed\n");
	if (k == 0) {
	  /*
	   * No speech data available; check current timestamp with most recent
	   * speech to see if more than 1 sec elapsed.  If so, end of utterance.
	   */
	  if ((cont->read_ts - ts) > DEFAULT_SAMPLES_PER_SEC)
	    break;
	} else {
	  /* New speech data received; note current timestamp */
	  ts = cont->read_ts;
	}
	
	/*
	 * Decode whatever data was read above.  NOTE: Non-blocking mode!!
	 * rem = #frames remaining to be decoded upon return from the function.
	 */
	rem = uttproc_rawdata (adbuf, k, 0);
	
	/* If no work to be done, sleep a bit */
	if ((rem == 0) && (k == 0))
	  sleep_msec (20);
      }
      
      /*
       * Utterance ended; flush any accumulated, unprocessed A/D data and stop
       * listening until current utterance completely decoded
       */
      ad_stop_rec (ad);
      while (ad_read (ad, adbuf, 4096) >= 0);
      cont_ad_reset (cont);
      
      printf ("Stopped listening, please wait...\n"); fflush (stdout);
#if 0
      /* Power histogram dump (FYI) */
      cont_ad_powhist_dump (stdout, cont);
#endif
      /* Finish decoding, obtain and print result */
      uttproc_end_utt ();
      if (uttproc_result (&fr, &hyp, 1) < 0)
	E_FATAL("uttproc_result failed\n");
      
      
      /*obtaining the results*/
      sscanf (hyp, "%s", word);
      printf ("%d: %s\n", fr,word); fflush (stdout);
 	  win=wnck_screen_get_active_window(scr);
	  tmp=wnck_screen_get_windows(wnck_window_get_screen(win));
	
      i=g_list_index(tmp,win);/*the place value  of window in the list*/
      printf("<<<<<<<<<<<<<<>>>>>>>>>>>>>>i:%d,%s\n\n\n",i,wnck_window_get_name(win));
      count=0;
      while(tmp!=NULL)
	{
	  printf("%d:%s\n\n",count,wnck_window_get_name(tmp->data));
	  tmp=tmp->next;count++;
	}
            /*comparison and action for DAKKU */
      if(strcmp(word,"PADU")==0)
	g_spawn_command_line_async("totem --play",NULL);
      if(strcmp(word,"EMACS")==0)
	g_spawn_command_line_async("emacs",NULL);
      if(strcmp(word,"SAMAYAM")==0)
	g_spawn_command_line_async(DHVANISCRIPT,NULL);
      if(strcmp(word,"VALAPARATHU")==0)
	g_spawn_command_line_async("epiphany",NULL);
      if(strcmp(word,"EAZHUTHIDAM")==0)
      g_spawn_command_line_async("gedit",NULL);
      /*Minimizing current active window*/
           if (strcmp (word, "CHURUKKU") == 0)
	      wnck_window_minimize(win);
      /*Moving focus(active window)towards the left of the panel.The active window is changed to
 the next normal window on the left.effect of alt+tab key press*/
      if(strcmp(word,"ADUTHATHU")==0)
	{
	  win=wnck_screen_get_active_window(scr);
	  tmp=wnck_screen_get_windows(wnck_window_get_screen(win));
	
	  while(tmp!=NULL)/*while traces the current active window through the list*/
	    {
	      printf("tracing:current:%s\n\ntmp:%s\n\n",wnck_window_get_name(win),wnck_window_get_name(tmp->data));	   
	      if(tmp->data==win)
		{   
			  printf("BREAKED with tmp:%s\n",wnck_window_get_name(tmp->data));
		  break;
		}
	    
	      tmp=tmp->next;
	      
	    }
	  if(tmp==NULL){printf("BULL SHIT GIVE A WINDOW IN THE LIST\n\n");}//exit(1);}
	  if(tmp->next==NULL)/*shifting back to the first window by refreshing the list*/
	    tmp=wnck_screen_get_windows(wnck_window_get_screen(win));
	  else
	    tmp=tmp->next;
	  printf("cuow:%s\n\n",wnck_window_get_name(tmp->data));
	
		
	  
	  while(tmp!=NULL)
	    {
	      printf("tmp in while:%s\n\n",wnck_window_get_name(tmp->data));
	      if(wnck_window_get_window_type(tmp->data)==WNCK_WINDOW_NORMAL)
		{
		  wnck_window_activate(tmp->data,0);
		  flag=1;
		  break;
		}
	      else
		tmp=tmp->next;
	    }
	  
	  if(flag==0)
	    {
	      printf("FLAG==0 DETECTED:\n");
	      tmp=wnck_screen_get_windows(wnck_window_get_screen(win));
	      while(tmp!=NULL)
		{
		  printf("tmp in last while:%s\n",wnck_window_get_name(tmp->data));
		  if(wnck_window_get_window_type(tmp->data)==WNCK_WINDOW_NORMAL)
		    {
		      wnck_window_activate(tmp->data,0);
		      break;
		    }
		  else
		    tmp=tmp->next;
		}
	    }
	
	 
	}
      if(strcmp(word,"VALUTHAKKU")==0)
	{
	  if(wnck_window_get_window_type(win)!= WNCK_WINDOW_NORMAL)
	    {
	      if(wnck_window_get_window_type(wnck_screen_get_previously_active_window(scr))==WNCK_WINDOW_NORMAL)
		win=wnck_screen_get_previously_active_window(scr);
	    }
	      wnck_window_unminimize(win,0);
	    
	}

      while(gtk_events_pending())/*gtk probing and refreshing the win and tmp*/
	{
	  gtk_main_iteration();
	  win=wnck_screen_get_active_window(scr);
	  tmp=wnck_screen_get_windows(wnck_window_get_screen(win));
	  
	}
      
      /* Resume A/D recording for next utterance */
      if (ad_start_rec (ad) < 0)
	E_FATAL("ad_start_rec failed\n");
    }
  
  cont_ad_close (cont);
}
예제 #19
0
static void
wnck_selector_on_show (GtkWidget *widget, WnckSelector *selector)
{
  GtkWidget *separator;
  WnckScreen *screen;
  WnckWorkspace *workspace;
  int nb_workspace;
  int i;
  GList **windows_per_workspace;
  GList *windows;
  GList *l, *children;

  /* Remove existing items */
  children = gtk_container_get_children (GTK_CONTAINER (selector->priv->menu));
  for (l = children; l; l = l->next)
    gtk_container_remove (GTK_CONTAINER (selector->priv->menu), l->data);
  g_list_free (children);

  if (selector->priv->window_hash)
    g_hash_table_destroy (selector->priv->window_hash);
  selector->priv->window_hash = g_hash_table_new_full (g_direct_hash,
                                                 g_direct_equal,
                                                 NULL, g_free);

  screen = wnck_selector_get_screen (selector);

  nb_workspace = wnck_screen_get_workspace_count (screen);
  windows_per_workspace = g_malloc0 (nb_workspace * sizeof (GList *));

  /* Get windows ordered by workspaces */
  windows = wnck_screen_get_windows (screen);
  windows = g_list_sort (windows, wnck_selector_windows_compare);

  for (l = windows; l; l = l->next)
    {
      workspace = wnck_window_get_workspace (l->data);
      if (!workspace && wnck_window_is_pinned (l->data))
        workspace = wnck_screen_get_active_workspace (screen);
      if (!workspace)
        continue;
      i = wnck_workspace_get_number (workspace);
      windows_per_workspace[i] = g_list_prepend (windows_per_workspace[i],
                                                 l->data);
    }

  /* Add windows from the current workspace */
  workspace = wnck_screen_get_active_workspace (screen);
  if (workspace)
    {
      i = wnck_workspace_get_number (workspace);

      windows_per_workspace[i] = g_list_reverse (windows_per_workspace[i]);
      for (l = windows_per_workspace[i]; l; l = l->next)
        wnck_selector_append_window (selector, l->data);
      g_list_free (windows_per_workspace[i]);
      windows_per_workspace[i] = NULL;
    }

  /* Add separator */
  separator = gtk_separator_menu_item_new ();
  gtk_menu_shell_append (GTK_MENU_SHELL (selector->priv->menu), separator);

  /* Add windows from other workspaces */
  for (i = 0; i < nb_workspace; i++)
    {
      wnck_selector_add_workspace (selector, screen, i);
      windows_per_workspace[i] = g_list_reverse (windows_per_workspace[i]);
      for (l = windows_per_workspace[i]; l; l = l->next)
        wnck_selector_append_window (selector, l->data);
      g_list_free (windows_per_workspace[i]);
      windows_per_workspace[i] = NULL;
    }
  g_free (windows_per_workspace);

  selector->priv->no_windows_item = wnck_selector_item_new (selector,
		  					    _("No Windows Open"),
							    NULL);
  gtk_widget_set_sensitive (selector->priv->no_windows_item, FALSE);
  gtk_menu_shell_append (GTK_MENU_SHELL (selector->priv->menu),
                         selector->priv->no_windows_item);

  wnck_selector_make_menu_consistent (selector);
}
예제 #20
0
static gboolean
wnck_selector_scroll_event (GtkWidget      *widget,
                            GdkEventScroll *event)
{
  WnckSelector *selector;
  WnckScreen *screen;
  WnckWorkspace *workspace;
  GList *windows_list;
  GList *l;
  WnckWindow *window;
  WnckWindow *previous_window;
  gboolean should_activate_next_window;

  selector = WNCK_SELECTOR (widget);

  screen = wnck_selector_get_screen (selector);
  workspace = wnck_screen_get_active_workspace (screen);
  windows_list = wnck_screen_get_windows (screen);
  windows_list = g_list_sort (windows_list, wnck_selector_windows_compare);

  /* Walk through the list of windows until we find the active one
   * (considering only those windows on the same workspace).
   * Then, depending on whether we're scrolling up or down, activate the next
   * window in the list (if it exists), or the previous one.
   */
  previous_window = NULL;
  should_activate_next_window = FALSE;
  for (l = windows_list; l; l = l->next)
    {
      window = WNCK_WINDOW (l->data);

      if (wnck_window_is_skip_tasklist (window))
        continue;

      if (workspace && !wnck_window_is_pinned (window) &&
          wnck_window_get_workspace (window) != workspace)
        continue;

      if (should_activate_next_window)
        {
          wnck_window_activate_transient (window, event->time);
          return TRUE;
        }

      if (wnck_window_is_active (window))
        {
          switch (event->direction)
            {
              case GDK_SCROLL_UP:
                if (previous_window != NULL)
                  {
                    wnck_window_activate_transient (previous_window,
                                                    event->time);
                    return TRUE;
                  }
              break;

              case GDK_SCROLL_DOWN:
                should_activate_next_window = TRUE;
              break;

              case GDK_SCROLL_LEFT:
              case GDK_SCROLL_RIGHT:
                /* We ignore LEFT and RIGHT scroll events. */
              break;

              case GDK_SCROLL_SMOOTH:
              break;

              default:
                g_assert_not_reached ();
            }
        }

      previous_window = window;
    }

  return TRUE;
}