Ejemplo n.º 1
0
// heavily inspired by dwm.c
void client_update_wm_hints(HSClient* client) {
    XWMHints* wmh = XGetWMHints(g_display, client->window);
    if (!wmh) {
        return;
    }

    Window focused_window = frame_focused_window(g_cur_frame);
    if ((focused_window == client->window)
        && wmh->flags & XUrgencyHint) {
        // remove urgency hint if window is focused
        wmh->flags &= ~XUrgencyHint;
        XSetWMHints(g_display, client->window, wmh);
    } else {
        bool newval = (wmh->flags & XUrgencyHint) ? true : false;
        if (newval != client->urgent) {
            client->urgent = newval;
            char winid_str[STRING_BUF_SIZE];
            snprintf(winid_str, STRING_BUF_SIZE, "0x%lx", client->window);
            client_setup_border(client, focused_window == client->window);
            hook_emit_list("urgent", client->urgent ? "on":"off", winid_str, NULL);
            tag_set_flags_dirty();
        }
    }
    if (wmh->flags & InputHint) {
        client->neverfocus = !wmh->input;
    } else {
        client->neverfocus = false;
    }
    XFree(wmh);
}
Ejemplo n.º 2
0
// we use logo.xpm as the Application icon
void setIcon (void)
{
    int             rv;
    Pixmap          pixmap = 0;
    Pixmap          mask = 0;
    XpmAttributes   attrib;
    XWMHints       *h = XGetWMHints (dpy, aboutWindow);
    XWMHints        wm_hints;
    Bool            got_hints = h != 0;

    attrib.valuemask = 0;
    rv = XCreatePixmapFromData (dpy, aboutWindow, about_icon_xpm, &pixmap, &mask, &attrib);
    if (rv != XpmSuccess) {
	fprintf (stderr, "Failed to read xpm file: %s\n", XpmGetErrorString (rv));
	return;
    }

    if (!got_hints) {
	h = &wm_hints;
	h->flags = 0;
    }
    h->icon_pixmap = pixmap;
    h->icon_mask = mask;
    h->flags |= IconPixmapHint | IconMaskHint;
    XSetWMHints (dpy, aboutWindow, h);
    if (got_hints)
	XFree ((char *) h);
}
Ejemplo n.º 3
0
Window
wm_get_group_leader(Display *dpy, Window window)
{
	unsigned char *data;
	int status, real_format;
	Atom real_type;
	unsigned long items_read, items_left;
	Window leader = None;
	
	status = XGetWindowProperty(dpy, window, WM_CLIENT_LEADER,
	                  0, 1, False, XA_WINDOW, &real_type, &real_format,
	                  &items_read, &items_left, &data);
	
	if(status != Success)
	{
		XWMHints *hints = XGetWMHints(dpy, window);
		if(! hints)
			return None;
		
		if(hints->flags & WindowGroupHint)
			leader = hints->window_group;
		
		return leader;
	}
	
	if(items_read)
		leader = ((Window*)data)[0];
	
	XFree(data);
	
	return leader;
}
Ejemplo n.º 4
0
static void
urgent(void)
{
	/* This is from deryni/tuomov's urgent_test.c */
	Display *dpy;
	Window id;
	const char *ids;
	XWMHints *hints;

	ids = getenv("WINDOWID");
	if (ids == NULL)
		return;

	id = atoi(ids);

	dpy = XOpenDisplay(NULL);
	if (dpy == NULL)
		return;

	XSetErrorHandler(error_handler);
	hints = XGetWMHints(dpy, id);
	if (hints) {
		hints->flags|=XUrgencyHint;
		XSetWMHints(dpy, id, hints);
		XFree(hints);
	}
	XSetErrorHandler(NULL);

	XFlush(dpy);
	XCloseDisplay(dpy);
}
Ejemplo n.º 5
0
static void wxgtk_window_set_urgency_hint (GtkWindow *win,
                                           gboolean setting)
{
#if GTK_CHECK_VERSION(2,7,0)
    if (gtk_check_version(2,7,0) == NULL)
        gtk_window_set_urgency_hint(win, setting);
    else
#endif
    {
#ifdef GDK_WINDOWING_X11
        GdkWindow* window = gtk_widget_get_window(GTK_WIDGET(win));
        wxCHECK_RET(window, "wxgtk_window_set_urgency_hint: GdkWindow not realized");

        Display* dpy = GDK_WINDOW_XDISPLAY(window);
        Window xid = GDK_WINDOW_XID(window);
        XWMHints* wm_hints = XGetWMHints(dpy, xid);

        if (!wm_hints)
            wm_hints = XAllocWMHints();

        if (setting)
            wm_hints->flags |= XUrgencyHint;
        else
            wm_hints->flags &= ~XUrgencyHint;

        XSetWMHints(dpy, xid, wm_hints);
        XFree(wm_hints);
#endif // GDK_WINDOWING_X11
    }
}
Ejemplo n.º 6
0
void selectInput ( Window w, void* data )
{
	XWMHints* wmhints = XGetWMHints(dp, w);
	XWindowAttributes wattr;
	
	XGetWindowAttributes(dp, w, &wattr);
	
	XSelectInput ( dp, w, VisibilityChangeMask );
	
	DEBUG(10, "w is 0x%x\n", w);
	
	if ( wmhints != NULL && wmhints->initial_state == 1 && wattr.map_state == 2)
	{
		Window* wp = (Window*)malloc(sizeof(Window));
		*wp = w;
		
		XSelectInput ( dp, w, EnterWindowMask | LeaveWindowMask );
	
		DEBUG(4, "inserting window # 0x%x\n", *wp);
		
		slist_add ( &window_list, wp );
	}
	else if ( wattr.map_state == 2 )
	{
		XSelectInput ( dp, w, EnterWindowMask | LeaveWindowMask );
	
		DEBUG(4, "select isViewable window # 0x%x\n", w);		
	}

	XFree ( wmhints );
	
	return;
}
Ejemplo n.º 7
0
Archivo: events.c Proyecto: Limsik/e17
unsigned char
handle_key_press(event_t *ev)
{
    XWMHints *wm_hints;
#ifdef COUNT_X_EVENTS
    static unsigned long keypress_cnt = 0;
#endif

    PROF_INIT(handle_key_press);
    D_EVENTS(("handle_key_press(ev [%8p] on window 0x%08x)\n", ev, ev->xany.window));
#if UNUSED_BLOCK
    REQUIRE_RVAL(XEVENT_IS_MYWIN(ev, &primary_data), 0);
#endif

    COUNT_EVENT(keypress_cnt);
    if (!(BITFIELD_IS_SET(eterm_options, ETERM_OPTIONS_NO_INPUT))) {
        lookup_key(ev);
    }
    if (BITFIELD_IS_SET(vt_options, VT_OPTIONS_URG_ALERT)) {
        wm_hints = XGetWMHints(Xdisplay, TermWin.parent);
        wm_hints->flags &= ~XUrgencyHint;
        XSetWMHints(Xdisplay, TermWin.parent, wm_hints);
        XFree(wm_hints);
    }
    PROF_DONE(handle_key_press);
    PROF_TIME(handle_key_press);
    return 1;
}
Ejemplo n.º 8
0
Archivo: icons.c Proyecto: g7/fbpanel
static int task_has_icon(task *tk)
{
    XWMHints *hints;
    gulong *data;
    int n;

    ENTER;
    data = get_xaproperty(tk->win, a_NET_WM_ICON, XA_CARDINAL, &n);
    if (data)
    {
        XFree(data);
        RET(1);
    }
    
    hints = XGetWMHints(GDK_DISPLAY(), tk->win);
    if (hints)
    {
        if ((hints->flags & IconPixmapHint) || (hints->flags & IconMaskHint))
        {
            XFree (hints);
            RET(1);
        }
        XFree (hints);
    }
    RET(0);
}
Ejemplo n.º 9
0
Archivo: wmurgent.c Proyecto: z24/zwm
//------------------------------------------------------------------------------
int main(int argc,char *argv[])
{
    if (argc!=2)
    {
        fprintf(stderr,"Usage: %s WindowID\n",argv[0]);
        fprintf(stderr,"  WindowID: a hex number, e.x. 0x1\n");
        return 1;
    }

    Window wm;
    sscanf(argv[1],"%x",(unsigned int*)&wm);
    
    Display *dpy = XOpenDisplay(NULL);
    if (dpy==NULL)
        return 1;

    XWMHints *wmh = XGetWMHints(dpy,wm);
    if (wmh)
    {
        wmh->flags |= XUrgencyHint;
        XSetWMHints(dpy,wm,wmh);
        XFree(wmh);
    }

    XCloseDisplay(dpy);

    return 0;
}
Ejemplo n.º 10
0
static void scan_initial_windows(WRootWin *rootwin)
{
    Window dummy_root, dummy_parent, *wins=NULL;
    uint nwins=0, i, j;
    XWMHints *hints;
    
    XQueryTree(ioncore_g.dpy, WROOTWIN_ROOT(rootwin), &dummy_root, &dummy_parent,
               &wins, &nwins);
    
    for(i=0; i<nwins; i++){
        if(wins[i]==None)
            continue;
        hints=XGetWMHints(ioncore_g.dpy, wins[i]);
        if(hints!=NULL && hints->flags&IconWindowHint){
            for(j=0; j<nwins; j++){
                if(wins[j]==hints->icon_window){
                    wins[j]=None;
                    break;
                }
            }
        }
        if(hints!=NULL)
            XFree((void*)hints);
    }
    
    rootwin->tmpwins=wins;
    rootwin->tmpnwins=nwins;
}
Ejemplo n.º 11
0
void wsSetIcon(Display *dsp, Window win, guiIcon_t *icon)
{
    XWMHints *wm;
    Atom iconatom;
    CARD32 data[2];

    if (icon->normal) {
        wm = XGetWMHints(dsp, win);

        if (!wm)
            wm = XAllocWMHints();

        wm->icon_pixmap = icon->normal;
        wm->icon_mask   = icon->normal_mask;
        wm->flags      |= IconPixmapHint | IconMaskHint;

        XSetWMHints(dsp, win, wm);
        XFree(wm);
    }

    if (icon->small || icon->normal) {
        iconatom = XInternAtom(dsp, "KWM_WIN_ICON", False);
        data[0]  = (icon->small ? icon->small : icon->normal);
        data[1]  = (icon->small ? icon->small_mask : icon->normal_mask);

        XChangeProperty(dsp, win, iconatom, iconatom, 32, PropModeReplace, (unsigned char *)data, 2);
    }

    if (icon->collection) {
        iconatom = XInternAtom(dsp, "_NET_WM_ICON", False);
        XChangeProperty(dsp, win, iconatom, XA_CARDINAL, 32, PropModeReplace, (unsigned char *)icon->collection, icon->collection_size);
    }
}
Ejemplo n.º 12
0
int plugin_hide(int ph)
{
	int i;
	XWMHints *hints;
	Display *display = XtDisplay(topLevel);
	Screen *screen = XtScreen(topLevel);
	Window w = plugin[ph].victim;

	XSync(display, False);
	XWithdrawWindow(display, w, XScreenNumberOfScreen(screen));
        XSync(display, False);
        hints = XGetWMHints(display, w);
        hints->flags |= WindowGroupHint;
        hints->window_group = RootWindowOfScreen(screen);
        XSetWMHints(display, w, hints);
#if 1	/* testing */
	for (i = 0; i < REPARENT_LOOPS; i++) {
		Window root, parent, *child;
		Cardinal n;
		XQueryTree(display, w, &root, &parent, &child, &n);
		XReparentWindow(display, w, root, 0, 0);
		XSync(display, False);
	}
#endif
	if (plugin[ph].core != None) {
		XtDestroyWidget(plugin[ph].core);
		plugin[ph].core = None;
	}
	return 0;
}
Ejemplo n.º 13
0
void window_manage(Window win)
{
	XWindowAttributes attrib;
	gboolean no_manage = FALSE;
	Window icon_win = None;
	grab_server(TRUE);
	if(xqueue_exists_local(check_unmap, &win)) {
		wm_debug("Trying to manage unmapped window. Aborting that.");
		no_manage = TRUE;
	} else if(!XGetWindowAttributes(t_display, win, &attrib))
		no_manage = TRUE;
	else {
		XWMHints *wmhints;
		if((wmhints = XGetWMHints(t_display, win))) {
			if((wmhints->flags & StateHint) && wmhints->initial_state == WithdrawnState) {
				if(wmhints->flags & IconWindowHint)
					icon_win = wmhints->icon_window;
			}
			XFree(wmhints);
		}
	}
	if(!no_manage) {
		if(attrib.override_redirect) {
			wm_debug("not managing override redirect window 0x%x", win);
			grab_server(FALSE);
		} else
			client_manage(win);
	} else {
		grab_server(FALSE);
		wm_debug("FAILED to manage window 0x%x", win);
	}
}
Ejemplo n.º 14
0
bool X11Support::getWindowUrgency(unsigned long window)
{
	XWMHints* hints = XGetWMHints(QX11Info::display(), window);
	if(hints == NULL)
		return false;
	bool isUrgent = (hints->flags & 256) != 0; // UrgencyHint
	XFree(hints);
	return isUrgent;
}
Ejemplo n.º 15
0
/* really returns XWMHints*, but to avoid requiring extra includes, we'll return void* */
void         *
count_xgetwmhints (const char *fname, int line, Display * display, Window w)
{
	XWMHints     *val;

	val = XGetWMHints (display, w);
	if (val != NULL)
		count_alloc (fname, line, (void *)val, sizeof (XWMHints), C_XMEM | C_XGETWMHINTS);
	return (void *)val;
}
Ejemplo n.º 16
0
void CaptureAllWindows(void)
{
  int i, j;
  unsigned int nchildren;
  Window root, parent, *children;

  PPosOverride = TRUE;

  if (!XQueryTree(dpy, Scr.Root, &root, &parent, &children, &nchildren))
    return;

  /*
   * weed out icon windows
   */
  for (i = 0; i < nchildren; i++) {
    if (children[i]) {
      XWMHints *wmhintsp = XGetWMHints(dpy, children[i]);
      if (wmhintsp) {
	if (wmhintsp->flags & IconWindowHint) {
	  for (j = 0; j < nchildren; j++) {
	    if (children[j] == wmhintsp->icon_window) {
	      children[j] = None;
	      break;
	    }
	  }
	}
	XFree((char *) wmhintsp);
      }
    }
  }

  /*
   * map all of the non-override windows
   */

  for (i = 0; i < nchildren; i++) {
    if (children[i] && MappedNotOverride(children[i])) {
      XUnmapWindow(dpy, children[i]);
      Event.xmaprequest.window = children[i];
      HandleMapRequestKeepRaised(BlackoutWin);
    }
  }

  isIconicState = DontCareState;

  if (nchildren > 0)
    XFree((char *) children);

  /* after the windows already on the screen are in place,
   * don't use PPosition */
  PPosOverride = FALSE;
  Scr.flags |= WindowsCaptured;
  KeepOnTop();

}
Ejemplo n.º 17
0
void UpdateWMHints(UltimateContext *uc)
{
  if(uc->WMHints) XFree(uc->WMHints);
  uc->WMHints = XGetWMHints(disp,uc->win);
  if((uc == ActiveWin) && ((!uc->WMHints)
     ||(uc->WMHints && (uc->WMHints->flags & InputHint) && uc->WMHints->input)))
  {
    XSetInputFocus(disp, ActiveWin->win, RevertToPointerRoot, TimeStamp);
  }
  UpdateWinGroup(uc);
}
Ejemplo n.º 18
0
KPagerMainWindow::KPagerMainWindow(QWidget *parent, const char *name)
	: DCOPObject("KPagerIface"), KMainWindow(parent, name)
{
    m_reallyClose=false;

    m_pPager = new KPager(this, 0);
    setCentralWidget(m_pPager);

    KConfig *cfg = kapp->config();
    cfg->setGroup("KPager");

    // Update the last used geometry
    int w = cfg->readNumEntry(m_pPager->lWidth(),-1);
    int h = cfg->readNumEntry(m_pPager->lHeight(),-1);
    if (w > 0 && h > 0)
        resize(w,h);
    else
        resize(m_pPager->sizeHint());
    //  resize(cfg->readNumEntry(lWidth(),200),cfg->readNumEntry(lHeight(),90));

    int xpos=cfg->readNumEntry("xPos",-1);
    int ypos=cfg->readNumEntry("yPos",-1);
    if (xpos > 0 && ypos > 0)
      move(xpos,ypos);
    else
    {
//      NETRootInfo ri( qt_xdisplay(), NET::WorkArea );
//      NETRect rect=ri.workArea(1);
//      move(rect.pos.x+rect.size.width-m_pPager->width(),
//	  rect.pos.y+rect.size.height-m_pPager->height());
// antonio:The above lines don't work. I should look at them when I have
// more time
        move(kapp->desktop()->width()-m_pPager->sizeHint().width()-5,kapp->desktop()->height()-m_pPager->sizeHint().height()-25);
    }

    // Set the wm flags to this window
    KWin::setState( winId(), NET::StaysOnTop | NET::SkipTaskbar | NET::Sticky | NET::SkipPager );
    KWin::setOnAllDesktops( winId(), true);
    if ( KWin::windowInfo( winId(), NET::WMWindowType, 0 ).windowType(NET::Normal) == NET::Normal )
    {
       KWin::setType( winId(), NET::Utility );
    }

    XWMHints *hints = XGetWMHints(x11Display(), winId());
    if( hints == NULL )
        hints = XAllocWMHints();
    hints->input = false;
    hints->flags |= InputHint;
    XSetWMHints(x11Display(), winId(), hints);
    XFree(reinterpret_cast<char *>(hints));

    timeout=new QTimer(this,"timeoutToQuit");
    connect(timeout,SIGNAL(timeout()),this, SLOT(reallyClose()));
}
Ejemplo n.º 19
0
void window_manage(Window win)
{
    XWindowAttributes attrib;
    gboolean no_manage = FALSE;
    gboolean is_dockapp = FALSE;
    Window icon_win = None;

    grab_server(TRUE);

    /* check if it has already been unmapped by the time we started
       mapping. the grab does a sync so we don't have to here */
    if (xqueue_exists_local(check_unmap, &win)) {
        ob_debug("Trying to manage unmapped window. Aborting that.");
        no_manage = TRUE;
    }
    else if (!XGetWindowAttributes(obt_display, win, &attrib))
        no_manage = TRUE;
    else {
        XWMHints *wmhints;

        /* is the window a docking app */
        is_dockapp = FALSE;
        if ((wmhints = XGetWMHints(obt_display, win))) {
            if ((wmhints->flags & StateHint) &&
                wmhints->initial_state == WithdrawnState)
            {
                if (wmhints->flags & IconWindowHint)
                    icon_win = wmhints->icon_window;
                is_dockapp = TRUE;
            }
            XFree(wmhints);
        }
    }

    if (!no_manage) {
        if (attrib.override_redirect) {
            ob_debug("not managing override redirect window 0x%x", win);
            grab_server(FALSE);
        }
        else if (is_dockapp) {
            if (!icon_win)
                icon_win = win;
            dock_manage(icon_win, win);
        }
        else
            client_manage(win, NULL);
    }
    else {
        grab_server(FALSE);
        ob_debug("FAILED to manage window 0x%x", win);
    }
}
Ejemplo n.º 20
0
static int mud_urgent( lua_State* L )
{
	PRETEND_TO_USE( L );

	if( !UI.hasFocus ) {
		XWMHints* hints = XGetWMHints( UI.display, UI.window );
		hints->flags |= XUrgencyHint;
		XSetWMHints( UI.display, UI.window, hints );
		XFree( hints );
	}

	return 0;
}
Ejemplo n.º 21
0
	TrayIconPrivate( TrayIcon *object, const QPixmap &pm, bool _isWMDock )
	: QLabel( 0, "psidock", WMouseNoMask ), iconObject(object)
	{
		isWMDock = _isWMDock;

		// WindowMaker
		if(isWMDock) {
			QPixmap pix = pm;
			setPixmap(pix);
			resize(64,64);
			update();

			Display *dsp = x11Display();  // get the display
			WId win = winId();     // get the window
			XWMHints *hints;  // hints
			/*XClassHint classhint;  // class hints
			classhint.res_name = "psidock";  // res_name
			classhint.res_class = "Wharf";  // res_class
			XSetClassHint(dsp, win, &classhint); // set the class hints*/
			hints = XGetWMHints(dsp, win);  // init hints
			hints->initial_state = WithdrawnState;
			hints->icon_x = 0;
			hints->icon_y = 0;
			hints->icon_window = winId(); //wharfIcon->winId();
			hints->window_group = win;  // set the window hint
			hints->flags = WindowGroupHint | IconWindowHint | IconPositionHint | StateHint; // set the window group hint
			XSetWMHints(dsp, win, hints);  // set the window hints for WM to use.
			XFree( hints );
		}
		// KDE/GNOME
		else {
			setWFlags(WRepaintNoErase);

			QPixmap pix = pm; //buildIcon(pm);
			setPixmap(pix);
			resize(22,22);
			update();

			//setMask(*pix.mask());

			// dock the widget (adapted from Gabber / gdk)
			Display *dsp = x11Display(); // get the display
			WId win = winId();           // get the window
			int r;
			int data = 1;
			r = XInternAtom(dsp, "KWM_DOCKWINDOW", false);
			XChangeProperty(dsp, win, r, r, 32, 0, (uchar *)&data, 1);
			r = XInternAtom(dsp, "_KDE_NET_WM_SYSTEM_TRAY_WINDOW_FOR", false);
			XChangeProperty(dsp, win, r, XA_WINDOW, 32, 0, (uchar *)&data, 1);
		}
	}
Ejemplo n.º 22
0
void map_client(client_t *c)
{
    XWindowAttributes attr;
    strut_t s = { 0, 0, 0, 0 };
    XWMHints *hints;
    int btn, want_raise = 1;

    XGrabServer(dpy);

    XGetWindowAttributes(dpy, c->win, &attr);
    collect_struts(c, &s);

    if (attr.map_state == IsViewable) {
        c->ignore_unmap++;
        reparent(c, &s);
        if (get_wm_state(c->win) == IconicState) {
            c->ignore_unmap++;
            XUnmapWindow(dpy, c->win);
        } else {
            set_wm_state(c, NormalState);
            do_map(c, want_raise);
        }
    } else {
        if ((hints = XGetWMHints(dpy, c->win))) {
            if (hints->flags & StateHint)
                set_wm_state(c, hints->initial_state);
            XFree(hints);
        } else {
            set_wm_state(c, NormalState);
        }
        if (!init_geom(c, &s) && opt_imap) {
            btn = sweep(c, map_curs, recalc_map, SWEEP_DOWN, &s);
            if (btn == Button2)
                btn = sweep(c, resize_curs, recalc_resize, SWEEP_UP, &s);
            if (btn == Button3)
                want_raise = 0;
        }
#ifdef DEBUG
        dump_geom(c, "set to");
        dump_info(c);
#endif
        reparent(c, &s);
        if (get_wm_state(c->win) == NormalState)
            do_map(c, want_raise);
    }

    XSync(dpy, False);
    c->name = get_wm_name(c->win); // horrible kludge
    XUngrabServer(dpy);
}
Ejemplo n.º 23
0
Archivo: event.c Proyecto: n4cht/kwm
/** PropertyNotify handle event
 * \param ev XPropertyEvent pointer
*/
static void
propertynotify(XPropertyEvent *ev)
{
     Client *c;
     Systray *s;
     Window trans;
     XWMHints *h;

     if(ev->state == PropertyDelete)
          return;

     if((s = systray_find(ev->window)))
     {
          systray_state(s);
          systray_update();
     }

     if((c = client_gb_win(ev->window)))
     {
          switch(ev->atom)
          {
          case XA_WM_TRANSIENT_FOR:
               XGetTransientForHint(dpy, c->win, &trans);
               if((c->flags & TileFlag || c->flags & MaxFlag))
                    if(((c->flags & HintFlag && (client_gb_win(trans) != NULL)))
                              || (!(c->flags & HintFlag && (client_gb_win(trans) != NULL))))
                         arrange(c->screen, True);
               break;
          case XA_WM_NORMAL_HINTS:
               client_size_hints(c);
               break;
          case XA_WM_HINTS:
               if((h = XGetWMHints(dpy, c->win)) && (h->flags & XUrgencyHint) && c != sel)
               {
                    client_urgent(c, True);
                    XFree(h);
               }
               break;
          case XA_WM_NAME:
               client_get_name(c);
               break;
          default:
               if(ev->atom == net_atom[net_wm_name])
                    client_get_name(c);
               break;
          }
     }

     return;
}
Ejemplo n.º 24
0
void Frame::get_wm_hints()
{
    XWMHints *xwmhints;

    if ((xwmhints = XGetWMHints(QX11Info::display(), c_win)) != NULL)
    {
        if (xwmhints->flags & StateHint && xwmhints->initial_state == IconicState)
        {
            set_state(3);
            state = "IconicState";
        }
        XFree(xwmhints);
    }
}
Ejemplo n.º 25
0
static void
seturgency(Display *dpy, Window winid, Bool set) {
	XWMHints *hints = XGetWMHints(dpy, winid);
	if(!hints) {
		fputs("seturgent: unable to get window manager hints.\n", stderr);
		return;
	}
	if(set)
		hints->flags |= XUrgencyHint;
	else
		hints->flags &= ~XUrgencyHint;
	if(!XSetWMHints(dpy, winid, hints))
		fputs("seturgent: unable to set urgency hint.\n", stderr);
	XFree(hints);
}
Ejemplo n.º 26
0
/*
 * Check the _MB_CURRENT_APP_WINDOW on the root window, and update
 * the top_most status accordingly
 */
static void
hildon_program_update_top_most                  (HildonProgram *program)
{
    XWMHints *wm_hints;
    Window active_window;
    HildonProgramPrivate *priv;

    priv = HILDON_PROGRAM_GET_PRIVATE (program);
    g_assert (priv);
    
    active_window = hildon_window_get_active_window();

    if (active_window)
    {
      gint xerror;
      
      gdk_error_trap_push ();
      wm_hints = XGetWMHints (GDK_DISPLAY (), active_window);
      xerror = gdk_error_trap_pop ();
      if (xerror)
        return;

      if (wm_hints)
      {

          if (wm_hints->window_group == priv->window_group)
          {
              if (!priv->is_topmost)
              {
                  priv->is_topmost = TRUE;
                  g_object_notify (G_OBJECT (program), "is-topmost");
              }
          }
          else if (priv->is_topmost)
          {
            priv->is_topmost = FALSE;
            g_object_notify (G_OBJECT (program), "is-topmost");
          }
      }
      XFree (wm_hints);
    }

    /* Check each window if it was is_topmost */
    g_slist_foreach (priv->windows, 
            (GFunc)hildon_program_window_list_is_is_topmost, &active_window);
}
Ejemplo n.º 27
0
static void
event_propertynotify(XEvent *e)
{
     XPropertyEvent *ev = &e->xproperty;
     XWMHints *h;
     struct client *c;
     struct _systray *s;

     if(ev->state == PropertyDelete)
          return;

     if((c = client_gb_win(ev->window)))
     {
          switch(ev->atom)
          {
               case XA_WM_TRANSIENT_FOR:
                    break;

               case XA_WM_NORMAL_HINTS:
                    client_get_sizeh(c);
                    break;

               case XA_WM_HINTS:
                    if((h = XGetWMHints(EVDPY(e), c->win))
                       && (h->flags & XUrgencyHint)
                       && c->tag != W->screen->seltag)
                    {
                         c->tag->flags |= TAG_URGENT;
                         infobar_elem_screen_update(c->screen, ElemTag);
                         XFree(h);
                    }

                    break;

               default:
                    if(ev->atom == XA_WM_NAME || ev->atom == W->net_atom[net_wm_name])
                         client_get_name(c);
                    break;
          }
     }
     else if((s = systray_find(ev->window)))
     {
          systray_state(s);
          systray_update();
     }
}
Ejemplo n.º 28
0
/**
@brief   Updates the frame with available wm hints (ICCCM icon, window "group", focus wanted, urgency, withdrawn)
@return  void
**/
void
get_frame_wm_hints(Display *display, struct Frame *frame) {
  XWMHints *wm_hints = XGetWMHints(display, frame->framed_window);
  //WM_ICON_SIZE  in theory we can ask for set of specific icon sizes.

  //Set defaults
  Pixmap icon_p = 0;
  Pixmap icon_mask_p = 0;

  if(wm_hints != NULL) {
    if(wm_hints->flags & IconPixmapHint) {
      icon_p = wm_hints->icon_pixmap;
      //XSetWindowBackgroundPixmap(display, frame->menu_item.icon.item_icon, icon_p);
    }

    if(wm_hints->flags & IconMaskHint) {
      icon_mask_p = wm_hints->icon_mask;
      //icon_mask_p = wm_hints->icon_mask;
      //XShapeCombineMask (display, icon_p, ShapeBounding //ShapeClip or ShapeBounding
      //,0, 0, icon_mask_p, ShapeSet);
      //Shapeset or ShapeUnion, ShapeIntersect, ShapeSubtract, ShapeInvert
      //XMapWindow(display, frame->menu_item.icon.item_icon);

    }
    /* This method of creating the icon is not good, a higher quality method is available in EWMH
    if(icon_p && icon_mask_p ) {
      for(int i = 0; i <= inactive; i++) {
        create_icon_background(display, frame->widgets[title_menu_lhs].state[i]
        , icon_p, icon_mask_p
        , themes->window_type[frame->theme_type][title_menu_lhs].state_p[i]
        , themes->window_type[frame->theme_type][title_menu_lhs].w, themes->window_type[frame->theme_type][title_menu_lhs].h);
        XMapWindow(display, frame->widgets[title_menu_lhs].state[i]);
      }

    }
    XSync(display, False);
    */
    //get the icon sizes
    //find out it is urgent
    //get the icon if it has one.
    //icon window is for the systray
    //window group is for mass minimization
    XFree(wm_hints);
  }
}
Ejemplo n.º 29
0
void Client::getWMHints()
{
	XWMHints *xwmhints;
	if ((xwmhints = XGetWMHints(display(), clientId)) != NULL) {
		if (xwmhints->flags & StateHint && xwmhints->initial_state == IconicState) {
			setClientState(IconicState);
		}
		if (xwmhints->flags & IconPixmapHint) {
			getServerIcon(xwmhints->icon_pixmap, (xwmhints->flags & IconMaskHint)?(xwmhints->icon_mask):(None));
		}
		if (appIcon.isNull())
			appIcon = QPixmap(":/default/appicon.png");
		// FIXME: UrgencyHint not defined
		//Urgency = xwmhints->flags & UrgencyHint;
		wantFocus = xwmhints->input;
		XFree(xwmhints);
    }
}
Ejemplo n.º 30
0
void KWM::setIcon(Window w, const QPixmap &pm){
  XWMHints *hints = XGetWMHints(qt_xdisplay(), w);
  if (!hints)
    hints = XAllocWMHints();
  QPixmap *p = new QPixmap;
  *p = pm;
  hints->icon_pixmap=p->handle();
  hints->flags |= IconPixmapHint;
  if(p->mask()){
    hints->icon_mask = p->mask()->handle();
    hints->flags |= IconMaskHint;
  }
  else
    hints->flags &= ~IconMaskHint;
  XSetWMHints( qt_xdisplay(), w, hints );
  XFree((char*)hints);
  delete p;
}