示例#1
0
static gint
wnck_selector_windows_compare (gconstpointer  a,
                               gconstpointer  b)
{
  int posa;
  int posb;

  posa = wnck_window_get_sort_order (WNCK_WINDOW (a));
  posb = wnck_window_get_sort_order (WNCK_WINDOW (b));

  return (posa - posb);
}
示例#2
0
/**
 * ww_filter_strut_windows
 * @windows: List of %WnckWindow<!-- -->s to filter
 * @current_workspace: Only use windows on this workspace. %NULL indicates
 *                     that all windows should be used
 *
 * Extract all windows that should be considered "hard edges", or windows
 * blocking the movement of other windows from %GList of
 * %WnckWindows. The prime example of a "strut" is a standard desktop panel.
 *
 * Return value: A newly allocated list containing only windows that are 
 * not minimized, maximized, or shaded, and is wnck_window_skip_task_list() and
 * wnck_window_is_pinned().
 */
GList*
ww_filter_strut_windows (GList * windows, WnckWorkspace *current_workspace)
{
	GList       *next;
	GList       *result;
	WnckWindow  *win;
	WnckWorkspace *win_ws;

	result = NULL;    
	
	for (next = windows; next; next = next->next)
	{
    win = WNCK_WINDOW(next->data);
    
    /* Debug code to print out all window geometries: */
    /*int x, y, w, h;
    wnck_window_get_geometry(win, &x, &y, &w, &h);
    g_debug ("\"%s\": (%d, %d)@%dx%d",
             wnck_window_get_name(win), x, y, w, h);*/
    		
		if (wnck_window_get_window_type(win) == WNCK_WINDOW_DOCK)
		{
			win_ws = wnck_window_get_workspace (win);
			
			if (current_workspace == NULL ||
				win_ws == current_workspace ||				
				win_ws == NULL)	
				result = g_list_append (result, win);
		}  
  }
	
	return result;
}
示例#3
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;
}
示例#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
/**
 * 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);
        }
    }
}
示例#6
0
/**
 * ww_filter_user_windows
 * @windows: List of %WnckWindow<!-- -->s to filter
 * @current_workspace: Only use windows on this workspace. %NULL indicates
 *                     that all windows should be used
 *
 * Extract the user controlled visible windows from a %GList of
 * %WnckWindows.
 *
 * Return value: A newly allocated list containing only windows that are 
 * not minimized, shaded, or wnck_window_skip_task_list() on the current
 * workspace.
 */
GList*
ww_filter_user_windows (GList * windows, WnckWorkspace *current_workspace)
{
	GList       *next;
	GList       *result;
	WnckWindow  *win;
	WnckWorkspace *win_ws;

	result = NULL;    
	
	for (next = windows; next; next = next->next)
	{
		win = WNCK_WINDOW(next->data);
		if (!wnck_window_is_skip_tasklist (win) &&
			!wnck_window_is_minimized (win) &&
			!wnck_window_is_maximized (win) &&
			!wnck_window_is_shaded (win))
		{
			win_ws = wnck_window_get_workspace (win);
			
			if (current_workspace == NULL
			    || (win_ws == current_workspace
			        && wnck_window_is_in_viewport(win, current_workspace))
			    || win_ws == NULL)	
				result = g_list_append (result, win);
				
		}
	}
	
	return result;
}
示例#7
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);
	}
}
示例#8
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);
	}
}
示例#9
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;
}
示例#10
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");
}
示例#11
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;
}
示例#12
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;
}
示例#13
0
/**
 * ww_find_neighbour
 * @screen:
 * @windows:
 * @active:
 * @direction:
 *
 * Return value: The neighbouring window from @windows in the given direction
 *               or %NULL in case no window is found or @active is %NULL
 */
WnckWindow*
ww_find_neighbour (WnckScreen	*screen,
                   GList		*windows,
                   WnckWindow	*active,
                   WwDirection	direction)
{
	WnckWindow	*neighbour;
	GList		*next;
	int			ax, ay, aw, ah; /* active window geometry */
	int			wx, wy; /* geometry for currently checked window */ 
	int			nx, ny; /* geometry of neighbour */
	double		wdist, ndist; /* distance to active window */

	neighbour = NULL;
	
	g_return_val_if_fail (WNCK_IS_SCREEN(screen), NULL);
	
	if (g_list_length(windows) == 0)
    {
		return NULL;
    }
	
	/* If there is no active window, do nothing */
	if (active == NULL
		|| wnck_window_is_skip_tasklist (active)) {
		g_debug ("No active window");
		return NULL;
	}

	nx = ny = 0;
	ndist = 100000;

	wnck_window_get_geometry (active, &ax, &ay, &aw, &ah);
	g_debug("Active window '%s' (%d, %d) @ %d x %d",
	        wnck_window_get_name (active), ax, ay, aw, ah);

	/* Set ax and ay to the center of grav. for active */
	ww_window_center (active, &ax, &ay);
	
	if ( direction == LEFT )
	{
		for ( next = windows; next; next = next->next )
		{
			ww_window_center (WNCK_WINDOW (next->data), &wx, &wy);
			wdist = ww_y_weighted_distance (wx, wy, ax, ay);
			if ( wx < ax )
			{
				if ( wdist < ndist )
				{
					neighbour = WNCK_WINDOW (next->data);
					ndist = wdist;
				}
			} 
		}
	}
	else if ( direction == RIGHT )
	{
		for ( next = windows; next; next = next->next )
		{
			ww_window_center (WNCK_WINDOW (next->data), &wx, &wy);
			wdist = ww_y_weighted_distance (wx, wy, ax, ay);
			if ( wx > ax )
			{
				if ( wdist < ndist )
				{
					neighbour = WNCK_WINDOW (next->data);
					ndist = wdist;
				}
			}
		}
	}
	else if ( direction == DOWN )
	{
		for ( next = windows; next; next = next->next )
		{
			ww_window_center (WNCK_WINDOW (next->data), &wx, &wy);
			wdist = ww_x_weighted_distance (wx, wy, ax, ay);
			if ( wy > ay )
			{
				if ( wdist < ndist )
				{
					neighbour = WNCK_WINDOW (next->data);
					ndist = wdist;
				}
			}
		}
	}
	else if ( direction == UP )
	{
		for ( next = windows; next; next = next->next )
		{
			ww_window_center (WNCK_WINDOW (next->data), &wx, &wy);
			wdist = ww_x_weighted_distance (wx, wy, ax, ay);
			if ( wy < ay )
			{
				if ( wdist < ndist )
				{
					neighbour = WNCK_WINDOW (next->data);
					ndist = wdist;
				}
			}
		}
	}

	if (neighbour)
		g_debug ("Found neighbour '%s'",
		         wnck_window_get_name (neighbour));
	
	return neighbour; 
}
示例#14
0
/**
 * ww_calc_bounds
 * @screen: The screen for which to calculate the bounds
 * @struts: A list of %WnckWindow<!---->s that should be treated as
 *          blocking elements on the desktop. Eg. panels and docks
 * @x: Return value for the left side of the bounding box
 * @y: Return value for the top of the box
 * @right: Return coordinate for the right side of the bounding box
 * @bottom: Return value for the bottom coordinate of the bounding box
 *
 * Calculate the maximal rect within a set of blocking windows.
 * For simplicity this method assumes that all struts are along the screen
 * edges and expand over the entire screen edge. Ie a standard panel setup.
 */
void
ww_calc_bounds (WnckScreen *screen,
                GList *struts, 
                int *left, 
                int *top, 
                int *right, 
                int *bottom)
{
	GList		*next;
	WnckWindow  *win;
	int wx, wy, ww, wh; /* current window geom */
	int edge_l, edge_t, edge_b, edge_r;
	int screen_w, screen_h;
	
	edge_l = 0;
	edge_t = 0;
	edge_r = wnck_screen_get_width (screen);
	edge_b = wnck_screen_get_height (screen);
	
	screen_w = edge_r;
	screen_h = edge_b;
	
	for (next = struts; next; next = next->next)
	{	
		win = WNCK_WINDOW (next->data);
		wnck_window_get_geometry (win, &wx, &wy, &ww, &wh);
		
		/* Left side strut */
		if (is_high(ww, wh) && wx == 0) {
			edge_l = MAX(edge_l, ww);
		}
		
		/* Top struct */
		else if (is_broad(ww, wh) && wy == 0) {
			edge_t = MAX (edge_t, wh);
		}
		
		/* Right side strut */
		else if (is_high(ww, wh) && (wx+ww) == screen_w) {
			edge_r = MIN(edge_r, wx);
		}
		
		/* Bottom struct */
		else if (is_broad(ww, wh) && (wy+wh) == screen_h) {
			edge_b = MIN (edge_b, wy);
		}
		
		else {
			g_warning ("Desktop layout contains floating element at "
					   "(%d, %d)@%dx%d", wx, wy, ww, wh);
		}
	}
	
	g_debug ("Calculated desktop bounds (%d, %d), (%d, %d)",
			 edge_l, edge_t, edge_r, edge_b);
	
	*left = edge_l;
	*top = edge_t;
	*right = edge_r;
	*bottom = edge_b;
}