Exemplo n.º 1
1
void appIcon_Init(Widget* w_TopLevel, int argc, char* argv[])
{	
	Position x, y;
	Dimension w, h;
	
	appLList = (struct NODE *)malloc(sizeof(struct NODE));
	appLList->ptrData = NULL;
	appLList->next = NULL;
	
	
	XtSetLanguageProc (NULL, NULL, NULL);
	*w_TopLevel = XtVaOpenApplication (&GXIM_App, "gXipmsg", NULL, 0, &argc, argv, NULL,sessionShellWidgetClass, NULL);

	APPICON_Form = XmCreateForm (*w_TopLevel, "ipmsgForm", NULL, 0);
	
	// Create list holder
	APPICON_List_Users = XmCreateScrolledList (APPICON_Form, "List", NULL, 0);
	
	XtVaGetValues (APPICON_Form, XmNforeground, &fg, XmNbackground, &bg, NULL);
	
	pixmap =XmGetPixmap (XtScreen (APPICON_Form), "ipmsg.xpm", fg, bg);
	
	if(pixmap == XmUNSPECIFIED_PIXMAP)
	{
		pixmap = XmGetPixmap (XtScreen (APPICON_Form), "/etc/gXipmsg/ipmsg.xpm", fg, bg);
	}
		
	// Create icon button
	n = 0;
	XtSetArg (args[n], XmNlabelType, XmPIXMAP); n++; 
	XtSetArg (args[n], XmNlabelPixmap, pixmap); n++;
	APPICON_BtnG_Icon = XmCreatePushButtonGadget (APPICON_Form, "ipmsgButton", args, n);	
	XtAddCallback (APPICON_BtnG_Icon, XmNactivateCallback, appIcon_IconCallBack, APPICON_List_Users);
	XtManageChild (APPICON_BtnG_Icon);	
	
	XtManageChild (APPICON_Form);
	
	x = WidthOfScreen (XtScreen (*w_TopLevel));
	y = HeightOfScreen (XtScreen (*w_TopLevel));
	XtVaGetValues(*w_TopLevel, XmNwidth, &w, XmNheight, &h, NULL);
	
	x = x - (w+150);
	y = y - (h+150);
	
	XtVaSetValues (*w_TopLevel,
		       XmNmwmDecorations, MWM_DECOR_TITLE | MWM_DECOR_MENU,	
		       XmNmwmFunctions, MWM_FUNC_CLOSE | MWM_FUNC_MOVE,
		       XmNtitle, "gXip",
		       XmNx, x,
		       XmNy, y,
		       NULL);	
	
	// Materialize major widgets
	XtRealizeWidget (*w_TopLevel);
}
Exemplo n.º 2
0
int xf_list_monitors(xfInfo* xfi)
{
#ifdef WITH_XINERAMAZ
	int i, nmonitors = 0;
	int ignored, ignored2;
	XineramaScreenInfo* screen = NULL;

	if (XineramaQueryExtension(xfi->display, &ignored, &ignored2))
	{
		if (XineramaIsActive(xfi->display))
		{
			screen = XineramaQueryScreens(xfi->display, &nmonitors);

			for (i = 0; i < nmonitors; i++)
			{
				DEBUG_MSG("      %s [%d] %dx%d\t+%d+%d\n",
				       (i == 0) ? "*" : " ", i,
				       screen[i].width, screen[i].height,
				       screen[i].x_org, screen[i].y_org);
			}

			XFree(screen);
		}
	}
#else
	Screen* screen;

	screen = ScreenOfDisplay(xfi->display, DefaultScreen(xfi->display));
	DEBUG_MSG("      * [0] %dx%d\t+%d+%d\n", WidthOfScreen(screen), HeightOfScreen(screen), 0, 0);
#endif

	return 0;
}
Exemplo n.º 3
0
static gint
xfce_xsettings_helper_screen_dpi (XfceXSettingsScreen *screen)
{
    Screen *xscreen;
    gint    width_mm, width_dpi;
    gint    height_mm, height_dpi;
    gint    dpi = DPI_FALLBACK;

    xscreen = ScreenOfDisplay (screen->xdisplay, screen->screen_num);
    if (G_LIKELY (xscreen != NULL))
    {
        width_mm = WidthMMOfScreen (xscreen);
        height_mm = HeightMMOfScreen (xscreen);

        if (G_LIKELY (width_mm > 0 && height_mm > 0))
        {
            width_dpi = 25.4 * WidthOfScreen (xscreen) / width_mm;
            height_dpi = 25.4 * HeightOfScreen (xscreen) / height_mm;

            /* both values need to be reasonable */
            if (width_dpi > DPI_LOW_REASONABLE && width_dpi < DPI_HIGH_REASONABLE
                && height_dpi > DPI_LOW_REASONABLE && height_dpi < DPI_HIGH_REASONABLE)
            {
                /* gnome takes the average between the two, however the
                 * minimin seems to result in sharper font in more cases */
                dpi = MIN (width_dpi, height_dpi);
            }
        }
    }

    xfsettings_dbg_filtered (XFSD_DEBUG_XSETTINGS, "calculated dpi of %d for screen %d",
                             dpi, screen->screen_num);

    return dpi;
}
Exemplo n.º 4
0
int x11_shadow_subsystem_base_init(x11ShadowSubsystem* subsystem)
{
	if (subsystem->display)
		return 1; /* initialize once */

	if (!getenv("DISPLAY"))
		setenv("DISPLAY", ":0", 1);

	if (!XInitThreads())
		return -1;

	subsystem->display = XOpenDisplay(NULL);

	if (!subsystem->display)
	{
		WLog_ERR(TAG, "failed to open display: %s", XDisplayName(NULL));
		return -1;
	}

	subsystem->xfds = ConnectionNumber(subsystem->display);
	subsystem->number = DefaultScreen(subsystem->display);
	subsystem->screen = ScreenOfDisplay(subsystem->display, subsystem->number);
	subsystem->depth = DefaultDepthOfScreen(subsystem->screen);
	subsystem->width = WidthOfScreen(subsystem->screen);
	subsystem->height = HeightOfScreen(subsystem->screen);
	subsystem->root_window = RootWindow(subsystem->display, subsystem->number);

	return 1;
}
Exemplo n.º 5
0
int
parseArgs( int argc, char *argv[])
{
    char xsign, ysign;
    if ( argc != 3 || strcmp( "-geometry", argv[1] ) )
	return 1;

    if ( sscanf( argv[2], "%dx%d%c%d%c%d\n", &window_width, 
		 &window_height, 
		 &xsign, &window_x, &ysign, &window_y ) != 6 ) 
    	return 1;
    
    if ( xsign == '-' )
    {
	int screen_width = WidthOfScreen( 
	    ScreenOfDisplay( myDisplay, myScreen ) );
	window_x = screen_width - window_width - window_x;
    }

    if ( ysign == '-' )
    {
	int screen_height = HeightOfScreen( 
	    ScreenOfDisplay( myDisplay, myScreen ) );
	window_y = screen_height - window_height - window_y;
    }
    return 0;
}
Exemplo n.º 6
0
static int module_init(Display *dpy) {

    int i;

    data.display = dpy;
    data.windows = (Window *)malloc(sizeof(Window) * ScreenCount(dpy));

    for (i = 0; i < ScreenCount(dpy); i++) {

        Screen *screen = ScreenOfDisplay(dpy, i);
        Colormap colormap = DefaultColormapOfScreen(screen);
        XSetWindowAttributes xswa;
        XColor color;

        alock_alloc_color(dpy, colormap, data.colorname, "black", &color);

        xswa.override_redirect = True;
        xswa.colormap = colormap;
        xswa.background_pixel = color.pixel;

        data.windows[i] = XCreateWindow(dpy, RootWindowOfScreen(screen),
                0, 0, WidthOfScreen(screen), HeightOfScreen(screen), 0,
                CopyFromParent, InputOutput, CopyFromParent,
                CWOverrideRedirect | CWColormap | CWBackPixel,
                &xswa);

    }

    return 0;
}
Exemplo n.º 7
0
static void
CenterWidgetAtPoint(Widget w, int x, int y)
{
    Arg	args[2];
    Dimension	width, height;

    XtSetArg(args[0], XtNwidth, &width);
    XtSetArg(args[1], XtNheight, &height);
    XtGetValues (w, args, 2);
    x = x - (int) width / 2;
    y = y - (int) height / 2;
    if (x < 0)
	x = 0;
    else {
	int scr_width = WidthOfScreen (XtScreen(w));
	if (x + (int)width > scr_width)
	    x = scr_width - width;
    }
    if (y < 0)
	y = 0;
    else {
	int scr_height = HeightOfScreen (XtScreen(w));
	if (y + (int)height > scr_height)
	    y = scr_height - height;
    }
    XtSetArg(args[0], XtNx, x);
    XtSetArg(args[1], XtNy, y);
    XtSetValues (w, args, 2);
}
Exemplo n.º 8
0
void slop::Framebuffer::draw(glm::vec2 mouse, float time, glm::vec4 color){
    shader->bind();
    shader->setParameter( "texture", 0 );
    shader->setAttribute( "position", buffers[0], 2 );
    shader->setAttribute( "uv", buffers[1], 2 );
    if ( shader->hasParameter( "mouse" ) ) {
        shader->setParameter( "mouse", mouse );
    }
    if ( shader->hasParameter( "color" ) ) {
        shader->setParameter( "color", color );
    }
    if ( shader->hasParameter( "screenSize" ) ) {
        shader->setParameter( "screenSize", glm::vec2( WidthOfScreen( x11->screen ), HeightOfScreen( x11->screen ) ));
    }
    if ( shader->hasParameter( "time" ) ) {
        shader->setParameter( "time", time );
    }
    glActiveTexture(GL_TEXTURE0);
    glBindTexture( GL_TEXTURE_2D, image );
    if ( shader->hasParameter( "desktop" ) ) {
		shader->setParameter( "desktop", 1 );
        glActiveTexture(GL_TEXTURE0 + 1);
        glBindTexture( GL_TEXTURE_2D, desktopImage );
    }
    glEnable( GL_TEXTURE_2D );
    glDrawArrays( GL_TRIANGLES, 0, vertCount );
    glDisable( GL_TEXTURE_2D );
    shader->unbind();
}
Exemplo n.º 9
0
static gint
gdk_x11_screen_get_height (GdkScreen *screen)
{
  g_return_val_if_fail (GDK_IS_SCREEN (screen), 0);

  return HeightOfScreen (GDK_X11_SCREEN (screen)->xscreen);
}
Exemplo n.º 10
0
Window create_full_screen_window (Display *dpy, int screen, Colormap cmap)
{
  XSetWindowAttributes attrs;
  Window win;
  Visual *visual;
  Screen *screen_obj;
  unsigned long attrmask;
  int depth;

  screen_obj = ScreenOfDisplay (dpy, screen);
  visual = DefaultVisualOfScreen (screen_obj);
  depth = visual_depth (screen_obj, visual);

  attrmask = (CWOverrideRedirect | CWEventMask | CWBackingStore | CWColormap
              | CWCursor);
  attrs.override_redirect = True;
  attrs.event_mask = (ExposureMask | KeyPressMask | ButtonPressMask
                      | Button1MotionMask | ButtonReleaseMask);
  attrs.backing_store = NotUseful;
  attrs.colormap = cmap;
  attrs.cursor = XCreateFontCursor (dpy, XC_cross);

  win = XCreateWindow (dpy, RootWindowOfScreen (screen_obj),
                       0, 0, WidthOfScreen (screen_obj),
                       HeightOfScreen (screen_obj), 0,
                       depth, InputOutput, visual,
                       attrmask, &attrs);
  return win;
}
Exemplo n.º 11
0
// find the dimensions of the monitor displaying point x,y
void monitor_dimensions ( Display *display, Screen *screen, int x, int y, workarea *mon )
{
    memset ( mon, 0, sizeof ( workarea ) );
    mon->w = WidthOfScreen ( screen );
    mon->h = HeightOfScreen ( screen );

    // locate the current monitor
    if ( XineramaIsActive ( display ) ) {
        int                monitors;
        XineramaScreenInfo *info = XineramaQueryScreens ( display, &monitors );

        if ( info ) {
            for ( int i = 0; i < monitors; i++ ) {
                if ( INTERSECT ( x, y, 1, 1, info[i].x_org, info[i].y_org, info[i].width, info[i].height ) ) {
                    mon->x = info[i].x_org;
                    mon->y = info[i].y_org;
                    mon->w = info[i].width;
                    mon->h = info[i].height;
                    break;
                }
            }
        }

        XFree ( info );
    }
}
Exemplo n.º 12
0
static void switch_to_best_mode (void)
{
    Screen *scr = ScreenOfDisplay (display, screen);
    int w = WidthOfScreen (scr);
    int h = HeightOfScreen (scr);
    int d = DefaultDepthOfScreen (scr);
#ifdef USE_VIDMODE_EXTENSION
    int i, best;
    if (vidmodeavail) {
	best = 0;
	for (i = 1; i < vidmodecount; i++) {
	    if (allmodes[i]->hdisplay >= current_width
		&& allmodes[i]->vdisplay >= current_height
		&& allmodes[i]->hdisplay <= allmodes[best]->hdisplay
		&& allmodes[i]->vdisplay <= allmodes[best]->vdisplay)
		best = i;
	}
	write_log ("entering DGA mode: %dx%d (%d, %d)\n",
		allmodes[best]->hdisplay, allmodes[best]->vdisplay,
		current_width, current_height);
	XF86VidModeSwitchToMode (display, screen, allmodes[best]);
	XF86VidModeSetViewPort (display, screen, 0, 0);
    }
#endif
    XMoveWindow (display, mywin, 0, 0);
    XWarpPointer (display, None, rootwin, 0, 0, 0, 0, 0, 0);
    XF86DGADirectVideo (display, screen, XF86DGADirectGraphics | XF86DGADirectMouse | XF86DGADirectKeyb);
    XF86DGASetViewPort (display, screen, 0, 0);
    memset (fb_addr, 0, (w * h) * (d / 8));
}
Exemplo n.º 13
0
// We use this to detect if we should enable masking or not.
// This is really important because if a user tries to screenshot a window that's
// slightly off-screen he probably wants the whole window, but if a user
// takes a full screenshot, then he would most certainly want it masked, but
// only if they have pixels that are offscreen.
bool checkMask( std::string type, int x, int y, int w, int h, Window id ) {
    if ( type == "auto" ) {
        // If we specified an actual window we certainly don't want to mask anything.
        if ( id != None && id != xengine->m_root ) {
            return false;
        }
        const int sw = WidthOfScreen( xengine->m_screen );
        const int sh = HeightOfScreen( xengine->m_screen );
        // First we check if there's even any offscreen pixels
        int monitorArea = 0;
        std::vector<XRRCrtcInfo*> monitors = xengine->getCRTCS();
        for ( unsigned int i = 0;i<monitors.size();i++ ) {
            XRRCrtcInfo* cmonitor = monitors[ i ];
            monitorArea += cmonitor->height * cmonitor->width;
        }
        xengine->freeCRTCS( monitors );
        // If our monitors cover the entire screen, masking won't do anything anyway.
        if ( monitorArea >= sw * sh ) {
            return false;
        }
        // If our screenshot has > 80% of the screen covered, we probably want it masked by off-screen pixels.
        if ( abs( (int)( (float)sw - (float)w ) ) / (float)sw < 0.2 &&
             abs( (int)( (float)sh - (float)h ) ) / (float)sh < 0.2 &&
             (float)x / (float)sw < 0.2 &&
             (float)y / (float)sh < 0.2 ) {
            return true;
        }
        // Otherwise we're probably taking a picture of a specific thing on the screen.
        return false;
    } else if ( type == "on" ) {
        return true;
    }
    return false;
}
Exemplo n.º 14
0
bool SpringApp::GetDisplayGeometry()
{
	SDL_SysWMinfo info;
	SDL_VERSION(&info.version);
	if (!SDL_GetWMInfo(&info)) {
		return false;
	}

	info.info.x11.lock_func();
	{
		Display* display = info.info.x11.display;
		Window   window  = info.info.x11.window;

		XWindowAttributes attrs;
		XGetWindowAttributes(display, window, &attrs);
		const Screen* screen = attrs.screen;
		gu->screenSizeX = WidthOfScreen(screen);
		gu->screenSizeY = HeightOfScreen(screen);
		gu->winSizeX = attrs.width;
		gu->winSizeY = attrs.height;

		Window tmp;
		int xp, yp;
		XTranslateCoordinates(display, window, attrs.root, 0, 0, &xp, &yp, &tmp);
		gu->winPosX = xp;
		gu->winPosY = gu->screenSizeY - gu->winSizeY - yp;
	}
	info.info.x11.unlock_func();

	return true;
}		
Exemplo n.º 15
0
/*! Open an X11 window and create a cairo surface base on that window. If x and
 * y are set to 0 the function opens a full screen window and stores to window
 * dimensions to x and y.
 * @param x Pointer to width of window.
 * @param y Pointer to height of window.
 * @return Returns a pointer to a valid Xlib cairo surface. The function does
 * not return on error (exit(3)).
 */
cairo_surface_t* 
cairo_create_x11_surface(int *x, int *y) {

   Display *dsp;
   Drawable da;
   Screen *scr;
   int screen;
   cairo_surface_t *sfc;

   if ((dsp = XOpenDisplay(NULL)) == NULL)
      exit(1);
   screen = DefaultScreen(dsp);
   scr = DefaultScreenOfDisplay(dsp);
   if (!*x || !*y)
   {
      *x = WidthOfScreen(scr), *y = HeightOfScreen(scr);
      da = XCreateSimpleWindow(dsp, DefaultRootWindow(dsp), 0, 0, *x, *y, 0, 0, 0);
      fullscreen (dsp, da);
   }
   else
      da = XCreateSimpleWindow(dsp, DefaultRootWindow(dsp), 0, 0, *x, *y, 0, 0, 0);
   XSelectInput(dsp, da, ButtonPressMask | KeyPressMask);
   XMapWindow(dsp, da);

   sfc = cairo_xlib_surface_create(dsp, da, DefaultVisual(dsp, screen), *x, *y);
   cairo_xlib_surface_set_size(sfc, *x, *y);

   return sfc;
}
Exemplo n.º 16
0
void
ChooseSession(void)
{
    Dimension   width, height;
    Position	x, y;


    /*
     * Add the session names to the list
     */

    AddSessionNames (sessionNameCount, sessionNamesLong);


    /*
     * Center popup containing choice of sessions
     */
    
    XtRealizeWidget (chooseSessionPopup);

    XtVaGetValues (chooseSessionPopup,
	XtNwidth, &width,
	XtNheight, &height,
	NULL);

    x = (Position)(WidthOfScreen (XtScreen (topLevel)) - width) / 2;
    y = (Position)(HeightOfScreen (XtScreen (topLevel)) - height) / 3;

    XtVaSetValues (chooseSessionPopup,
	XtNx, x,
	XtNy, y,
	NULL);

    XtVaSetValues (chooseSessionListWidget,
	XtNlongest, width,
	NULL);

    XtVaSetValues (chooseSessionLabel,
	XtNwidth, width,
	NULL);

    XtVaGetValues (chooseSessionMessageLabel,
	XtNforeground, &save_message_foreground,
	XtNbackground, &save_message_background,
	NULL);

    XtVaSetValues (chooseSessionMessageLabel,
	XtNwidth, width,
	XtNforeground, save_message_background,
	NULL);

    /*
     * Wait for a map notify on the popup, then set input focus.
     */

    XtAddEventHandler (chooseSessionPopup, StructureNotifyMask, False,
	ChooseWindowStructureNotifyXtHandler, NULL);

    XtPopup (chooseSessionPopup, XtGrabNone);
}
int main(void)
{
	Display *dpy;
	int width, height, fd;
	unsigned int attachments[] = {
		DRI2BufferBackLeft,
		DRI2BufferFrontLeft,
	};

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

	fd = dri2_open(dpy);
	if (fd < 0)
		return 1;

	width = WidthOfScreen(DefaultScreenOfDisplay(dpy));
	height = HeightOfScreen(DefaultScreenOfDisplay(dpy));
	run(dpy, width, height, attachments, 1, "fullscreen");
	run(dpy, width, height, attachments, 2, "fullscreen (with front)");

	width /= 2;
	height /= 2;
	run(dpy, width, height, attachments, 1, "windowed");
	run(dpy, width, height, attachments, 2, "windowed (with front)");

	return 0;
}
Exemplo n.º 18
0
void
_gdk_x11_screen_get_edge_monitors (GdkX11Screen *x11_screen,
                                   gint      *top,
                                   gint      *bottom,
                                   gint      *left,
                                   gint      *right)
{
#ifdef HAVE_XFREE_XINERAMA
  gint          top_most_pos = HeightOfScreen (x11_screen->xscreen);
  gint          left_most_pos = WidthOfScreen (x11_screen->xscreen);
  gint          bottom_most_pos = 0;
  gint          right_most_pos = 0;
  gint          i;
  XineramaScreenInfo *x_monitors;
  int x_n_monitors;
#endif

  *top = *bottom = *left = *right = -1;

#ifdef HAVE_XFREE_XINERAMA
  if (!XineramaIsActive (x11_screen->xdisplay))
    return;

  x_monitors = XineramaQueryScreens (x11_screen->xdisplay, &x_n_monitors);
  if (x_n_monitors <= 0 || x_monitors == NULL)
    {
      if (x_monitors)
        XFree (x_monitors);

      return;
    }

  for (i = 0; i < x_n_monitors; i++)
    {
      if (left && left_most_pos > x_monitors[i].x_org)
	{
	  left_most_pos = x_monitors[i].x_org;
	  *left = i;
	}
      if (right && right_most_pos < x_monitors[i].x_org + x_monitors[i].width)
	{
	  right_most_pos = x_monitors[i].x_org + x_monitors[i].width;
	  *right = i;
	}
      if (top && top_most_pos > x_monitors[i].y_org)
	{
	  top_most_pos = x_monitors[i].y_org;
	  *top = i;
	}
      if (bottom && bottom_most_pos < x_monitors[i].y_org + x_monitors[i].height)
	{
	  bottom_most_pos = x_monitors[i].y_org + x_monitors[i].height;
	  *bottom = i;
	}
    }

  XFree (x_monitors);
#endif
}
Exemplo n.º 19
0
int main(int argc, char * argv[]) {
	Window root;
	Display * display;
	XEvent xev;
	int screenWidth;
	int screenHeight;

	display = XOpenDisplay(NULL);
	if (display == NULL) {
		if (debug) printf("Could not open display\n");
		return 1;
	}

	root = DefaultRootWindow(display);
	screenWidth = WidthOfScreen(DefaultScreenOfDisplay(display));
	screenHeight = HeightOfScreen(DefaultScreenOfDisplay(display));
	if (debug) printf("Screen width: %i\n", screenWidth);
	if (debug) printf("Screen height: %i\n", screenHeight);

	XAllowEvents(display, AsyncBoth, CurrentTime);

	bool go = true;

	// We grab
	XGrabButton(display, AnyButton, AnyModifier, root, true, ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None);

	while (go) {
		XNextEvent(display, &xev);

		switch(xev.type) {
			case ButtonPress:
				if (debug) printf("Button press - %i\n", xev.xbutton.button);
				if (debug) printf("Coordinates - %i, %i\n", xev.xbutton.x, xev.xbutton.y);
			break;

			case ButtonRelease:
				if (debug) printf("Button release - %i\n", xev.xbutton.button);
				if (xev.xbutton.y>screenHeight-400)
					// If we touch on the bottom side of the screen, we go to the next page
					pageForward(display);
				else if (xev.xbutton.x>screenWidth-200 && xev.xbutton.y<200)
					// If we touch the upper right corner, we quit
					go = false;
				else
					// If touched anywhere else let's apply a simple touch where we are
					// It's not perfect, because it will disable gestures
					SendMouseEvent(display, Button1, xev.xbutton.x, xev.xbutton.y, true);
					usleep(10000);
					SendMouseEvent(display, Button1, xev.xbutton.x, xev.xbutton.y, false);
			break;
		}
	}

	XUngrabButton(display, AnyButton, AnyModifier, root);

	XCloseDisplay(display);

	return 0;
}
Exemplo n.º 20
0
static void
compute_mag_pos(int *xp, int *yp)
{
    int t;

    t = mag_x + main_x - magnifier.width / 2;
    if (t > WidthOfScreen(SCRN) - (int)magnifier.width - 2 * MAGBORD)
	t = WidthOfScreen(SCRN) - (int)magnifier.width - 2 * MAGBORD;
    if (t < 0)
	t = 0;
    *xp = t;
    t = mag_y + main_y - magnifier.height / 2;
    if (t > HeightOfScreen(SCRN) - (int)magnifier.height - 2 * MAGBORD)
	t = HeightOfScreen(SCRN) - (int)magnifier.height - 2 * MAGBORD;
    if (t < 0)
	t = 0;
    *yp = t;
}
Exemplo n.º 21
0
static cairo_bool_t
_cairo_boilerplate_xlib_check_screen_size (Display *dpy,
					   int	    screen,
					   int	    width,
					   int	    height)
{
    Screen *scr = XScreenOfDisplay (dpy, screen);
    return width <= WidthOfScreen (scr) && height <= HeightOfScreen (scr);
}
Exemplo n.º 22
0
int main ( int argc , char **argv )
/************************************************************************
 * main			             				   	*
 *								   	*
 * Main program for ncolor.	             			   	*
 *								   	*
 * main ( argc, argv )							*
 * Input paramaters:							*
 *  argc	int	number of input arguments			*
 *  **argv	char	input arguments					*
 * 									*
 * Output paramaters:							*
 *  NONE								*
 **									*
 * Log:								   	*
 * E. Safford/GSC	12/98	initial coding				*
 * T. Piper/SAIC	05/03	removed proto_ncolor.h			*
 * T. Piper/SAIC	07/03	removed unnecessary xwcmn.h		*
 ***********************************************************************/
{
Widget		top_level;
XtAppContext 	app;
Screen		*screen;
/*---------------------------------------------------------------------*/

    top_level = XtAppInitialize( &app, RESOURCE_FILE, NULL, 0,
                        &argc, argv, NULL, NULL, 0);

    screen = XtScreen(top_level);

    XtVaSetValues (top_level, 
		XmNminWidth,		625,
  		XmNx,			90,	
  		XmNy,		 	HeightOfScreen(screen) - 25,	
		NULL); 

/*
 * check resource file
 */
    NxmRes_check(XtDisplay(top_level), RESOURCE_FILE, NULL);

/*
 * initialize GEMPAK variables
 */
    if ( NxmGmpkInit(top_level, 2, NULL ) != 0 ) {
	exit(1);
    }

    ncolor_create(top_level); 
    XtRealizeWidget(top_level);

    NxmGmpkRgstr(top_level, "ncolor", NULL);
    XtAppMainLoop(app);

    return(0);
} 
Exemplo n.º 23
0
static void
FitMenuOnScreen(Widget menu, XtPointer client, XtPointer call)
{
    if (XtHeight(menu) > HeightOfScreen(XtScreen(menu)))
    {
    int height;
    short numColumns;

    	XtVaGetValues(menu,
    		XmNnumColumns, &numColumns,
    		NULL);
	height = XtHeight(menu) * numColumns;
	numColumns = (height / HeightOfScreen(XtScreen(menu))) + 1;
    	XtVaSetValues(menu,
    		XmNnumColumns, numColumns,
    		XmNpacking, XmPACK_COLUMN,
    		NULL);
    }
}
Exemplo n.º 24
0
int main( int   argc,
          char *argv[] )
{
    FILE *dev	;
    overlay_t *ov;
    Screen *xscrn;
    
    dpy = XOpenDisplay (NULL);
    if (!dpy) _exit(1);

    xscrn=ScreenOfDisplay(dpy, 0);
    xsize=WidthOfScreen(xscrn)/NUM_MONITORS;
    ysize=HeightOfScreen(xscrn);
    depth=PlanesOfScreen(xscrn);
    fprintf(stderr, "Width: %d, Height: %d, Depth: "
	    "%d\n", xsize, ysize, depth);

    AllBlackButInit();

    if(!(dev=fopen("/dev/em8300-0", "r")))
        {
	    const gchar *errstr = g_strerror(errno);
	    perror("Could not open /dev/em8300-0 for reading");
	    AllBlackButClose();
	    gtk_init(&argc, &argv);
	    GtkWidget *dialog = gtk_message_dialog_new(
		NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
		"Could not open EM8300 device for reading.\n\n"
		"Make sure the hardware is present, modules are "
		"loaded, and you have read permissions to the "
		"device.\n\nThe error was: /dev/em8300-0: %s", errstr);
	    gtk_window_set_title(GTK_WINDOW(dialog),
		"Autocal: Exiting with error");
	    gtk_dialog_run(GTK_DIALOG(dialog));
	    gtk_widget_destroy(dialog);
	    _exit(-1);
        }

    ov = overlay_init(dev);

    overlay_set_screen(ov,xsize,ysize,depth);

    overlay_read_state(ov,NULL);

    overlay_autocalibrate(ov, pattern_draw, NULL);

    overlay_write_state(ov,NULL);
    
    overlay_release(ov);

    fclose(dev);    

    AllBlackButClose();
    return 0;
}
Exemplo n.º 25
0
static gboolean
init_fake_xinerama (GdkScreen *screen)
{
#ifdef G_ENABLE_DEBUG
  GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
  XSetWindowAttributes atts;
  Window win;
  gint w, h;

  if (!(_gdk_debug_flags & GDK_DEBUG_XINERAMA))
    return FALSE;
  
  /* Fake Xinerama mode by splitting the screen into 4 monitors.
   * Also draw a little cross to make the monitor boundaries visible.
   */
  w = WidthOfScreen (x11_screen->xscreen);
  h = HeightOfScreen (x11_screen->xscreen);

  x11_screen->n_monitors = 4;
  x11_screen->monitors = g_new0 (GdkX11Monitor, 4);
  init_monitor_geometry (&x11_screen->monitors[0], 0, 0, w / 2, h / 2);
  init_monitor_geometry (&x11_screen->monitors[1], w / 2, 0, w / 2, h / 2);
  init_monitor_geometry (&x11_screen->monitors[2], 0, h / 2, w / 2, h / 2);
  init_monitor_geometry (&x11_screen->monitors[3], w / 2, h / 2, w / 2, h / 2);
  
  atts.override_redirect = 1;
  atts.background_pixel = WhitePixel(GDK_SCREEN_XDISPLAY (screen), 
				     x11_screen->screen_num);
  win = XCreateWindow(GDK_SCREEN_XDISPLAY (screen), 
		      x11_screen->xroot_window, 0, h / 2, w, 1, 0, 
		      DefaultDepth(GDK_SCREEN_XDISPLAY (screen), 
				   x11_screen->screen_num),
		      InputOutput, 
		      DefaultVisual(GDK_SCREEN_XDISPLAY (screen), 
				    x11_screen->screen_num),
		      CWOverrideRedirect|CWBackPixel, 
		      &atts);
  XMapRaised(GDK_SCREEN_XDISPLAY (screen), win); 
  win = XCreateWindow(GDK_SCREEN_XDISPLAY (screen), 
		      x11_screen->xroot_window, w/2 , 0, 1, h, 0, 
		      DefaultDepth(GDK_SCREEN_XDISPLAY (screen), 
				   x11_screen->screen_num),
		      InputOutput, 
		      DefaultVisual(GDK_SCREEN_XDISPLAY (screen), 
				    x11_screen->screen_num),
		      CWOverrideRedirect|CWBackPixel, 
		      &atts);
  XMapRaised(GDK_SCREEN_XDISPLAY (screen), win);
  return TRUE;
#endif
  
  return FALSE;
}
Exemplo n.º 26
0
int BC_DisplayInfo::get_root_h()
{
#ifdef SINGLE_THREAD
	BC_Display::lock_display("BC_DisplayInfo::get_root_h");
#endif
	Screen *screen_ptr = XDefaultScreenOfDisplay(display);
	int result = HeightOfScreen(screen_ptr);
#ifdef SINGLE_THREAD
	BC_Display::unlock_display();
#endif
	return result;
}
Exemplo n.º 27
0
// origin for our coordinates is the bottom left corner
bool SpringApp::GetDisplayGeometry()
{
	SDL_SysWMinfo info;
	SDL_VERSION(&info.version);

	if (!SDL_GetWMInfo(&info)) {
		return false;
	}

#ifndef _WIN32
	info.info.x11.lock_func();
	{
		Display* display = info.info.x11.display;
		Window   window  = info.info.x11.window;

		XWindowAttributes attrs;
		XGetWindowAttributes(display, window, &attrs);
		const Screen* screen = attrs.screen;
		gu->screenSizeX = WidthOfScreen(screen);
		gu->screenSizeY = HeightOfScreen(screen);
		gu->winSizeX = attrs.width;
		gu->winSizeY = attrs.height;

		Window tmp;
		int xp, yp;
		XTranslateCoordinates(display, window, attrs.root, 0, 0, &xp, &yp, &tmp);
		gu->winPosX = xp;
		gu->winPosY = gu->screenSizeY - gu->winSizeY - yp;
	}
	info.info.x11.unlock_func();
#else
	gu->screenSizeX = GetSystemMetrics(SM_CXFULLSCREEN);
	gu->screenSizeY = GetSystemMetrics(SM_CYFULLSCREEN);

	RECT rect;
	if (!GetClientRect(info.window, &rect)) {
		return false;
	}

	if((rect.right - rect.left)==0 || (rect.bottom - rect.top)==0)
		return false;

	gu->winSizeX = rect.right - rect.left;
	gu->winSizeY = rect.bottom - rect.top;

	// translate from client coords to screen coords
	MapWindowPoints(info.window, HWND_DESKTOP, (LPPOINT)&rect, 2);
	gu->winPosX = rect.left;
	gu->winPosY = gu->screenSizeY - gu->winSizeY - rect.top;
#endif // _WIN32
	return true;
}
Exemplo n.º 28
0
void 
cid_get_X_infos (void) 
{
    s_XDisplay = XOpenDisplay (0);
    
    XSetErrorHandler (_cid_xerror_handler);
    
    Screen *XScreen = XDefaultScreenOfDisplay (s_XDisplay);
    cid->XScreenWidth  = WidthOfScreen (XScreen);
    cid->XScreenHeight = HeightOfScreen (XScreen);
    
    //g_print ("%dx%d\n",XScreenWidth,XScreenHeight);
}
Exemplo n.º 29
0
/* center a popup */
void centerMe (Widget w, XtPointer unused, XmAnyCallbackStruct *cbs) {
    Dimension width, height;
    Position x, y;

    XtVaGetValues (w, XmNx, &x, XmNy, &y, NULL);

    x = (Position) WidthOfScreen(XtScreen(w)) / 2;
    y = (Position) HeightOfScreen(XtScreen(w)) / 2;
    XtVaGetValues (w, XmNwidth, &width, XmNheight, &height, NULL);
    x -= width/2;
    y -= height/2;
    XtVaSetValues (w, XmNx, x, XmNy, y, NULL);
}
Exemplo n.º 30
0
void xf_create_window(xfInfo* xfi)
{
	XEvent xevent;
	char* title;
	char* hostname;
	int width, height;

	width = xfi->width;
	height = xfi->height;

	xfi->attribs.background_pixel = BlackPixelOfScreen(xfi->screen);
	xfi->attribs.border_pixel = WhitePixelOfScreen(xfi->screen);
	xfi->attribs.backing_store = xfi->primary ? NotUseful : Always;
	xfi->attribs.override_redirect = xfi->fullscreen;
	xfi->attribs.colormap = xfi->colormap;

	if (xfi->remote_app != True)
	{
		if (xfi->fullscreen)
		{
			width = xfi->fullscreen ? WidthOfScreen(xfi->screen) : xfi->width;
			height = xfi->fullscreen ? HeightOfScreen(xfi->screen) : xfi->height;
		}

		hostname = xfi->instance->settings->hostname;
		title = xmalloc(sizeof("FreeRDP: ") + strlen(hostname));
		sprintf(title, "FreeRDP: %s", hostname);

		xfi->window = xf_CreateDesktopWindow(xfi, title, width, height, xfi->decorations);
		xfree(title);

		if (xfi->fullscreen)
			xf_SetWindowFullscreen(xfi, xfi->window, xfi->fullscreen);

		/* wait for VisibilityNotify */
		do
		{
			XMaskEvent(xfi->display, VisibilityChangeMask, &xevent);
		}
		while (xevent.type != VisibilityNotify);

		xfi->unobscured = (xevent.xvisibility.state == VisibilityUnobscured);

		XSetWMProtocols(xfi->display, xfi->window->handle, &(xfi->WM_DELETE_WINDOW), 1);
		xfi->drawable = xfi->window->handle;
	}
	else
	{
		xfi->drawable = DefaultRootWindow(xfi->display);
	}
}