Пример #1
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;
}
Пример #2
0
/*ARGSUSED*/
ClientData *
GetPCD (
     int    scr,		/* unused */
     Window win)
{
  ClientData   *pCD = NULL;
  Window        root, parent, *children;
  unsigned int  nchildren;

  if (XQueryTree(DISPLAY, win & WIN_MASK, &root, &parent,
		 &children, &nchildren))

    if (XFindContext (DISPLAY, parent, wmGD.windowContextType,
		      (XPointer *)&pCD))
      {
	Boolean foundIt = False;

	while ((parent != root) && (!foundIt))
	  {
	    win = parent;
	    if (!XQueryTree(DISPLAY, win, &root, &parent,
			    &children, &nchildren))
	      break;
	    foundIt =
	      (XFindContext (DISPLAY, parent, wmGD.windowContextType,
			     (XPointer *)&pCD) == 0);
	  }

	if (!foundIt) pCD = NULL;
      }

  return (pCD);
}
Пример #3
0
/***********************************************************************
 *		set_window_cursor
 */
void set_window_cursor( struct x11drv_win_data *data, HCURSOR handle )
{
    Cursor cursor, prev;

    wine_tsx11_lock();
    if (!handle) cursor = get_empty_cursor();
    else if (!cursor_context || XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&cursor ))
    {
        /* try to create it */
        wine_tsx11_unlock();
        if (!(cursor = create_cursor( handle ))) return;

        wine_tsx11_lock();
        if (!cursor_context) cursor_context = XUniqueContext();
        if (!XFindContext( gdi_display, (XID)handle, cursor_context, (char **)&prev ))
        {
            /* someone else was here first */
            XFreeCursor( gdi_display, cursor );
            cursor = prev;
        }
        else
        {
            XSaveContext( gdi_display, (XID)handle, cursor_context, (char *)cursor );
            TRACE( "cursor %p created %lx\n", handle, cursor );
        }
    }

    XDefineCursor( gdi_display, data->whole_window, cursor );
    /* make the change take effect immediately */
    XFlush( gdi_display );
    data->cursor = handle;
    wine_tsx11_unlock();
}
Пример #4
0
Bool focus_container(wm_t *wm, wm_event_t *event) {
  container_t *container;
  int ret;

  //wm_log(wm, LOG_INFO, "%s", __func__);

  ret = XFindContext(wm->dpy, event->client->window, client_container_context,
                     (XPointer*)&container);
  if (ret == XCNOENT) {
    /* See if this window is a container */
    ret = XFindContext(wm->dpy, event->client->window, container_context,
                       (XPointer*)&container);
    if (ret == XCNOENT) {
      wm_log(wm, LOG_INFO, "no container found for window %d, can't focus.", event->client->window);
      return False;
    }
  }

  if (current_container == container) {
    //wm_log(wm, LOG_INFO, "%s: ignoring attempt to focus and blur the same container at the same time.", __func__);
    //return True;
  }
  container_blur(current_container);
  current_container = container;
  container_focus(container);

  return True;
}
Пример #5
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);
  }
}
Пример #6
0
Файл: DragBS.c Проект: att/uwin
/*
 * fetch the cached atoms table
 */
static XmDndTargetsTable
get_targets_table(Display *display)
{
    XmDndTargetsTable targets = NULL;

    DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:get_targets_table(%d)\n",
		      __FILE__, __LINE__));

    if (displayToTargets == (XContext)0)
    {
	displayToTargets = XUniqueContext();
    }

    if (XFindContext(display, DefaultRootWindow(display),
		     displayToTargets, (XPointer *)&targets) != XCSUCCESS)
    {
	DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:get_targets_table(%d) - NULL\n",
		      __FILE__, __LINE__));

	return NULL;
    }

    DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:get_targets_table(%d) - %p\n",
		      __FILE__, __LINE__, targets));

    return targets;
}
Пример #7
0
/***********************************************************************
 *           process_events
 */
static int process_events( Display *display, ULONG_PTR mask )
{
    XEvent event;
    HWND hwnd;
    int count = 0;
    x11drv_event_handler handler;

    wine_tsx11_lock();
    while (XCheckIfEvent( display, &event, filter_event, (char *)mask ))
    {
        count++;
        if (XFilterEvent( &event, None )) continue;  /* filtered, ignore it */

        if (!(handler = find_handler( event.type )))
        {
            TRACE( "%s, ignoring\n", dbgstr_event( event.type ));
            continue;  /* no handler, ignore it */
        }

        if (XFindContext( display, event.xany.window, winContext, (char **)&hwnd ) != 0)
            hwnd = 0;  /* not for a registered window */
        if (!hwnd && event.xany.window == root_window) hwnd = GetDesktopWindow();

        wine_tsx11_unlock();
        TRACE( "%s for hwnd/window %p/%lx\n",
               dbgstr_event( event.type ), hwnd, event.xany.window );
        handler( hwnd, &event );
        wine_tsx11_lock();
    }
    XFlush( gdi_display );
    wine_tsx11_unlock();
    if (count) TRACE( "processed %d events\n", count );
    return count;
}
Пример #8
0
static void DrvPrintTree(PRIVATEDISPLAY *dp, Window start)
{
    static indent = 0;
    Window root;
    Window parent;
    Window *children;
    unsigned int nchildren;
    Status rv;
    int i;
    char indent_str[80];
    DWORD dwClientWin;
    
    rv = XQueryTree(dp->display, 
		    start,
		    &root, &parent, &children, &nchildren);
    if (rv)
    {
	for (i = 0; i < indent; i++)
	    indent_str[i] = ' ';
	indent_str[i] = '\0';
	
	for (i = 0; i < nchildren; i++)
	{
	    XFindContext(dp->display, children[i], dp->client_hwnd,
			     (caddr_t *) &dwClientWin);
	    indent += 2;
	    DrvPrintTree(dp, children[i]);
	    indent -= 2;
	}

	XFree(children);
    }
}
Пример #9
0
Файл: DragBS.c Проект: att/uwin
/*
 * lookup (program local) the value of the drag window
 */
static Window
get_drag_window(Display *display)
{
    Window win;

    DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:get_drag_window(%d)\n",
		      __FILE__, __LINE__));

    if (displayToDW == None)
    {
	displayToDW = XUniqueContext();
    }

    if (XFindContext(display, DefaultRootWindow(display),
		     displayToDW, (XPointer *)&win) == XCSUCCESS)
    {
	DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:get_drag_window(%d) - %p\n",
		      __FILE__, __LINE__, win));

	return win;
    }

    DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:get_drag_window(%d) - None\n",
		      __FILE__, __LINE__));

    return None;
}
Пример #10
0
static int dialog_click (Display *dpy, Window win, int x, int y, int b) {
	struct XJDialog *dlg = NULL;
	XFindContext (dpy, win, _dlg_ctx, (XPointer*)&dlg);
	if (!dlg) return -1;

	x -= dlg->x0;
	y -= dlg->y0;

	if (x <= 0 || y <= 0 || x >= dlg->width || y >= dlg->height) {
		return -1;
	}
	if (b != 1) return 0;

	if (dlg->menu_hover >= 0 && dlg->menu_hover < dlg->menu_count) {
		if (dlg->menu_items[dlg->menu_hover].callback && dlg->menu_items[dlg->menu_hover].sensitive) {
			dlg->menu_items[dlg->menu_hover].callback();
			close_x_dialog(dpy);
#ifdef XFIB
			if (dlg->menu_items[dlg->menu_hover].callback == &ui_open_file) {
				if (!(interaction_override&OVR_LOADFILE)) {
					x_fib_cfg_filter_callback(fib_filter_movie_filename);
					x_fib_show (dpy, _parent, 0, 0);
				}
			}
#endif
		}
	}
	return 0;
}
Пример #11
0
Файл: DragBS.c Проект: att/uwin
/*
 * cache the atoms table
 */
static void
set_targets_table(Display *display, XmDndTargetsTable table)
{
    XmDndTargetsTable targets;

    DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:set_targets_table(%d) - %p\n",
		      __FILE__, __LINE__, table));

    if (displayToTargets == (XContext)0)
    {
	displayToTargets = XUniqueContext();
    }

    if (XFindContext(display, DefaultRootWindow(display),
		     displayToTargets, (XPointer *)&targets) == XCSUCCESS)
    {

	if (targets == table)
	{
	    return;
	}

	XDeleteContext(display, DefaultRootWindow(display),
		       displayToTargets);
    }

    XSaveContext(display, DefaultRootWindow(display),
		 displayToTargets, (XPointer)table);
}
Пример #12
0
Файл: DragBS.c Проект: att/uwin
/*
 * cache the atoms table
 */
static void
set_atoms_table(Display *display, XmDndAtomsTable table)
{
    XmDndAtomsTable atoms;

    DEBUGOUT(_LtDebug0(__FILE__, NULL, "%s:set_atoms_table(%d)\n",
		      __FILE__, __LINE__));

    if (displayToAtoms == (XContext)0)
	displayToAtoms = XUniqueContext();

    if (XFindContext(display, DefaultRootWindow(display),
		     displayToAtoms, (XPointer *)&atoms) == XCSUCCESS)
    {
	if (atoms == table)
	{
	    return;
	}

	XDeleteContext(display, DefaultRootWindow(display),
		       displayToAtoms);
    }

    XSaveContext(display, DefaultRootWindow(display),
		 displayToAtoms, (XPointer)table);
}
Пример #13
0
static cairo_5c_surface_t *
get_window_surface (x_global_t *xg, Window wid)
{
    XPointer	pointer;
    if (XFindContext (xg->dpy, wid, xg->context, &pointer) == 0)
	return (cairo_5c_surface_t *) pointer;
    return NULL;
}
Пример #14
0
XPointer *
subSubtleFind(Window win,
              XContext id)
{
    XPointer *data = NULL;

    return XCNOENT != XFindContext(subtle->dpy, win, id, (XPointer *)&data) ? data : NULL;
} /* }}} */
Пример #15
0
/***********************************************************************
 *           palette_get_mapping
 */
static int *palette_get_mapping( HPALETTE hpal )
{
    int *mapping;

    wine_tsx11_lock();
    if (XFindContext( gdi_display, (XID)hpal, palette_context, (char **)&mapping )) mapping = NULL;
    wine_tsx11_unlock();
    return mapping;
}
Пример #16
0
/** Find a client by window. */
ClientNode *FindClientByWindow(Window w)
{
   ClientNode *np;
   if(!XFindContext(display, w, clientContext, (void*)&np)) {
      return np;
   } else {
      return NULL;
   }
}
Пример #17
0
void MenuExpose(XEvent *event)
{
  Menu *mc;
  MenuItem *mi;

  if(event->xexpose.count) return;
  if(!XFindContext(disp, event->xexpose.window, TheScreen.MenuContext,
                   (XPointer *)&mi)) {
    DrawItem(mi, 0);
    return;
  }
  if(!XFindContext(disp, event->xexpose.window, TheScreen.MenuFrameContext,
                   (XPointer *)&mc)) {
    DrawMenuFrame(mc, 0);
    return;
  }
  HandleExpose(event);
}
Пример #18
0
W_View *W_GetViewForXWindow(Display * display, Window window)
{
	W_View *view;

	if (XFindContext(display, window, ViewContext, (XPointer *) & view) == 0) {
		return view;
	}
	return NULL;
}
Пример #19
0
void BrowserControl::handleXEvent(const XEvent& event)
{
    VisualComponent *component = 0;
    XFindContext(event.xany.display, event.xany.window, m_context, (XPointer*)&component);

    // Send event to the appropriate component that will be handle
    if (component)
        component->handleEvent(event);
}
Пример #20
0
/** Find a client by its frame window. */
ClientNode *FindClientByParent(Window p)
{
   ClientNode *np;
   if(!XFindContext(display, p, frameContext, (void*)&np)) {
      return np;
   } else {
      return NULL;
   }
}
Пример #21
0
void x_object_destroy(XObject * obj)
{
	Window root,parent,*childlist;
	XObject* child;
	unsigned childcnt,i;
	if(XQueryTree(dis,obj->obj.win,&root,&parent,&childlist,&childcnt)!=0)
	{
		if(childlist!=NULL)
		{
			for(i=0;i<childcnt;i++)
			{
				child=NULL;
				XFindContext(dis,childlist[i],xctxt,(XPointer*)&child);
				if(child!=NULL)
					x_object_destroy(child);
			}
			XFree(childlist);
		}
	}
	if(obj->obj.type==XWINDOW)
		obj->window.focus=NULL;
	else if(obj->obj.parentwindow->window.focus)
		x_object_set_focused(obj->obj.parentwindow);
	XDeleteContext(dis,obj->obj.win,xctxt);
	XDestroyWindow(dis,obj->obj.win);
	switch(obj->obj.type)
	{
	case XWINDOW:
		XFree(obj->window.header.value);
		if(modalwindow==obj)
			modalwindow=NULL;
		break;
	case XBUTTON:
		x_gc_unref(obj->button.Black);
		x_gc_unref(obj->button.Gray);
		x_gc_unref(obj->button.White);
		free(obj->button.text);
		break;
	case XFRAME:
		break;
	case XLABEL:
		free(obj->label.text);
		break;
	case XTEXTBOX:
		free(obj->textbox.buffer);
		x_gc_unref(obj->textbox.SelectFocused);
		x_gc_unref(obj->textbox.SelectUnfocused);
		break;
	case XSCROLL:
		x_gc_unref(obj->scroll.Black);
		x_gc_unref(obj->scroll.Gray);
		x_gc_unref(obj->scroll.White);
		break;
	}
	free(obj);
}
Пример #22
0
int handle_xdlg_event (Display *dpy, XEvent *event) {
	if (!_dlg_mwin) return 0;
	assert(event->xany.window);
	if (event->xany.window != _dlg_mwin && event->xany.window != _dlg_swin) {
		switch (event->type) {
			case ButtonRelease:
			case KeyRelease:
			close_x_dialog (dpy);
				break;
			default:
				break;
		}
		return 0;
	}

	switch (event->type) {
		case ConfigureNotify:
			//printf("DLG ConfigureNotify %dx%d\n", event->xconfigure.width, event->xconfigure.height);
			break;
		case LeaveNotify:
			{
				struct XJDialog *dlg = NULL;
				XFindContext (dpy, event->xany.window, _dlg_ctx, (XPointer*)&dlg);
				if (dlg
						&& dlg->menu_hover >= 0 && dlg->menu_hover < dlg->menu_count
						&& !dlg->menu_items[dlg->menu_hover].submenu)
				{
					dlg->menu_hover = -1;
					dialog_expose (dpy, event->xany.window);
				}
			}
			break;
		case Expose:
			if (event->xexpose.count == 0) {
				dialog_expose (dpy, event->xany.window);
			}
			break;
		case MotionNotify:
			dialog_motion (dpy, event->xany.window, event->xmotion.x_root, event->xmotion.y_root);
			if (event->xmotion.is_hint == NotifyHint) {
				XGetMotionEvents (dpy, event->xany.window, CurrentTime, CurrentTime, NULL);
			}
			break;
		case ButtonPress:
			break;
		case ButtonRelease:
			if (dialog_click(dpy, event->xany.window, event->xbutton.x_root, event->xbutton.y_root, event->xbutton.button)) {
				close_x_dialog (dpy);
			}
			break;
		case KeyRelease:
			close_x_dialog (dpy);
			break;
	}
	return 1;
}
Пример #23
0
Файл: thing.c Проект: Cougar/pwm
WThing *find_thing(Window win)
{
	WThing *thing;
	
	if(XFindContext(wglobal.dpy, win, wglobal.win_context,
					(XPointer*)&thing)!=0)
		return NULL;
	
	return thing;
}
Пример #24
0
WApplication *wApplicationOf(Window window)
{
	WApplication *wapp;

	if (window == None)
		return NULL;
	if (XFindContext(dpy, window, wAppWinContext, (XPointer *) & wapp) != XCSUCCESS)
		return NULL;
	return wapp;
}
Пример #25
0
static WindowInfo* find_handle(Window handle)
{
    WindowInfo* info;

    if (XFindContext(s_display, handle, s_context, (XPointer*) &info) != 0) {
        return 0;
    }

    return info;
}
Пример #26
0
WRegion *xwindow_region_of(Window win)
{
    WRegion *reg;
    
    if(XFindContext(ioncore_g.dpy, win, ioncore_g.win_context,
                    (XPointer*)&reg)!=0)
        return NULL;
    
    return reg;
}
Пример #27
0
static void
Destroy(Widget w, XawVendorShellExtPart *ve)
{
    contextDataRec *contextData;
    contextErrDataRec *contextErrData;

    if (!XtIsVendorShell( w ) )
	return;
    XtFree( (char*) ve->im.resources );

    if (extContext != (XContext)0 &&
	!XFindContext (XtDisplay (w), (Window)(uintptr_t)w,
		       extContext, (XPointer*)&contextData))
        XtFree( (char*) contextData );

    if (errContext != (XContext)0 &&
	!XFindContext (XDisplayOfIM( ve->im.xim ), (Window)(uintptr_t) ve->im.xim,
		       errContext, (XPointer*) &contextErrData))
        XtFree( (char*) contextErrData );
}
Пример #28
0
static Widget
GetErrCnxt(XIM error_im)
{
    contextErrDataRec *contextErrData;

    if (XFindContext(XDisplayOfIM(error_im), (Window)error_im, errContext,
		      (XPointer*)&contextErrData)) {
	return(NULL);
    }
    return(contextErrData->widget);
}
Пример #29
0
static void close_x_dialog_win (Display *dpy, Window *win) {
	struct XJDialog *dlg = NULL;
	if (!win || !*win) return;
	XFindContext (dpy, *win, _dlg_ctx, (XPointer*)&dlg);
	if (dlg) {
		XDeleteContext (dpy, *win, _dlg_ctx);
		XFreeGC (dpy, dlg->gc);
		free(dlg);
	}
	XDestroyWindow (dpy, *win);
	*win = 0;
}
Пример #30
0
static XawVendorShellExtPart *
GetExtPart(VendorShellWidget w)
{
    contextDataRec *contextData;
    XawVendorShellExtWidget vew;

	if (XFindContext(XtDisplay(w), (Window)(((intptr_t)w)& 0xffffffff), extContext,
		      (XPointer*)&contextData)) {
	return(NULL);
    }
    vew = (XawVendorShellExtWidget)contextData->ve;
    return(&(vew->vendor_ext));
}