Beispiel #1
0
Pixmap XbrGfxReadBitmap(Display *display, Screen *screen, GC gc, char *bits,
                        int width, int height)
{
    Pixmap bitmap, pixmap;

    /* Create a bitmap from the bits passed in */
    bitmap = XCreateBitmapFromData(display, RootWindowOfScreen(screen), bits,
      width, height);

    /* Create a pixmap with the same dimensions */
    pixmap = XCreatePixmap(display, RootWindowOfScreen(screen), width, height,
      DefaultDepthOfScreen(screen));

    /* Copy the bitmap onto the first plane of the pixmap */
    XCopyPlane(display, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1);

    /* Finished with the bitmap */
    XFreePixmap(display, bitmap);

    /* Done. */
    return(pixmap);
}
Beispiel #2
0
void register_canvas(Widget w, GC gc)
{
    draww = w;
    drawGC = gc;

    XtVaGetValues(w, XmNwidth, &width, XmNheight, &height, NULL);
    pixmap = XCreatePixmap(XtDisplay(w),
			   RootWindowOfScreen(XtScreen(w)), width, height,
			   (unsigned int)DefaultDepthOfScreen(XtScreen(w)));
    set_color("White");
    (void)XFillRectangle(XtDisplay(draww), pixmap, drawGC, 0,0, width,height);
    diameter = min(width, height) - RM;
}
Beispiel #3
0
// -----------------------------------------------------------------------------
int _wncki_screen_get_workspace_count(Screen* xscreen)
{
	int    ns    = 0;
	Window xroot = RootWindowOfScreen(xscreen);

	if( !_wncki_get_cardinal(xscreen, xroot, _wncki_atom_get("_NET_NUMBER_OF_DESKTOPS"), &ns) )
		ns  = 1;

	if( ns <= 0 )
		ns  = 1;

	return ns;
}
Beispiel #4
0
Pixmap get_pp_pixmap(void){
	if(!pp_pixmap) {
		pp_pixmap = XCreatePixmapFromBitmapData(
			XtDisplay(root),
			RootWindowOfScreen(XtScreen(root)),
			(char*)pp_bitmap_bits,
			pp_bitmap_width,
			pp_bitmap_height,
			BlackPixelOfScreen(XtScreen(root)), /* foreground pixel */
			WhitePixelOfScreen(XtScreen(root)), /* background pixel */
			DefaultDepthOfScreen(XtScreen(root)) /* depth */);
	}
	return pp_pixmap;
}
Beispiel #5
0
xfWindow* xf_CreateDesktopWindow(xfInfo* xfi, char* name, int width, int height, boolean decorations)
{
	xfWindow* window;

	window = (xfWindow*) xzalloc(sizeof(xfWindow));

	if (window != NULL)
	{
		int input_mask;
		XClassHint* class_hints;

		window->width = width;
		window->height = height;
		window->fullscreen = False;
		window->decorations = decorations;

		window->handle = XCreateWindow(xfi->display, RootWindowOfScreen(xfi->screen),
			xfi->workArea.x, xfi->workArea.y, xfi->width, xfi->height, 0, xfi->depth, InputOutput, xfi->visual,
			CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap |
			CWBorderPixel, &xfi->attribs);

		class_hints = XAllocClassHint();

		if (class_hints != NULL)
		{
			class_hints->res_name = "xfreerdp";
			class_hints->res_class = "xfreerdp";
			XSetClassHint(xfi->display, window->handle, class_hints);
			XFree(class_hints);
		}

		xf_ResizeDesktopWindow(xfi, window, width, height);
		xf_SetWindowDecorations(xfi, window, decorations);

		input_mask =
			KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask |
			VisibilityChangeMask | FocusChangeMask | StructureNotifyMask |
			PointerMotionMask | ExposureMask | PropertyChangeMask;

		if (xfi->grab_keyboard)
			input_mask |= EnterWindowMask | LeaveWindowMask;

		XSelectInput(xfi->display, window->handle, input_mask);
		XMapWindow(xfi->display, window->handle);
	}

	XStoreName(xfi->display, window->handle, name);

	return window;
}
Beispiel #6
0
xfWindow* xf_CreateWindow(xfInfo* xfi, rdpWindow* wnd, int x, int y, int width, int height, uint32 id)
{
	xfWindow* window;

	window = (xfWindow*) xzalloc(sizeof(xfWindow));

	if ((width * height) < 1)
		return NULL;

	xf_FixWindowCoordinates(xfi, &x, &y, &width, &height);

	window->left = x;
	window->top = y;
	window->right = x + width - 1;
	window->bottom = y + height - 1;
	window->width = width;
	window->height = height;

	if (window != NULL)
	{
		XGCValues gcv;
		int input_mask;
		XClassHint* class_hints;

		window->decorations = False;
		window->fullscreen = False;
		window->window = wnd;
		window->localMoveSize = False;

		window->handle = XCreateWindow(xfi->display, RootWindowOfScreen(xfi->screen),
			x, y, window->width, window->height, 0, xfi->depth, InputOutput, xfi->visual,
			CWBackPixel | CWBackingStore | CWOverrideRedirect | CWColormap |
			CWBorderPixel, &xfi->attribs);

		xf_SetWindowDecorations(xfi, window, window->decorations);

		class_hints = XAllocClassHint();

		if (class_hints != NULL)
		{
			char* class;
			class = xmalloc(sizeof(rail_window_class));
			snprintf(class, sizeof(rail_window_class), "RAIL:%08X", id);
			class_hints->res_name = "RAIL";
			class_hints->res_class = class;
			XSetClassHint(xfi->display, window->handle, class_hints);
			XFree(class_hints);
			xfree(class);
		}
Beispiel #7
0
static Bool
XPixmapLoader(XawParams *params, Screen *screen, Colormap colormap, int depth,
	      Pixmap *pixmap_return, Pixmap *mask_return,
	      Dimension *width_return, Dimension *height_return)
{
  XpmAttributes xpm_attributes;
  XawArgVal *argval;
  unsigned int closeness = 4000;
  static SubstitutionRec sub[] = {
    {'H',   NULL},
    {'N',   NULL},
    {'T',   "pixmaps"},
    {'P',   PROJECT_ROOT},
  };
  char *filename;

  if ((argval = XawFindArgVal(params, "closeness")) != NULL
      && argval->value)
    closeness = atoi(argval->value);

  if (params->name[0] != '/' && params->name[0] != '.')
    {
      if (!sub[0].substitution)
	sub[0].substitution = getenv("HOME");
      sub[1].substitution = params->name;
      if (pixmap_path == NULL)
	GetResourcePixmapPath(DisplayOfScreen(screen));
      filename = XtFindFile(pixmap_path, sub, XtNumber(sub), NULL);
      if (!filename)
	return (False);
    }
  else
    filename = params->name;

  xpm_attributes.colormap = colormap;
  xpm_attributes.closeness = closeness;
  xpm_attributes.valuemask = XpmSize | XpmColormap | XpmCloseness;
  if (XpmReadFileToPixmap(DisplayOfScreen(screen),
			  RootWindowOfScreen(screen), filename, pixmap_return,
			  mask_return, &xpm_attributes) == XpmSuccess)
    {
      *width_return = xpm_attributes.width;
      *height_return = xpm_attributes.height;

      return (True);
    }

  return (False);
}
Beispiel #8
0
IMAGE_CONTEXT *new_window( char *wnd_name, int x, int y, int width, int height )
{
    IMAGE_CONTEXT *img_ctx;
    img_ctx = new IMAGE_CONTEXT;

    g_width = width;
    g_height = height;

    // First we are creating the window
    if ( ( img_ctx->display = XOpenDisplay(NULL) ) == NULL )
    {
        printf("Error: XOpenDisplay failed.\n");
        exit(1);
    }

    img_ctx->screenNumber = DefaultScreen( img_ctx->display );
    img_ctx->screen = XScreenOfDisplay( img_ctx->display, img_ctx->screenNumber );


    img_ctx->window = XCreateSimpleWindow (
			img_ctx->display,
			RootWindowOfScreen( img_ctx->screen ),
			0,
			0,
			g_width,
			g_height,
			0,
			BlackPixelOfScreen( img_ctx->screen ),
			BlackPixelOfScreen( img_ctx->screen )
    );


    img_ctx->xImage = NULL;
    if( image_create( img_ctx, g_width, g_height ) < 0 )
    {
        printf("Error: image_create() failed\n");
        exit(1);
    }

    XSelectInput( img_ctx->display, img_ctx->window, ButtonPressMask | KeyPressMask );
    XMapRaised( img_ctx->display, img_ctx->window );
    XStoreName( img_ctx->display, img_ctx->window, wnd_name );
	XGetWindowAttributes( img_ctx->display, img_ctx->window, &(img_ctx->windowAttributes ) );

	XMoveWindow( img_ctx->display, img_ctx->window, x, y );


    return img_ctx;
}
/* Uses: dpy, scr, cmap. */
static XStandardColormap *
x_get_std_cmap(gx_device_X * xdev, Atom prop)
{
    int i;
    XStandardColormap *scmap, *sp;
    int nitems;

    if (XGetRGBColormaps(xdev->dpy, RootWindowOfScreen(xdev->scr),
			 &scmap, &nitems, prop))
	for (i = 0, sp = scmap; i < nitems; i++, sp++)
	    if (xdev->cmap == sp->colormap)
		return sp;

    return NULL;
}
Beispiel #10
0
static void awt_util_updateXtCoordinatesForEmbeddedFrame(Widget ef)
{
    Window ef_window;
    Window win;
    int32_t x, y;
    ef_window = XtWindow(ef);
    if (ef_window != None) {
        if (XTranslateCoordinates(awt_display, ef_window,
            RootWindowOfScreen(XtScreen(ef)),
            0, 0, &x, &y, &win)) {
            DTRACE_PRINTLN("correcting coordinates");
            ef->core.x = x;
            ef->core.y = y;
        }
    }
}
Beispiel #11
0
void MotifUI::FillBackground(Widget widget, Pixmap pixmap, Pixmap mask)
{
   static Pixmap temp = 0L;
   static GC gc = 0L;
   static unsigned int old_width = 0, old_height = 0, old_depth = 0;
   unsigned int width, height, junk, dep;
   Window root;
   XGCValues xgc;

   XGetGeometry(display, pixmap, &root, (int *) &junk,
		(int *) &junk, &width, &height, &junk, &dep);
   if (temp &&
       (old_width < width || old_height < height || old_depth != dep))
    {
      // Free resources
      XFreeGC(display, gc);
      XFreePixmap(display, temp);
      temp = 0L;
      gc = 0L;
    }

   old_width = width;
   old_height = height;
   old_depth = dep;
   if (dep == 1 && UIClass() == MAIN_WINDOW)
      XtVaGetValues(widget, XmNforeground, &xgc.foreground, NULL);
   else
      XtVaGetValues(widget, XmNbackground, &xgc.foreground, NULL);
   if (!temp)
    {
      temp = XCreatePixmap(display, RootWindowOfScreen(XtScreen(widget)),
                           width, height, dep);
      xgc.function = GXcopy;
      gc = XCreateGC(display, pixmap, GCForeground|GCFunction, &xgc);
    }
   else
      XSetForeground(display, gc, xgc.foreground);

   XFillRectangle(display, temp, gc, 0, 0, width, height);
   if (mask != XmUNSPECIFIED_PIXMAP)
      XSetClipMask(display, gc, mask);
   else
      XSetClipMask(display, gc, None);
   XCopyArea(display, pixmap, temp, gc, 0, 0, width, height, 0, 0);
   XSetClipMask(display, gc, None);
   XCopyArea(display, temp, pixmap, gc, 0, 0, width, height, 0, 0);
}
Beispiel #12
0
int XDPSCreatePixmapForEPSF(
    DPSContext context,
    Screen *screen,
    FILE *epsf,
    int depth,
    double pixelsPerPoint,
    Pixmap *pixmap,
    XRectangle *pixelSize,
    XRectangle *bbox)
{
    Pixmap p;
    int width, height;
    XRectangle bb;

    if (screen == NULL || depth <= 0 ||
	pixelsPerPoint <= 0) {
	return dps_status_illegal_value;
    }

    if (context == NULL) {
	context = XDPSGetSharedContext(DisplayOfScreen(screen));
    }

    (*rewindFunction)(epsf, rewindClientData);

    if (ParseFileForBBox(epsf, &bb) == dps_status_failure) {
	return dps_status_failure;
    }

    width = ceil(bb.width * pixelsPerPoint);
    height = ceil(bb.height * pixelsPerPoint);
    if (width <= 0 || height <= 0) return dps_status_failure;

    p = XCreatePixmap(DisplayOfScreen(screen), RootWindowOfScreen(screen),
		      width, height, depth);

    if (pixmap != NULL) *pixmap = p;
    if (pixelSize != NULL) {
       pixelSize->x = pixelSize->y = 0;
       pixelSize->width = width;
       pixelSize->height = height;
    }
    if (bbox != NULL) *bbox = bb;

    if (context != NULL) return dps_status_success;
    else return dps_status_no_extension;
}
Beispiel #13
0
void wxTopLevelWindowX11::DoGetPosition(int *x, int *y) const
{
    XSync(wxGlobalDisplay(), False);
    Window window = (Window) m_mainWindow;
    if (!window)
        return ;

    Display *display = wxGlobalDisplay();
    Window root = RootWindowOfScreen(DefaultScreenOfDisplay(display));
    Window parent_window = window,
        next_parent   = window;

    // search for the parent that is child of ROOT, because the WM may
    // reparent twice and notify only the next parent (like FVWM)
    while (next_parent != root) {
        Window *theChildren;
#if wxUSE_NANOX
        GR_COUNT n;
#else
        unsigned int n;
#endif
        parent_window = next_parent;
        XQueryTree(display, parent_window, &root,
            &next_parent, &theChildren, &n);
        XFree(theChildren); // not needed
    }
#if 0
    int xx, yy; unsigned int dummy;
    XGetGeometry(display, parent_window, &root,
                 &xx, &yy, &dummy, &dummy, &dummy, &dummy);
    if (x) *x = xx;
    if (y) *y = yy;
#else
    XWindowAttributes attr;
    Status status = XGetWindowAttributes( wxGlobalDisplay(), parent_window, & attr);
    if (status)
    {
        if (x) *x = attr.x;
        if (y) *y = attr.y;
    }
    else
    {
        if (x) *x = 0;
        if (y) *y = 0;
    }
#endif
}
Beispiel #14
0
void
move_resize_window (WnckWindow *win,
		    int	       direction,
		    decor_event *gtkwd_event)
{
    Display    *xdisplay;
    GdkDisplay *gdkdisplay;
    GdkScreen  *screen;
    Window     xroot;
    XEvent     ev;

    gdkdisplay = gdk_display_get_default ();
    xdisplay   = GDK_DISPLAY_XDISPLAY (gdkdisplay);
    screen     = gdk_display_get_default_screen (gdkdisplay);
    xroot      = RootWindowOfScreen (gdk_x11_screen_get_xscreen (screen));

    if (action_menu_mapped)
    {
	gtk_object_destroy (GTK_OBJECT (action_menu));
	return;
    }

    ev.xclient.type    = ClientMessage;
    ev.xclient.display = xdisplay;

    ev.xclient.serial	  = 0;
    ev.xclient.send_event = TRUE;

    ev.xclient.window	    = wnck_window_get_xid (win);
    ev.xclient.message_type = wm_move_resize_atom;
    ev.xclient.format	    = 32;

    ev.xclient.data.l[0] = gtkwd_event->x_root;
    ev.xclient.data.l[1] = gtkwd_event->y_root;
    ev.xclient.data.l[2] = direction;
    ev.xclient.data.l[3] = gtkwd_event->button;
    ev.xclient.data.l[4] = 1;

    XUngrabPointer (xdisplay, gtkwd_event->time);
    XUngrabKeyboard (xdisplay, gtkwd_event->time);

    XSendEvent (xdisplay, xroot, FALSE,
		SubstructureRedirectMask | SubstructureNotifyMask,
		&ev);

    XSync (xdisplay, FALSE);
}
Beispiel #15
0
// Wait for an appropriate window to be created.
// If exactMatch is FALSE, a substring match is OK.
// If windowName is empty, then wait for the next overrideRedirect window.
bool wxReparenter::WaitAndReparent(wxWindow* newParent, wxAdoptedWindow* toReparent,
                                   const wxString& windowName,
                                   bool exactMatch)
{
    sm_newParent = newParent;
    sm_toReparent = toReparent;
    sm_exactMatch = exactMatch;
    sm_name = windowName;
    
    Display* display = wxGlobalDisplay();
    XSelectInput(display,
        RootWindowOfScreen(DefaultScreenOfDisplay(display)),
        SubstructureNotifyMask);

    if (!WM_STATE)
        WM_STATE = XInternAtom(display, "WM_STATE", False);

#ifdef __WXDEBUG__
    if (!windowName.IsEmpty())
        wxLogDebug(_T("Waiting for window %s"), windowName.c_str());
#endif
    
    sm_done = FALSE;

    wxEventLoop eventLoop;
    while (!sm_done)
    {
        if (eventLoop.Pending())
        {
            XEvent xevent;
            XNextEvent(display, & xevent);
            if (!wxTheApp->ProcessXEvent((WXEvent*) & xevent))
            {
                // Do the local event processing
                ProcessXEvent((WXEvent*) & xevent);
            }
        }
        else
        {
#if wxUSE_TIMER
            wxTimer::NotifyTimers();
            wxTheApp->ProcessIdle();
#endif
        }
    }
    return TRUE;
}
Beispiel #16
0
static Drawable
CreatePixmap(Screen *screen, const gfxIntSize& size, unsigned int depth,
             Drawable relatedDrawable)
{
    if (!gfxASurface::CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT))
        return None;

    if (relatedDrawable == None) {
        relatedDrawable = RootWindowOfScreen(screen);
    }
    Display *dpy = DisplayOfScreen(screen);
    // X gives us a fatal error if we try to create a pixmap of width
    // or height 0
    return XCreatePixmap(dpy, relatedDrawable,
                         NS_MAX(1, size.width), NS_MAX(1, size.height),
                         depth);
}
Beispiel #17
0
/* this should be called first */
int APP_CC
xcommon_init(void)
{
    if (g_display != 0)
    {
        LOG(10, ("xcommon_init: xcommon_init already called"));
        return 0;
    }

    g_display = XOpenDisplay(0);

    if (g_display == 0)
    {
        LOGM((LOG_LEVEL_ERROR, "xcommon_init: error, XOpenDisplay failed"));
        return 1;
    }

    LOG(0, ("xcommon_init: connected to display ok"));

    /* setting the error handlers can cause problem when shutting down
       chansrv on some xlibs */
    XSetErrorHandler(xcommon_error_handler);
    //XSetIOErrorHandler(xcommon_fatal_handler);

    g_x_socket = XConnectionNumber(g_display);

    if (g_x_socket == 0)
    {
        LOGM((LOG_LEVEL_ERROR, "xcommon_init: XConnectionNumber failed"));
        return 1;
    }

    g_x_wait_obj = g_create_wait_obj_from_socket(g_x_socket, 0);
    g_screen_num = DefaultScreen(g_display);
    g_screen = ScreenOfDisplay(g_display, g_screen_num);

    g_root_window = RootWindowOfScreen(g_screen);

    g_wm_delete_window_atom = XInternAtom(g_display, "WM_DELETE_WINDOW", 0);
    g_wm_protocols_atom = XInternAtom(g_display, "WM_PROTOCOLS", 0);
    g_utf8_string = XInternAtom(g_display, "UTF8_STRING", 0);
    g_net_wm_name = XInternAtom(g_display, "_NET_WM_NAME", 0);
    g_wm_state = XInternAtom(g_display, "WM_STATE", 0);
    
    return 0;
}
Beispiel #18
0
static BOOL xf_event_MotionNotify(xfInfo* xfi, XEvent* event, BOOL app)
{
	int x, y;
	rdpInput* input;
	Window childWindow;

	input = xfi->instance->input;
	x = event->xmotion.x;
	y = event->xmotion.y;

	if (!xfi->settings->MouseMotion)
	{
		if ((event->xmotion.state & (Button1Mask | Button2Mask | Button3Mask)) == 0)
			return TRUE;
	} 

	if (app)
	{
		/* make sure window exists */
		if (xf_rdpWindowFromWindow(xfi, event->xmotion.window) == 0)
		{
			return TRUE;
		}

		/* Translate to desktop coordinates */
		XTranslateCoordinates(xfi->display, event->xmotion.window,
			RootWindowOfScreen(xfi->screen),
			x, y, &x, &y, &childWindow);
	}

	if (xfi->scale != 1.0)
	{
		/* Take scaling in to consideration */
		x = (int) (x * (1.0 / xfi->scale));
		y = (int) (y * (1.0 / xfi->scale));
	}

	input->MouseEvent(input, PTR_FLAGS_MOVE, x, y);

	if (xfi->fullscreen)
	{
		XSetInputFocus(xfi->display, xfi->window->handle, RevertToPointerRoot, CurrentTime);
	}

	return TRUE;
}
Beispiel #19
0
/*
 *  Function for initialising the whole shebang.
 */
void
xautolock_initDiy (Display* d)
{
  int s;

  queue.display = d;
  queue.tail = 0;
  queue.head = 0; 

  for (s = -1; ++s < ScreenCount (d); )
  {
    Window root = RootWindowOfScreen (ScreenOfDisplay (d, s));
    addToQueue (root);
#if 0
    selectEvents (root, True);
#endif
  }
}
Beispiel #20
0
int main(int argc, char *argv[])
{
    theDisplay = XOpenDisplay(NULL);
    XSynchronize(theDisplay, True);
    theScreen = DefaultScreenOfDisplay(theDisplay);
    theWindow = XCreateSimpleWindow(theDisplay, RootWindowOfScreen(theScreen),
                                    0, 0,
                                    WINDOW_SIZE, WINDOW_SIZE, 0,
                                    BlackPixelOfScreen(theScreen),
                                    WhitePixelOfScreen(theScreen));
    theGC = XCreateGC(theDisplay, theWindow, 0L, NULL);
    XSetForeground(theDisplay, theGC, BlackPixelOfScreen(theScreen));
    XMapWindow(theDisplay, theWindow);
    /* more stuff to come here... */
    tortoise_reset();
    gh_enter(argc, argv, inner_main);
    return 0; /* never reached */
}
Beispiel #21
0
BOOL xf_generic_MotionNotify(xfContext* xfc, int x, int y, int state, Window window, BOOL app)
{
	rdpInput* input;
	Window childWindow;

	input = xfc->instance->input;

	if (!xfc->settings->MouseMotion)
	{
		if ((state & (Button1Mask | Button2Mask | Button3Mask)) == 0)
			return TRUE;
	}

	if (app)
	{
		/* make sure window exists */
		if (xf_rdpWindowFromWindow(xfc, window) == 0)
		{
			return TRUE;
		}

		/* Translate to desktop coordinates */
		XTranslateCoordinates(xfc->display, window,
			RootWindowOfScreen(xfc->screen),
			x, y, &x, &y, &childWindow);
	}
	
	/* Take scaling in to consideration */
	if ( (xfc->settings->ScalingFactor != 1.0) || (xfc->offset_x) || (xfc->offset_y) )
	{
		x = (int)((x - xfc->offset_x) * (1.0 / xfc->settings->ScalingFactor) );
		y = (int)((y - xfc->offset_y) * (1.0 / xfc->settings->ScalingFactor) );
	}
	CLAMP_COORDINATES(x,y);

	input->MouseEvent(input, PTR_FLAGS_MOVE, x, y);

	if (xfc->fullscreen)
	{
		XSetInputFocus(xfc->display, xfc->window->handle, RevertToPointerRoot, CurrentTime);
	}

	return TRUE;
}
Beispiel #22
0
/* This name doesn't really cover this function, since it also sets up mouse
   and keyboard. This is done over here, since on most display targets the
   mouse and keyboard can't be setup before the display has. */
int xgl_open_display(int reopen)
{
  if(!reopen)
  {
    XWindowAttributes window_attributes;
    VisualGC vgc;
    
    fprintf(stderr, xgl_version_str);

    /* create a window */
    if (x11_create_window(&window_width, &window_height,
        cabview?X11_RESIZABLE:X11_RESIZABLE_ASPECT))
      return 1;
    
    /* Use the window's visual for the OpenGL context. */
    if (XGetWindowAttributes(display, window, &window_attributes) != 0)
       glCaps.nativeVisualID = window_attributes.visual->visualid;

    vgc = findVisualGlX( display, RootWindowOfScreen (screen),
                       &window, 0, 0, window_width, window_height, &glCaps, 
  		       NULL, NULL, 0, NULL, 0, NULL, 
#ifdef GLDEBUG
  		       1);
#else
  		       0);
#endif

    if(vgc.success==0)
    {
  	fprintf(stderr,"OSD ERROR: failed to obtain visual.\n");
  	return 1; 
    }

    glContext=vgc.gc;

    if(!glContext) {
  	fprintf(stderr,"OSD ERROR: failed to create OpenGL context.\n");
  	return 1; 
    }
    
    setGLCapabilities ( display, vgc.visual, &glCaps);
    
    xinput_open(0, 0);
  }
static cairo_bool_t
NativeRendering(void *closure,
                Screen *screen,
                Drawable drawable,
                Visual *visual,
                short offset_x, short offset_y,
                XRectangle* rectangles, unsigned int num_rects)
{
    // Cairo doesn't provide a Colormap.
    // See if a suitable existing Colormap is known.
    Colormap colormap = LookupColormapForVisual(screen, visual);
    PRBool allocColormap = colormap == None;
    if (allocColormap) {
        // No existing colormap found.
        // This case is not expected with MOZ_WIDGET_GTK2.
        // Create a Colormap for the Visual.
        // This is only really useful for Visual classes with predefined
        // Colormap entries, but cairo would be all confused with
        // non-default non-TrueColor colormaps anyway.
        NS_ASSERTION(visual->c_class == TrueColor ||
                     visual->c_class == StaticColor ||
                     visual->c_class == StaticGray,
                     "Creating empty colormap");
        // If this case were expected then it might be worth considering
        // using a service that maintains a set of Colormaps for associated
        // Visuals so as to avoid repeating the LockDisplay required in
        // XCreateColormap, but then it's no worse than the XCreatePixmap
        // that produced the Drawable here.
        colormap = XCreateColormap(DisplayOfScreen(screen),
                                   RootWindowOfScreen(screen),
                                   visual, AllocNone);
    }

    NativeRenderingClosure* cl = (NativeRenderingClosure*)closure;
    nsresult rv = cl->mRenderer->
        NativeDraw(screen, drawable, visual, colormap, offset_x, offset_y,
                   rectangles, num_rects);
    cl->mRV = rv;

    if (allocColormap) {
        XFreeColormap(DisplayOfScreen(screen), colormap);
    }
    return NS_SUCCEEDED(rv);
}
Beispiel #24
0
void
TkpMakeContainer(
    Tk_Window tkwin)		/* Token for a window that is about to become
				 * a container. */
{
    TkWindow *winPtr = (TkWindow *) tkwin;
    Container *containerPtr;
    ThreadSpecificData *tsdPtr =
            Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));

    /*
     * Register the window as a container so that, for example, we can find
     * out later if the embedded app. is in the same process.
     */

    Tk_MakeWindowExist(tkwin);
    containerPtr = ckalloc(sizeof(Container));
    containerPtr->parent = Tk_WindowId(tkwin);
    containerPtr->parentRoot = RootWindowOfScreen(Tk_Screen(tkwin));
    containerPtr->parentPtr = winPtr;
    containerPtr->wrapper = None;
    containerPtr->embeddedPtr = NULL;
    containerPtr->nextPtr = tsdPtr->firstContainerPtr;
    tsdPtr->firstContainerPtr = containerPtr;
    winPtr->flags |= TK_CONTAINER;

    /*
     * Request SubstructureNotify events so that we can find out when the
     * embedded application creates its window or attempts to resize it. Also
     * watch Configure events on the container so that we can resize the child
     * to match.
     */

    winPtr->atts.event_mask |= SubstructureRedirectMask|SubstructureNotifyMask;
    XSelectInput(winPtr->display, winPtr->window, winPtr->atts.event_mask);
    Tk_CreateEventHandler(tkwin,
	    SubstructureNotifyMask|SubstructureRedirectMask,
	    ContainerEventProc, winPtr);
    Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbedStructureProc,
	    containerPtr);
    Tk_CreateEventHandler(tkwin, FocusChangeMask, EmbedFocusProc,
	    containerPtr);
}
Beispiel #25
0
int	
main(int argc, char**argv)
{
	Display *dpy;
	Screen *scr;
	XWindowAttributes attr;
	Colormap cmap;
	XColor color;
	int i;

	/* connect to X server */
	if ((dpy=XOpenDisplay(NULL))==NULL) {
		fprintf(stderr,"Cannot connect to display %s\n",
			XDisplayName(NULL));
		exit(-1);
	}
	scr = XDefaultScreenOfDisplay(dpy);

	/* determine colormap ID */
	if (!XGetWindowAttributes(dpy,RootWindowOfScreen(scr),&attr)) {
		fprintf(stderr,"Cannot get RootWindow attributes\n");
		exit(-1);
	}
	cmap = attr.colormap;
	printf("Root Window Colormap ID = %ld\n",cmap);

	/* list colors */
	for (i=0; i<CellsOfScreen(scr); i++) {
		color.pixel = i;
		XQueryColor(dpy,cmap,&color);
		printf("pixel = %d \tred = %d \tgreen = %d \tblue = %d\n",
		       (int) color.pixel,
		       (int) color.red,
		       (int) color.green,
		       (int) color.blue);
	}

	/* close connection to X server */
	XCloseDisplay(dpy);

        return( 0 );
}
// Wait for an appropriate window to be created.
// If exactMatch is false, a substring match is OK.
// If windowName is empty, then wait for the next overrideRedirect window.
bool wxReparenter::WaitAndReparent(wxWindow* newParent, wxAdoptedWindow* toReparent,
                                   const wxString& windowName,
                                   bool exactMatch)
{
    sm_newParent = newParent;
    sm_toReparent = toReparent;
    sm_exactMatch = exactMatch;
    sm_name = windowName;

    Display* display = wxGlobalDisplay();
    XSelectInput(display,
        RootWindowOfScreen(DefaultScreenOfDisplay(display)),
        SubstructureNotifyMask);

    if (!WM_STATE)
        WM_STATE = XInternAtom(display, "WM_STATE", False);

    sm_done = false;

    wxEventLoop eventLoop;
    while (!sm_done)
    {
        if (eventLoop.Pending())
        {
            XEvent xevent;
            XNextEvent(display, & xevent);
            if (!wxTheApp->ProcessXEvent((WXEvent*) & xevent))
            {
                // Do the local event processing
                ProcessXEvent((WXEvent*) & xevent);
            }
        }
        else
        {
#if wxUSE_TIMER
            wxGenericTimerImpl::NotifyTimers();
            wxTheApp->ProcessIdle();
#endif
        }
    }
    return true;
}
Beispiel #27
0
Time
GetTimestamp (Display *dpy)
{
  XEvent   event;
  XWindowAttributes attr;
  Window   rwin = RootWindowOfScreen(XtScreen(utmShell));
  Atom     time_atom = XInternAtom(dsp, "_MOTIF_CURRENT_TIME", False);

  XGetWindowAttributes(dsp, rwin, &attr);
  if (! (attr.your_event_mask & PropertyChangeMask))
    XSelectInput(dsp, rwin, attr.your_event_mask | PropertyChangeMask);

  XChangeProperty(dsp, rwin, time_atom, time_atom, 8, PropModeAppend, NULL, 0);
  XWindowEvent(dsp, rwin, PropertyChangeMask, &event);

  if (! (attr.your_event_mask & PropertyChangeMask))
    XSelectInput(dsp, rwin, attr.your_event_mask);

  return(event.xproperty.time);
}
Beispiel #28
0
// Get the current mouse position.
wxPoint wxGetMousePosition()
{
#if wxUSE_NANOX
    /* TODO */
    return wxPoint(0, 0);
#else
    Display *display = wxGlobalDisplay();
    Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display));
    Window rootReturn, childReturn;
    int rootX, rootY, winX, winY;
    unsigned int maskReturn;

    XQueryPointer (display,
                   rootWindow,
                   &rootReturn,
                   &childReturn,
                   &rootX, &rootY, &winX, &winY, &maskReturn);
    return wxPoint(rootX, rootY);
#endif
}
Beispiel #29
0
void wxTopLevelWindowMotif::Lower()
{
    Widget top = (Widget) GetTopWidget();
    Window parent_window = XtWindow( top ),
        next_parent   = XtWindow( top ),
        root          = RootWindowOfScreen( XtScreen( top ) );
    // search for the parent that is child of ROOT, because the WM may
    // reparent twice and notify only the next parent (like FVWM)
    while( next_parent != root )
    {
        Window *theChildren;
        unsigned int n;

        parent_window = next_parent;
        XQueryTree( XtDisplay( top ), parent_window, &root,
            &next_parent, &theChildren, &n );
        XFree( theChildren ); // not needed
    }
    XLowerWindow( XtDisplay( top ), parent_window );
}
Beispiel #30
0
PRIVATE void DestroyLido ()
{
	int		root_x, root_y;
	int		x, y;
	unsigned int	width, height, bw, depth;
	Window		dummy;

      /* Remember the window's position */
	XTranslateCoordinates (dpy, XtWindow (LidoTop),
				RootWindowOfScreen (XtScreen (LidoTop)),
				0, 0, &root_x, &root_y, &dummy);
	XGetGeometry (dpy, XtWindow (LidoTop), &dummy,
				&x, &y, &width, &height, &bw, &depth);
	(void) sprintf (LidoGeometry, "%ux%u+%d+%d", 
			width, height, root_x, root_y - Res.wm_push_down);

      /* Destroy the window */
	XtUnmapWidget (LidoTop);
	XtDestroyWidget (LidoTop);
	LidoTop = (Widget) NULL;
}