Beispiel #1
1
static int print_anyway(int ph, FILE *fp)
{
	Widget ow;
	unsigned int width = plugin[ph].width;
	unsigned int height = plugin[ph].height;
	int i;

	ow = XtVaCreatePopupShell("plugin_print",
		overrideShellWidgetClass, topLevel,
		XtNx, 0, XtNy, 0,
		XtNwidth, width, XtNheight, height,
		(char *)0);
	XtPopup(ow, XtGrabNone);
	XSync(XtDisplay(ow), False);
	for (i = 0; i < 1 /*REPARENT_LOOPS*/; i++) {
		XReparentWindow(XtDisplay(topLevel), plugin[ph].victim,
			XtWindow(ow), 0, 0);
		XSync(XtDisplay(topLevel), False);
		XClearWindow(XtDisplay(topLevel), plugin[ph].victim);
		XSync(XtDisplay(topLevel), False);
	}

	/* print */
	prnt(plugin[ph].victim /*pixmap*/, fp);

	/* finished printing */

	for (i = 0; i < 1 /*REPARENT_LOOPS*/; i++) {
		XReparentWindow(XtDisplay(topLevel), plugin[ph].victim,
			XtWindow(plugin[ph].core), 2, 2);
		XSync(XtDisplay(topLevel), False);
	}
	XtDestroyWidget(ow);
	return 0;
}
static void
mb_wm_client_menu_realize (MBWindowManagerClient *client)
{
  MBWindowManagerClientClass  *parent_klass = NULL;
  int our_type = MB_WM_TYPE_CLIENT_MENU;

  parent_klass = MB_WM_CLIENT_CLASS (MB_WM_OBJECT_GET_CLASS(client));
  /* Look back down class hierarchy until we find ourself, then
   * find our parent's realize. There must be a better way??? */
  while (MB_WM_OBJECT_CLASS(parent_klass)->type != our_type)
    parent_klass = MB_WM_CLIENT_CLASS(MB_WM_OBJECT_CLASS(parent_klass)->parent);
  parent_klass = MB_WM_CLIENT_CLASS(MB_WM_OBJECT_CLASS(parent_klass)->parent);

  if (parent_klass->realize)
    parent_klass->realize (client);

  /*
   * Must reparent the window to our root, otherwise we restacking of
   * pre-existing windows might fail.
   */
  if (client->xwin_frame)
    XReparentWindow(client->wmref->xdpy, client->xwin_frame,
                    client->wmref->root_win->xwindow, 0, 0);
  else
    XReparentWindow(client->wmref->xdpy, MB_WM_CLIENT_XWIN(client),
                    client->wmref->root_win->xwindow, 0, 0);
}
Beispiel #3
0
Datei: ewmh.c Projekt: n4cht/kwm
/** Manage _NET_WM_STATE_* ewmh
 */
void
ewmh_manage_net_wm_state(long data_l[], Client *c)
{
     /* Manage _NET_WM_STATE_FULLSCREEN */
     if(data_l[1] == (long)net_atom[net_wm_state_fullscreen])
     {
          if(data_l[0] == _NET_WM_STATE_ADD && !(c->flags & FSSFlag))
          {
               c->screen = screen_get_with_geo(c->geo.x, c->geo.y);
               c->flags &= ~UnmapFlag;
               XMapWindow(dpy, c->win);
               XReparentWindow(dpy, c->win, ROOT, spgeo[c->screen].x, spgeo[c->screen].y);
               XResizeWindow(dpy, c->win,
                             spgeo[c->screen].width,
                             spgeo[c->screen].height);
               XChangeProperty(dpy, c->win, net_atom[net_wm_state], XA_ATOM, 32,
                               PropModeReplace, (uchar *)&net_atom[net_wm_state_fullscreen], 1);

               c->tmp_geo = c->geo;

               if(c->flags & FreeFlag)
                    c->ogeo = c->geo;

               c->flags |= (FSSFlag | MaxFlag);

               client_raise(c);
               client_focus(c);
               XUnmapWindow(dpy, c->frame);
          }
          else if(data_l[0] == _NET_WM_STATE_REMOVE && (c->flags & FSSFlag))
          {
               XChangeProperty(dpy, c->win, net_atom[net_wm_state], XA_ATOM, 32, PropModeReplace, (uchar *)0, 0);
               c->flags &= ~(FSSFlag | MaxFlag);
               client_map(c);
               XReparentWindow(dpy, c->win, c->frame, BORDH, TBARH);
               client_moveresize(c, c->tmp_geo, False);
          }
     }
     /* Manage _NET_WM_STATE_STICKY */
     else if(data_l[1] == (long)net_atom[net_wm_state_sticky])
     {
          /* == client_ignore_tag */
          c->tag = MAXTAG + 1;
          arrange(c->screen, True);
     }
     /* Manage _NET_WM_STATE_DEMANDS_ATTENTION */
     else if(data_l[1] == (long)net_atom[net_wm_state_demands_attention])
     {
          if(data_l[0] == _NET_WM_STATE_ADD)
               client_urgent(c, True);
          if(data_l[0] == _NET_WM_STATE_REMOVE)
               if(c == sel)
                    client_focus(NULL);
     }

     return;
}
Beispiel #4
0
void flushclients()
{
  unsigned int i, nwins;
  Window dw1, dw2, *wins;
  Client *c;
#ifdef ASSIMILATE_WINDOWS
  Scrn *scr2;
#endif

  if((scr = front)) do {
    scr = scr->upfront;
    XQueryTree(dpy, scr->back, &dw1, &dw2, &wins, &nwins);
    for(i=0; i<nwins; i++)
      if((!XFindContext(dpy, wins[i], client_context, (XPointer *)&c))&&wins[i]==c->parent) {
	int x,y;
	grav_map_frame_to_win(c, c->x, c->y, &x, &y);
	XReparentWindow(dpy, c->window, scr->root, x, y);
	XSetWindowBorderWidth(dpy, c->window, c->old_bw);
	XRemoveFromSaveSet(dpy, c->window);
	wins[i]=c->window;
	rmclient(c);
      }
#ifdef ASSIMILATE_WINDOWS
      else if((!XFindContext(dpy, wins[i], screen_context, (XPointer *)&scr2)) && scr2==scr) {
	XWindowAttributes attr;
	XSetWindowAttributes xsa;
	XGetWindowAttributes(dpy, wins[i], &attr);
	XReparentWindow(dpy, wins[i], scr->root, attr.x, attr.y);
	xsa.override_redirect = True;
	XChangeWindowAttributes(dpy, wins[i], CWOverrideRedirect, &xsa);
	XDeleteContext(dpy, wins[i], screen_context);
	XRemoveFromSaveSet(dpy, wins[i]);
      }
#endif
    /*
      if(nwins) {
      for(i=0; i<(nwins>>1); i++) {
      Window w=wins[i];
      wins[i]=wins[nwins-1-i];
      wins[nwins-1-i]=w;
      }
      XRestackWindows(dpy, wins, nwins);
      }
      */
    XFree((void *) wins);
  } while(scr!=front);
  while((c=clients)) {
    if(c->parent != c->scr->root) {
      int x,y;
      grav_map_frame_to_win(c, c->x, c->y, &x, &y);
      XReparentWindow(dpy, c->window, c->scr->root, x, y);
      XSetWindowBorderWidth(dpy, c->window, c->old_bw);
      XRemoveFromSaveSet(dpy, c->window);
    }
    rmclient(c);
  }
}
Beispiel #5
0
void neo_draw_window_reparent(NeoDrawWindow *win, NeoDrawWindow *parent)
{
  if(!win)
    return;

  if(!parent)
    XReparentWindow(win->handle->display,win->id, win->handle->screen.root, 0,0);
  else
    XReparentWindow(win->handle->display, win->id, parent->id, 0,0);

}
Beispiel #6
0
void
handle_reparent(XEvent * evt)
{
	XReparentEvent * xre = &(evt->xreparent);

	/* news about a child window, maybe:
	   it's our own window; (fine)
	   it's the first free xterm; (fine)
	   it's the wm giving it up; (we'll take it)
	   it's sawfish hesitating giving it up (we ask again)
	   it's we giving out a child
	*/
#ifdef WRESTLE_FOR_CHILD
	fprintf(stderr, "Reparent: e%08x w%08x p%08x\n",
		xre->event, xre->window, xre->parent);
	fprintf(stderr, "\tWe are: %08x\n", gdi.mainw);
#endif/*WRESTLE_FOR_CHILD*/

	if (xre->parent != gdi.mainw && is_tabbed_window(xre->window)) /* WM wants it back. No. */
	{
#ifdef WRESTLE_FOR_CHILD
		fprintf(stderr, "WM wants child back. No way.\n");
#endif/*WRESTLE_FOR_CHILD*/
		XReparentWindow(gdi.display, xre->window, gdi.mainw, 0, 0);
		return;
	}
	if (!is_expected_child(xre->window))	/* "don't care" category */
	    return;

	/* so we do expect this child, whose was it? */
	Window parent = get_parent(xre->window);
	if (parent == gdi.mainw) {
#ifdef WRESTLE_FOR_CHILD
		fprintf(stderr, "\tit's our child\n");
#endif/*WRESTLE_FOR_CHILD*/

		received_child(xre->window);
		XMoveResizeWindow(gdi.display, xre->window,
				  0, tab_options.tabs_on_top?the_bar.height:0,
				  gdi.width, gdi.height - the_bar.height);
//		match_size_hints(xre->window, the_bar.height);
		new_tab(xre->window);
	}
	else {
		/* One has to ask twice to take a child from sawfish.
		   So we do that.
		*/
#ifdef WRESTLE_FOR_CHILD
		fprintf(stderr, "\tit's NOT our child, i'll ask again\n");
#endif/*WRESTLE_FOR_CHILD*/
		XReparentWindow(gdi.display, xre->window, gdi.mainw, 0, 0);
	}
	return;
}
Beispiel #7
0
// We assume that toReparent has had its X window set
// appropriately.
bool wxReparenter::Reparent(wxWindow* newParent, wxAdoptedWindow* toReparent)
{
    XWindowAttributes xwa;
    Window *children;
    unsigned int numchildren, each;
    Window returnroot, returnparent;
    XErrorHandler old;
    int parentOffset = 0;

    old = XSetErrorHandler(ErrorHandler);
    XReparentWindow( wxGlobalDisplay(),
                     (Window) toReparent->GetMainWindow(),
                     (Window) newParent->GetMainWindow(),
                     0, 0);

    if (!XQueryTree( wxGlobalDisplay(),
                     (Window) toReparent->GetMainWindow(),
                     &returnroot, &returnparent,
                     &children, &numchildren) || Xerror)
    {
        XSetErrorHandler(old);
        return TRUE;
    }

    if (numchildren > 0)
    {
        // TEST: see if we can get away with reparenting just
        // first one
        if (numchildren > 1)
        {
            wxLogDebug(wxT("Found %d, but only reparenting 1 child."), numchildren);
            numchildren = 1;
        }
        wxLogDebug(wxT("Reparenting %d children."), numchildren);
        /* Stacking order is preserved since XQueryTree returns its children in
           bottommost to topmost order
         */
        for (each=0; each<numchildren; each++)
        {
            XGetWindowAttributes( wxGlobalDisplay(),
                                  children[each], &xwa);
            fprintf(stderr,
              "Reparenting child at offset %d and position %d, %d.\n",
               parentOffset, parentOffset+xwa.x, parentOffset+xwa.y);
            XReparentWindow( wxGlobalDisplay(),
                             children[each], (Window) newParent->GetMainWindow(),
                             xwa.x, xwa.y);
        }
    }

    XSetErrorHandler(old);
    return TRUE;
}
Beispiel #8
0
SubTray *
subTrayNew(Window win)
{
  SubTray *t = NULL;

  assert(win);

  /* Create new tray */
  t = TRAY(subSharedMemoryAlloc(1, sizeof(SubTray)));
  t->flags = SUB_TYPE_TRAY;
  t->win   = win;
  t->width = subtle->ph; ///< Default width

  /* Update tray properties */
  subSharedPropertyName(subtle->dpy, win, &t->name, PKG_NAME);
  subEwmhSetWMState(t->win, WithdrawnState);
  XSelectInput(subtle->dpy, t->win, TRAYMASK);
  XReparentWindow(subtle->dpy, t->win, subtle->windows.tray, 0, 0);
  XAddToSaveSet(subtle->dpy, t->win);
  XSaveContext(subtle->dpy, t->win, TRAYID, (void *)t);

  /* Start embedding life cycle */
  subEwmhMessage(t->win, SUB_EWMH_XEMBED, 0xFFFFFF, CurrentTime,
    XEMBED_EMBEDDED_NOTIFY, 0, subtle->windows.tray, 0);

  subSharedLogDebugSubtle("new=tray, name=%s, win=%#lx\n", t->name, win);

  return t;
} /* }}} */
Beispiel #9
0
void ReparentWin(UltimateContext *uc, Window parent, int x, int y)
{
  UpdateUWMContext(uc);
  if(uc->Attributes.map_state != IsUnmapped) uc->expected_unmap_events++;
                                /* prevent unmapping of already mapped window */
  XReparentWindow(disp, uc->win, parent, x, y); /* perform action */
}
Beispiel #10
0
Bool container_client_add(container_t *container, client_t *client) {
  XWindowAttributes attr;
  int ret;
  container_t *tmp = NULL;

  ret = XFindContext(container->wm->dpy, client->window, container_context,
                     (XPointer*)&tmp);
  if (ret != XCNOENT) {
    wm_log(container->wm, LOG_INFO, "%s: ignoring attempt to add container as a client: %d", __func__, client->window);
    return False;
  }

  /* Ignore the add if this window already belongs to a container */
  ret = XFindContext(container->wm->dpy, client->window, client_container_context,
                     (XPointer*)&tmp);
  if (ret != XCNOENT) {
    wm_log(container->wm, LOG_INFO, "%s: window %d already in a container, ignoring mapnotify", __func__, client->window);
    return False;
  }

  wm_log(container->wm, LOG_INFO, "%s: client add window %d", __func__, client->window);
  XAddToSaveSet(container->wm->dpy, client->window);
  XGetWindowAttributes(container->wm->dpy, container->frame, &attr);
  XSetWindowBorderWidth(container->wm->dpy, client->window, 0);
  XSelectInput(container->wm->dpy, client->window, CLIENT_EVENT_MASK);
  XReparentWindow(container->wm->dpy, client->window, container->frame, 0, TITLE_HEIGHT);
  XResizeWindow(container->wm->dpy, client->window, attr.width, attr.height - TITLE_HEIGHT);
  XSaveContext(container->wm->dpy, client->window, client_container_context, (XPointer)container);

  //container_paint(container);
  container_client_show(container, client);
  return True;
}
Beispiel #11
0
Datei: dock.c Projekt: Cougar/pwm
static void do_remove_dockwin(WDock *dock, WClientWin *dw, bool subdest)
{
	WClientWin *p;
	int num=0;
	int x, y;
	
	p=first_clientwin((WThing*)dock);
	while(p!=NULL){
		if(p==dw)
			break;
		num++;
		p=next_clientwin(p);
	}
	
	if(p==NULL)
		return;

	x=dock->x;
	y=dock->y;
	
	XSelectInput(wglobal.dpy, dw->client_win,
				 dw->event_mask&~StructureNotifyMask);
	XReparentWindow(wglobal.dpy, dw->client_win, SCREEN->root, x, y);
	XSelectInput(wglobal.dpy, dw->client_win, dw->event_mask);
	
	unlink_thing((WThing*)dw);
	
	dock->dockwin_count--;

	if(dock->dockwin_count==0 || subdest)
		return;
	
	shrink_dock(dock);
}
Beispiel #12
0
void DockContainer::embed( WId id )
{
    if( id == _embeddedWinId || id == 0)
        return;
    QRect geom = KWin::windowInfo(id,NET::WMKDEFrameStrut).frameGeometry();

    // does the same as KWM::prepareForSwallowing()
    XWithdrawWindow( qt_xdisplay(), id, qt_xscreen() );
    while( KWin::windowInfo(id, NET::XAWMState).mappingState() != NET::Withdrawn );

    XReparentWindow( qt_xdisplay(), id, winId(), 0, 0 );

    // resize if window is bigger than frame
    if( (geom.width() > width()) ||
        (geom.height() > height()) )
        XResizeWindow( qt_xdisplay(), id, width(), height() );
    else
        XMoveWindow(qt_xdisplay(), id,
                    (sz() -  geom.width())/2 - border(),
                    (sz() - geom.height())/2 - border());
    XMapWindow( qt_xdisplay(), id );
    XUngrabButton( qt_xdisplay(), AnyButton, AnyModifier, winId() );

    _embeddedWinId = id;
}
Beispiel #13
0
void
systray_add(Window win)
{
     Systray *s;

     if(!conf.systray.active)
          return;

     s = xcalloc(1, sizeof(Systray));
     s->win = win;

     s->geo.height = infobar[conf.systray.screen].bar->geo.height;
     s->geo.width  = TRAY_DWIDTH;

     setwinstate(s->win, WithdrawnState);
     XSelectInput(dpy, s->win, StructureNotifyMask | PropertyChangeMask| EnterWindowMask | FocusChangeMask);
     XReparentWindow(dpy, s->win, traywin, 0, 0);

     ewmh_send_message(s->win, s->win, "_XEMBED", CurrentTime, XEMBED_EMBEDDED_NOTIFY, 0, traywin, 0);

     /* Attach */
     if(trayicons)
          trayicons->prev = s;

     s->next = trayicons;
     trayicons = s;

     return;
}
Beispiel #14
0
// ===== EmbedWindow() =====
bool LX11::EmbedWindow(WId win, WId container){
  Display *disp = QX11Info::display();
  //Reparent the window
  XReparentWindow(disp, win, container,0,0);
  XSync(disp, false);
  //Check that the window has _XEMBED_INFO
  Atom embinfo = XInternAtom(disp, "_XEMBED_INFO",false);
  uchar *data=0;
  ulong num, bytes;
  int fmt;
  Atom junk;
  if(Success != XGetWindowProperty(disp, win, embinfo, 0, 2, false, embinfo, &junk, &fmt, &num, &bytes, &data) ){
    return false; //Embedding error (no info?)
  }
  if(data){ XFree(data); } // clean up any data found
	
  //Now send the embed event to the app
  XEvent ev;
	ev.xclient.type=ClientMessage;
	ev.xclient.serial=0;
	ev.xclient.send_event=true;
	ev.xclient.message_type = XInternAtom(disp, "_XEMBED", false);
	ev.xclient.window = win;
	ev.xclient.format = 32;
	ev.xclient.data.l[0] = CurrentTime;
	ev.xclient.data.l[1] = 0; //XEMBED_EMBEDDED_NOTIFY
	ev.xclient.data.l[2] = 0;
	ev.xclient.data.l[3] = container;
	ev.xclient.data.l[4] = 0;
  XSendEvent(disp, win, false, 0xFFFFFF, &ev);
  //Now setup any redirects and return
  XSelectInput(disp, win, StructureNotifyMask); //Notify of structure changes
  return true;
}
/* Not called by the gl thread */
void
gst_gl_window_set_external_window_id (GstGLWindow * window, gulong id)
{
  if (window) {
    GstGLWindowPrivate *priv = window->priv;
    XWindowAttributes attr;

    g_mutex_lock (priv->x_lock);

    priv->parent = (Window) id;

    g_debug ("set parent window id: %lud\n", id);

    XGetWindowAttributes (priv->disp_send, priv->parent, &attr);

    XResizeWindow (priv->disp_send, priv->internal_win_id, attr.width,
        attr.height);

    XReparentWindow (priv->disp_send, priv->internal_win_id, priv->parent,
        0, 0);

    XSync (priv->disp_send, FALSE);

    g_mutex_unlock (priv->x_lock);
  }
}
Beispiel #16
0
PlexyWindows::PlexyWindows(Display* dsp, Window win, XWindowAttributes* attr, QWidget *parent, Qt::WindowFlags f  )
    :QWidget(parent, f)
{
    qDebug()<<"Creating PlexyWindow"<<endl;
    XSelectInput(dsp, win, (PropertyChangeMask | EnterWindowMask | FocusChangeMask));
    XGrabServer(dsp);
    XReparentWindow(dsp, win, winId(), 20, 20);
    XAddToSaveSet(dsp, win);

    Atom _net_active_window = XInternAtom(dsp , "_NET_ACTIVE_WINDOW", false);
    XClientMessageEvent xev;
    xev.type = ClientMessage;
    xev.window = win;
    xev.message_type = _net_active_window;
    xev.format = 32;
    xev.data.l[0] = 1;
    xev.data.l[1] = CurrentTime;
    xev.data.l[2] = 0;
    XSendEvent(dsp, QApplication::desktop()->winId(), False, StructureNotifyMask,
               (XEvent *)&xev);

    XMapWindow(dsp, win);
    XSync(dsp, false);
    XUngrabServer(dsp);
    show();
}
Beispiel #17
0
void qapp::wm_restart(void)
{
	xwindow *client;
	int i;

	if(smode)
		keyboard::tscreen();

	for(i=0; i < defaults::vdesks; i++)
	{
		if(tdesks[i])
		{
			tb_pg->change_desk(i);
			toggle_tiled();
		}
	}

	winf->release_cancel();
	tb_pg->change_desk(0);
	tb_pb->remove_all();
	
	foreach(client, clients)
	{
		XRemoveFromSaveSet(QX11Info::display(), client->client_id());
		XReparentWindow(QX11Info::display(), client->client_id(), QX11Info::appRootWindow(), client->x(), client->y());
		XMapWindow(QX11Info::display(), client->client_id());
	}
Beispiel #18
0
void map_notify_handler(XEvent local_event, Display* display, ScreenInfos infos){
	printf("----------Map Notify\n");
	XWindowAttributes win_attr;
	char *child_name;
	XGetWindowAttributes(display, local_event.xmap.window, &win_attr);
	XFetchName(display, local_event.xmap.window, &child_name);
	printf("\tAttributes: W: %d - H: %d - Name: %s - ID %lu\n", win_attr.width, win_attr.height, child_name, local_event.xmap.window);
	Window trans = None;	
	XGetTransientForHint(display, local_event.xmap.window, &trans);	
	printf("\tIs transient: %ld\n", trans);
	if(child_name!=NULL){
	  if(strcmp(child_name, "Parent") && local_event.xmap.override_redirect == False){
		Window new_win = draw_window_with_name(display, RootWindow(display, infos.screen_num), "Parent", infos.screen_num, 
						   win_attr.x, win_attr.y, win_attr.width, win_attr.height+DECORATION_HEIGHT, 0, 
						   BlackPixel(display, infos.screen_num));
		XMapWindow(display, new_win);
		XReparentWindow(display,local_event.xmap.window, new_win,0, DECORATION_HEIGHT);
		set_window_item(local_event.xmap.window, new_win);
		XSelectInput(display, local_event.xmap.window, StructureNotifyMask);
		printf("\tParent window id: %lu\n", new_win);
		put_text(display, new_win, child_name, "9x15", 10, 10, BlackPixel(display,infos.screen_num), WhitePixel(display, infos.screen_num));
	  } /*else {
		  XWindowAttributes attributes;
		  Status status = XGetWindowAttributes(display, local_event.xmap.window, &attributes);
		  printf("\tStatus: %d\n", attributes.map_state);
		  printf("\tOverride redirect: %d\n", attributes.override_redirect);
		  //XMapWindow(display, trans);
		  XFetchName(display, trans, &child_name);
		  printf("\tChild name: %s\n", child_name);
		  //XRaiseWindow(local_event.xmap.display, local_event.xmap.window);
		  //XCirculateSubwindows(local_event.xmap.display, local_event.xmap.window, RaiseLowest);
	  }*/
	}
	XFree(child_name);
}
Beispiel #19
0
void iupdrvReparent(Ihandle* ih)
{
  Widget native_parent = iupChildTreeGetNativeParentHandle(ih);
  Widget widget = (Widget)iupAttribGet(ih, "_IUP_EXTRAPARENT");
  if (!widget) widget = ih->handle;
  XReparentWindow(iupmot_display, XtWindow(widget), XtWindow(native_parent), 0, 0);
}
Beispiel #20
0
GdkWindow* create_wrapper(GdkWindow* parent, Window tray_icon)
{
    gdk_flush();
    GdkWindow* icon = gdk_x11_window_foreign_new_for_display(gdk_display_get_default(), tray_icon);
    if (icon == NULL)
        return NULL;
    GdkVisual* visual = gdk_window_get_visual(icon);
    GdkWindow* wrapper = NULL;
    if (gdk_visual_get_depth(visual) == 24) {
        GdkWindowAttr attributes;
        attributes.width = DEFAULT_HEIGHT;
        attributes.height = DEFAULT_HEIGHT;
        attributes.window_type = GDK_WINDOW_CHILD;
        attributes.wclass = GDK_INPUT_OUTPUT;
        attributes.event_mask = GDK_ALL_EVENTS_MASK;
        attributes.visual = visual;
        wrapper = gdk_window_new(parent, &attributes, GDK_WA_VISUAL);
        //TODO: there should set color correspond by dock background color
        /*GdkColor color = {1, 0, 0, 1};*/
        /*gdk_window_set_background_rgba(wrapper, &color);*/

        XReparentWindow(gdk_x11_get_default_xdisplay(),
                tray_icon,
                GDK_WINDOW_XID(wrapper),
                0, 0);
        gdk_window_show(icon);
        g_object_set_data(G_OBJECT(wrapper), "wrapper_child", icon);
        g_object_set_data(G_OBJECT(icon), "wrapper_parent", wrapper);
    } else {
        wrapper = icon;
    }
    return wrapper;
}
static void
socket_unrealize_cb(GtkWidget *widget, gpointer data)
{
  // Unmap and reparent any child windows that GDK does not yet know about.
  // (See bug 540114 comment 10.)
  GdkWindow* socket_window = widget->window;
  Display* display = GDK_DISPLAY();

  // Ignore X errors that may happen if windows get destroyed (possibly
  // requested by the plugin) between XQueryTree and when we operate on them.
  gdk_error_trap_push();

  Window root, parent;
  Window* children;
  unsigned int nchildren;
  if (!XQueryTree(display, gdk_x11_drawable_get_xid(socket_window),
                  &root, &parent, &children, &nchildren))
    return;

  for (unsigned int i = 0; i < nchildren; ++i) {
    Window child = children[i];
    if (!gdk_window_lookup(child)) {
      // This window is not known to GDK.
      XUnmapWindow(display, child);
      XReparentWindow(display, child, DefaultRootWindow(display), 0, 0);
    }
  }

  if (children) XFree(children);

  XSync(display, False);
  gdk_error_trap_pop();
}
Beispiel #22
0
void DestroyDockAppSettingsPanel(AppSettingsPanel * panel)
{
	if (!panel->destroyed) {
		XUnmapWindow(dpy, panel->wwin->client_win);
		XReparentWindow(dpy, panel->wwin->client_win, panel->wwin->screen_ptr->root_win, 0, 0);
		wUnmanageWindow(panel->wwin, False, False);
	}

	panel->destroyed = 1;

	/*
	 * kluge. If we destroy the panel before the icon chooser is closed,
	 * we will crash when it does close, trying to access something in the
	 * destroyed panel. Could use wretain()/wrelease() in the panel,
	 * but it is not working for some reason.
	 */
	if (panel->choosingIcon)
		return;

	WMDestroyWidget(panel->win);

	XDestroyWindow(dpy, panel->parent);

	panel->editedIcon->panel = NULL;

	panel->editedIcon->editing = 0;

	wfree(panel);
}
Beispiel #23
0
static void reparent(client_t *c, strut_t *s)
{
    XSetWindowAttributes pattr;
    geom_t f;

    f = frame_geom(c);
    pattr.override_redirect = True;
    pattr.background_pixel = bg.pixel;
    pattr.border_pixel = bd.pixel;
    pattr.event_mask = SubMask|ButtonPressMask|ExposureMask|EnterWindowMask;
    c->frame = XCreateWindow(dpy, root, f.x, f.y, f.w, f.h, BW(c),
        DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
        CWOverrideRedirect|CWBackPixel|CWBorderPixel|CWEventMask, &pattr);

#ifdef SHAPE
    if (shape) {
        XShapeSelectInput(dpy, c->win, ShapeNotifyMask);
        set_shape(c);
    }
#endif

#ifdef XFT
    c->xftdraw = XftDrawCreate(dpy, (Drawable)c->frame,
        DefaultVisual(dpy, DefaultScreen(dpy)),
        DefaultColormap(dpy, DefaultScreen(dpy)));
#endif

    XAddToSaveSet(dpy, c->win);
    XSelectInput(dpy, c->win, ColormapChangeMask|PropertyChangeMask);
    XSetWindowBorderWidth(dpy, c->win, 0);
    XResizeWindow(dpy, c->win, c->geom.w, c->geom.h);
    XReparentWindow(dpy, c->win, c->frame, 0, frame_height(c));

    send_config(c);
}
Beispiel #24
0
Datei: x.c Projekt: Limsik/e17
void
EReparentWindow(Win win, Win parent, int x, int y)
{
   if (!win)
      return;

#if 0
   Eprintf
      ("EReparentWindow: %p %#lx: %d %#lx->%#lx %d,%d %dx%d -> %d,%d\n",
       win, win->xwin, win->mapped, (win->parent) ? win->parent->xwin : None,
       parent->xwin, win->x, win->y, win->w, win->h, x, y);
#endif
   if (parent == win->parent)
     {
	if ((x != win->x) || (y != win->y))
	  {
	     win->x = x;
	     win->y = y;
	     XMoveWindow(disp, win->xwin, x, y);
	  }
	return;
     }
   else
     {
	win->parent = parent;
	win->x = x;
	win->y = y;
     }

   XReparentWindow(disp, win->xwin, parent->xwin, x, y);
}
void
mbdesktop_win_plugin_reparent (MBDesktop *mb)
{
  XWindowAttributes  attr;

  XGetWindowAttributes(mb->dpy, mb->win_plugin, &attr);  

  mb->win_plugin_rect.x      = mb->workarea_x; 
  mb->win_plugin_rect.y      = mb->workarea_y + mb->title_offset; 
  mb->win_plugin_rect.width  = mb->workarea_width;
  mb->win_plugin_rect.height = attr.height;

  XResizeWindow(mb->dpy, mb->win_plugin, 
		mb->win_plugin_rect.width, mb->win_plugin_rect.height);

  /* XFlush needed or toplevel background dont get pained ....  */
  XFlush(mb->dpy);

  XReparentWindow(mb->dpy, mb->win_plugin, mb->win_top_level, 
  		  mb->win_plugin_rect.x, mb->win_plugin_rect.y);

  printf("%s() win_plugin rect is +%i+%i, %ix%i\n", __func__,
	 mb->win_plugin_rect.x, mb->win_plugin_rect.y,
	 mb->win_plugin_rect.width, mb->win_plugin_rect.height);
	 

  //XSelectInput(mb->dpy, mb->win_plugin, PropertyChangeMask );

  mbdesktop_win_plugin_config_event (mb);

  XMapWindow(mb->dpy, mb->win_plugin);

}
Beispiel #26
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;
}
Beispiel #27
0
Datei: icons.c Projekt: att/uwin
/***************************************************************************
*
 *
 * Looks for an application supplied icon window
 *
 ***************************************************************************
*/
void GetIconWindow(struct icon_info *item)
{
  int x, y;
  unsigned int bw;
  Window Junkroot;

  if(!XGetGeometry(dpy, item->wmhints->icon_window, &Junkroot,
                  &x, &y, (unsigned int *)&item->icon_w,
		   (unsigned int *)&item->icon_h,
		   &bw, (unsigned int *)&item->icon_depth))
  {
    /* disable the icon window hint */
    item->wmhints->icon_window = None;
    item->wmhints->flags &= ~IconWindowHint;
    return;
  }

  item->icon_pixmap_w = item->wmhints->icon_window;

  if (FShapesSupported && (item->wmhints->flags & IconMaskHint))
  {
    SET_ICON_SHAPED(item, True);
    item->icon_maskPixmap = item->wmhints->icon_mask;
  }

  item->icon_w = min(max_icon_width + icon_relief,  item->icon_w);
  item->icon_h = min(max_icon_height + icon_relief, item->icon_h);

  XReparentWindow(dpy, item->icon_pixmap_w, icon_win, 0, 0);
  XSetWindowBorderWidth(dpy, item->icon_pixmap_w, 0);
  SET_ICON_OURS(item, False);
  SET_PIXMAP_OURS(item, False);
}
Beispiel #28
0
bool tiling_fitrep(WTiling *ws, WWindow *par, const WFitParams *fp)
{
    WTilingIterTmp tmp;
    bool ok=FALSE;
    
    if(par!=NULL){
        if(!region_same_rootwin((WRegion*)ws, (WRegion*)par))
            return FALSE;
    
        region_unset_parent((WRegion*)ws);
        
        XReparentWindow(ioncore_g.dpy, ws->dummywin, 
                        par->win, fp->g.x, fp->g.y);
        
        region_set_parent((WRegion*)ws, par);
    
        if(ws->split_tree!=NULL)
            split_reparent(ws->split_tree, par);
    }
    
    REGION_GEOM(ws)=fp->g;
    
    if(ws->split_tree!=NULL){
        bool done=FALSE;
        if(fp->mode&REGION_FIT_ROTATE)
            ok=split_rotate_to(ws->split_tree, &(fp->g), fp->rotation);
        if(!ok)
            split_resize(ws->split_tree, &(fp->g), PRIMN_ANY, PRIMN_ANY);
    }
    
    return TRUE;
}
Beispiel #29
0
Datei: SetWin.c Projekt: aosm/X11
/***********************************************************************
 * Sometimes the plugin widget gets stupidly destroyed, that is whenever
 * Netscape relayouts the page. This callback reparents the client
 * windows to the root window so they do not get destroyed as well.
 * Eventually the NPP_SetWindow function should be called and we'll
 * reparent them back under the plugin.
 ***********************************************************************/
static void
DestroyCB (Widget widget, XtPointer client_data, XtPointer call_data)
{
    PluginInstance* This = (PluginInstance*) client_data;
    int i;
#ifdef PLUGIN_TRACE
    fprintf (stderr, "DestroyCB, This: 0x%x\n", This);
#endif
    if (widget == This->plugin_widget) {
	This->plugin_widget = NULL;
	This->status_widget = NULL;
    }
    if (This->dont_reparent == RxFalse) {
	for (i = 0; i < This->nclient_windows; i++) {
	    XUnmapWindow (RxGlobal.dpy, This->client_windows[i].win);
	    This->client_windows[i].flags &= ~RxpMapped;

	    XReparentWindow (RxGlobal.dpy, This->client_windows[i].win,
			     (XtScreen (widget))->root, 0, 0);
	}
	This->dont_reparent = RxTrue;
    } else
	This->dont_reparent = RxFalse;
    /* 
     * not worth removing event handlers on this widget since it's
     * about to be destroyed anyway.
     */
}
Beispiel #30
0
void qapp::wm_restart(void)
{
	xwindow *client;
	int i;

        //if(smode)
        //	keyboard::tscreen();

	for(i=0; i < defaults::vdesks; i++)
	{
		if(tdesks[i])
		{
                        HomeDesktop::instance()->getPager()->setActiveDesktop(i);
                        //toggle_tiled();
		}
	}

	winf->release_cancel();
        HomeDesktop::instance()->getPager()->setActiveDesktop(0);
	
	foreach(client, clients)
	{
		XRemoveFromSaveSet(QX11Info::display(), client->client_id());
		XReparentWindow(QX11Info::display(), client->client_id(), QX11Info::appRootWindow(), client->x(), client->y());
		XMapWindow(QX11Info::display(), client->client_id());
	}