コード例 #1
0
ファイル: wmtools.c プロジェクト: Acidburn0zzz/crouton
int raiseWindow(Display *display, Window window) {
    Window parent, root, *children, *neworder;
    unsigned int nchildren, i, rotate;
    XWindowAttributes attr;

    if (!XQueryTree(display, DefaultRootWindow(display), &root, &parent,
                   &children, &nchildren))
        return 1;
    if (!children)
        return 2;

    for (rotate = 0; rotate < nchildren; ++rotate) {
        if (children[nchildren-1 - rotate] == window)
            break;
    }
    if (rotate == nchildren) {
        XFree(children);
        return 2;
    }

    if (rotate > 0) {
        /* Unmap and remap the old top-level window to kill off any mouse and
         * keyboard hooks */
        XUnmapWindow(display, children[nchildren-1]);

        neworder = (Window*)malloc(nchildren * sizeof(*neworder));
        /* XQueryTree returns children in back-to-front order, while
         * XRestackWindows takes a front-to-back list. Reverse the order and
         * rotate the position of the children -n positions to put the requested
         * window into the first position in the list.
         */
        for (i = 0; i < nchildren; ++i) {
            neworder[nchildren-1 - ((i+rotate) % nchildren)] = children[i];
        }
        XRestackWindows(display, neworder, nchildren);
        free(neworder);

        /* Split the map from the unmap to reduce the number of events */
        XMapWindow(display, children[nchildren-1]);
    }
    XFree(children);

    if (!XGetWindowAttributes(display, DefaultRootWindow(display), &attr)) {
        return 1;
    }
    /* Twiddle the width of the window to force a full refresh */
    XMoveResizeWindow(display, window,
                      attr.x, attr.y, attr.width-1, attr.height);
    XMoveResizeWindow(display, window,
                      attr.x, attr.y, attr.width,   attr.height);

    return 0;
}
コード例 #2
0
ファイル: screen.c プロジェクト: guns/subtle
void
subScreenResize(void)
{
  int i;

  assert(subtle);

  /* Update screens */
  for(i = 0; i < subtle->screens->ndata; i++)
    {
      SubScreen *s = SCREEN(subtle->screens->data[i]);

      /* Add strut */
      s->geom.x      = s->base.x + subtle->styles.subtle.padding.left;
      s->geom.y      = s->base.y + subtle->styles.subtle.padding.top;
      s->geom.width  = s->base.width - subtle->styles.subtle.padding.left -
        subtle->styles.subtle.padding.right;
      s->geom.height = s->base.height - subtle->styles.subtle.padding.top -
        subtle->styles.subtle.padding.bottom;

      /* Update panels */
      if(s->flags & SUB_SCREEN_PANEL1)
        {
          XMoveResizeWindow(subtle->dpy, s->panel1, s->base.x, s->base.y,
            s->base.width, subtle->ph);
          XMapRaised(subtle->dpy, s->panel1);

          /* Update height */
          s->geom.y      += subtle->ph;
          s->geom.height -= subtle->ph;
        }
      else XUnmapWindow(subtle->dpy, s->panel1);

      if(s->flags & SUB_SCREEN_PANEL2)
        {
          XMoveResizeWindow(subtle->dpy, s->panel2, s->base.x,
            s->base.y + s->base.height - subtle->ph, s->base.width, subtle->ph);
          XMapRaised(subtle->dpy, s->panel2);

          /* Update height */
          s->geom.height -= subtle->ph;
        }
      else XUnmapWindow(subtle->dpy, s->panel2);

      /* Create/update drawable for double buffering */
      if(s->drawable) XFreePixmap(subtle->dpy, s->drawable);
      s->drawable = XCreatePixmap(subtle->dpy, ROOT, s->base.width, subtle->ph,
        XDefaultDepth(subtle->dpy, DefaultScreen(subtle->dpy)));
    }

  ScreenPublish();
} /* }}} */
コード例 #3
0
ファイル: panel.c プロジェクト: o9000/tint2
void set_panel_window_geometry(Panel *panel)
{
	update_strut(panel);

	// Fixed position and non-resizable window
	// Allow panel move and resize when tint2 reload config file
	int minwidth = panel_autohide ? panel->hidden_width : panel->area.width;
	int minheight = panel_autohide ? panel->hidden_height : panel->area.height;
	XSizeHints size_hints;
	size_hints.flags = PPosition | PMinSize | PMaxSize;
	size_hints.min_width = minwidth;
	size_hints.max_width = panel->area.width;
	size_hints.min_height = minheight;
	size_hints.max_height = panel->area.height;
	XSetWMNormalHints(server.display, panel->main_win, &size_hints);

	if (!panel->is_hidden) {
		if (panel_horizontal) {
			XMoveResizeWindow(server.display,
			                  panel->main_win,
			                  panel->posx,
			                  panel->posy,
			                  panel->area.width,
			                  panel->area.height);
		} else {
			XMoveResizeWindow(server.display,
			                  panel->main_win,
			                  panel->posx,
			                  panel->posy,
			                  panel->area.width,
			                  panel->area.height);
		}
	} else {
		int diff = (panel_horizontal ? panel->area.height : panel->area.width) - panel_autohide_height;
		if (panel_horizontal) {
			XMoveResizeWindow(server.display,
			                  panel->main_win,
			                  panel->posx,
			                  panel->posy + diff,
			                  panel->hidden_width,
			                  panel->hidden_height);
		} else {
			XMoveResizeWindow(server.display,
			                  panel->main_win,
			                  panel->posx + diff,
			                  panel->posy,
			                  panel->hidden_width,
			                  panel->hidden_height);
		}
	}
}
コード例 #4
0
ファイル: xrama.c プロジェクト: BioinformaticsArchive/GromPy
static void size_app(t_x11 *x11,t_app *app)
{
  int i,dx,th;

  th=XTextHeight(x11->font)+4;
  dx=app->wd.width/ebutNR;
  for(i=0; (i<ebutNR); i++) {
    app->but[i].width=dx-4;
    app->but[i].height=th+4;
    XMoveResizeWindow(x11->disp,app->but[i].self,i*dx+2,2,dx-4,th+4);
  }
  XMoveResizeWindow(x11->disp,app->xrwd.self,2,th+10,
		    app->wd.width-6,app->wd.height-th-10-4);
}
コード例 #5
0
ファイル: tkUnixEmbed.c プロジェクト: afmayer/tcl-tk
static void
EmbedStructureProc(
    ClientData clientData,	/* Token for container window. */
    XEvent *eventPtr)		/* ResizeRequest event. */
{
    Container *containerPtr = clientData;
    Tk_ErrorHandler errHandler;

    if (eventPtr->type == ConfigureNotify) {
	if (containerPtr->wrapper != None) {
	    /*
	     * Ignore errors, since the embedded application could have
	     * deleted its window.
	     */

	    errHandler = Tk_CreateErrorHandler(eventPtr->xfocus.display, -1,
		    -1, -1, NULL, NULL);
	    XMoveResizeWindow(eventPtr->xconfigure.display,
		    containerPtr->wrapper, 0, 0,
		    (unsigned) Tk_Width((Tk_Window) containerPtr->parentPtr),
		    (unsigned) Tk_Height((Tk_Window) containerPtr->parentPtr));
	    Tk_DeleteErrorHandler(errHandler);
	}
    } else if (eventPtr->type == DestroyNotify) {
	EmbedWindowDeleted(containerPtr->parentPtr);
    }
}
コード例 #6
0
ファイル: xf_window.c プロジェクト: byteboon/FreeRDP
void xf_MoveWindow(xfContext* xfc, xfAppWindow* appWindow, int x, int y,
                   int width, int height)
{
	BOOL resize = FALSE;

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

	if ((appWindow->width != width) || (appWindow->height != height))
		resize = TRUE;

	if (appWindow->local_move.state == LMS_STARTING ||
	    appWindow->local_move.state == LMS_ACTIVE)
		return;

	appWindow->x = x;
	appWindow->y = y;
	appWindow->width = width;
	appWindow->height = height;

	if (resize)
		XMoveResizeWindow(xfc->display, appWindow->handle, x, y, width, height);
	else
		XMoveWindow(xfc->display, appWindow->handle, x, y);

	xf_UpdateWindowArea(xfc, appWindow, 0, 0, width, height);
}
コード例 #7
0
ファイル: window.cpp プロジェクト: nickbp/gridmgr
bool ActiveWindow::MoveResize(const Dimensions& activewin) {
    if (!init()) {
        return false;
    }

    unsigned int margin_width, margin_height;
    if (!get_window_size(disp, *win, NULL, &margin_width, &margin_height)) {
        return false;
    }

    //demaximize the window before attempting to move it
    if (!maximize_window(disp, *win, false)) {
        ERROR("couldn't demaximize");
        //disregard failure
    }

    unsigned long new_interior_width = activewin.width - margin_width,
        new_interior_height = activewin.height - margin_height;

    //moveresize uses exterior for position, but interior for width/height
    DEBUG("%ldx %ldy %luw %luh - margins %dw %dh = %ldx %ldy %luw %luh",
            activewin.x, activewin.y, activewin.width, activewin.height,
            margin_width, margin_height,
            activewin.x, activewin.y, new_interior_width, new_interior_height);

    if (XMoveResizeWindow(disp, *win, activewin.x, activewin.y,
                    new_interior_width, new_interior_height) == 0) {
        ERROR("MoveResize to %ldx %ldy %luw %luh failed.",
                activewin.x, activewin.y, new_interior_width, new_interior_height);
        return false;
    }
    return true;
}
コード例 #8
0
ファイル: XViewport.cpp プロジェクト: wrstone/ut432pubsrc
//
// Open this viewport's window.
//
void UXViewport::OpenWindow( DWORD InParentWindow, UBOOL IsTemporary, INT NewX, INT NewY, INT OpenX, INT OpenY )
{
	guard(UXViewport::OpenWindow);
	check(Actor);
	check(!HoldCount);
	UXClient* C = GetOuterUXClient();

	if (!XWindow)
		return;

	debugf( TEXT("Opening X viewport.") );

	// Create or update the window.
	SizeX = C->FullscreenViewportX;
	SizeY = C->FullscreenViewportY;
	if (!Mapped)
	{
		XMoveResizeWindow( XDisplay, XWindow, 0, 0, SizeX, SizeY );
		XMapWindow( XDisplay, XWindow );
	}

	// Create rendering device.
	if( !RenDev && !GIsEditor && !ParseParam(appCmdLine(),TEXT("nohard")) )
		TryRenderDevice( TEXT("ini:Engine.Engine.GameRenderDevice"), NewX, NewY, ColorBytes, C->StartupFullscreen );
	check(RenDev);
	UpdateWindowFrame();
	Repaint( 1 );

	unguard;
}
コード例 #9
0
ファイル: clientwin.c プロジェクト: mozeq/skippy-xd
void
clientwin_move(ClientWin *cw, float f, int x, int y)
{
	/* int border = MAX(1, (double)DISTANCE(cw->mainwin) * f * 0.25); */
	int border = 0;
	XSetWindowBorderWidth(cw->mainwin->dpy, cw->mini.window, border);
	
	cw->factor = f;
	cw->mini.x = x + (int)cw->x * f;
	cw->mini.y = y + (int)cw->y * f;
	if(cw->mainwin->lazy_trans)
	{
		cw->mini.x += cw->mainwin->x;
		cw->mini.y += cw->mainwin->y;
	}
	cw->mini.width = MAX(1, (int)cw->client.width * f);
	cw->mini.height = MAX(1, (int)cw->client.height * f);
	XMoveResizeWindow(cw->mainwin->dpy, cw->mini.window, cw->mini.x - border, cw->mini.y - border, cw->mini.width, cw->mini.height);
	
	if(cw->pixmap)
		XFreePixmap(cw->mainwin->dpy, cw->pixmap);
	
	if(cw->destination)
		XRenderFreePicture(cw->mainwin->dpy, cw->destination);
	
	cw->pixmap = XCreatePixmap(cw->mainwin->dpy, cw->mini.window, cw->mini.width, cw->mini.height, cw->mainwin->depth);
	XSetWindowBackgroundPixmap(cw->mainwin->dpy, cw->mini.window, cw->pixmap);
	
	cw->destination = XRenderCreatePicture(cw->mainwin->dpy, cw->pixmap, cw->mini.format, 0, 0);
}
コード例 #10
0
ファイル: fg_window_x11.c プロジェクト: LosingLin/regal
static int fghResizeFullscrToggle(void)
{
    XWindowAttributes attributes;
    SFG_Window *win = fgStructure.CurrentWindow;

    if(glutGet(GLUT_FULL_SCREEN)) {
        /* restore original window size */
        fgStructure.CurrentWindow->State.WorkMask = GLUT_SIZE_WORK;
        fgStructure.CurrentWindow->State.DesiredWidth  = win->State.pWState.OldWidth;
        fgStructure.CurrentWindow->State.DesiredHeight = win->State.pWState.OldHeight;

    } else {
        fgStructure.CurrentWindow->State.pWState.OldWidth  = win->State.Width;
        fgStructure.CurrentWindow->State.pWState.OldHeight = win->State.Height;

        /* resize the window to cover the entire screen */
        XGetWindowAttributes(fgDisplay.pDisplay.Display,
                fgStructure.CurrentWindow->Window.Handle,
                &attributes);
        
        /*
         * The "x" and "y" members of "attributes" are the window's coordinates
         * relative to its parent, i.e. to the decoration window.
         */
        XMoveResizeWindow(fgDisplay.pDisplay.Display,
                fgStructure.CurrentWindow->Window.Handle,
                -attributes.x,
                -attributes.y,
                fgDisplay.ScreenWidth,
                fgDisplay.ScreenHeight);
    }
    return 0;
}
コード例 #11
0
int
window_move_resize( Display * disp, Window win, char *arg )
{                               /*{{{ */
  signed long grav, x, y, w, h;
  unsigned long grflags;
  const char *argerr = "The -e option expects a list of comma separated integers: \"gravity,X,Y,width,height\"\n";

  if ( !arg || strlen( arg ) == 0 )
  {
    fputs( argerr, stderr );
    return EXIT_FAILURE;
  }

  if ( sscanf( arg, "%ld,%ld,%ld,%ld,%ld", &grav, &x, &y, &w, &h ) != 5 )
  {
    fputs( argerr, stderr );
    return EXIT_FAILURE;
  }

  if ( grav < 0 )
  {
    fputs( "Value of gravity mustn't be negative. Use zero to use the default gravity of the window.\n", stderr );
    return EXIT_FAILURE;
  }

  grflags = grav;
  if ( x != -1 )
    grflags |= ( 1 << 8 );
  if ( y != -1 )
    grflags |= ( 1 << 9 );
  if ( w != -1 )
    grflags |= ( 1 << 10 );
  if ( h != -1 )
    grflags |= ( 1 << 11 );

  p_verbose( "grflags: %lu\n", grflags );

  if ( wm_supports( disp, "_NET_MOVERESIZE_WINDOW" ) )
  {
    return client_msg( disp, win, "_NET_MOVERESIZE_WINDOW",
                       grflags, ( unsigned long ) x, ( unsigned long ) y, ( unsigned long ) w, ( unsigned long ) h );
  }
  else
  {
    p_verbose( "WM doesn't support _NET_MOVERESIZE_WINDOW. Gravity will be ignored.\n" );
    if ( ( w < 1 || h < 1 ) && ( x >= 0 && y >= 0 ) )
    {
      XMoveWindow( disp, win, x, y );
    }
    else if ( ( x < 0 || y < 0 ) && ( w >= 1 && h >= -1 ) )
    {
      XResizeWindow( disp, win, w, h );
    }
    else if ( x >= 0 && y >= 0 && w >= 1 && h >= 1 )
    {
      XMoveResizeWindow( disp, win, x, y, w, h );
    }
    return EXIT_SUCCESS;
  }
}
コード例 #12
0
ファイル: size_and_stack.c プロジェクト: tommed/tuxwm
//
// Push this window onto the desktop-stack which will also take a new screenshot
// push_stack checks for existing stack-items and updates them, so we don't need 
// to do any checking here.
//
void handle_configure(Display *d, Window w, int screen, StateMachine *state)
{
	// make sure window isn't a "special" window
	printf("check for override-redirect\n");
	XWindowAttributes win_attribs;
	if (!XGetWindowAttributes(d, w, &win_attribs)) {
		if (win_attribs.override_redirect) {
			printf("override redirect detected, skipping reconfigure\n");
			return;
		}
	}
	
	// push onto window-stack
	printf("push window to stack\n");
	push_stack(d, w);
	
	// resize window
	printf("do wm reconfigure\n");
	XWindowChanges changes;
	int topY = state->top_screen_reserved_height + LAYOUT_MARGIN;
	changes.x = LAYOUT_MARGIN; // honour margin
	changes.y = topY; // take top panel into consideration
	changes.width = DisplayWidth(d, screen) - (2*LAYOUT_MARGIN); // honour margin
	changes.height = DisplayHeight(d, screen) - topY/*inc. top margin*/ - LAYOUT_MARGIN/*bottom margin*/;
	
	if (state->is_hidden) {
		changes.y = changes.height+1; // prevent configure event taking over from hide_windows in desktop.h
	}
	
	printf("changing window to: x=%d, y=%d, width=%d, height=%d\n", changes.x, changes.y, changes.width, changes.height);
	XMoveResizeWindow(d, w, changes.x, changes.y, changes.width, changes.height);
	XSetInputFocus(d, w, RevertToPointerRoot, CurrentTime); // set focus on create
	XFlush(d);
}
コード例 #13
0
ファイル: bar.c プロジェクト: devanstroud/ratpoison
/* Raise the bar and put it in the right spot */
static void
prepare_bar (rp_screen *s, int width, int height, int multiline)
{
  width = width < s->width ? width : s->width;
  height = height < s->height ? height : s->height;
  XMoveResizeWindow (dpy, s->bar_window,
                     bar_x (s, width), bar_y (s, height),
                     width, height);

  /* Map the bar if needed */
  if (!s->bar_is_raised)
    {
      s->bar_is_raised = BAR_IS_MESSAGE;
      if (defaults.bar_sticky && !multiline)
        XMapWindow (dpy, s->bar_window);
      else
        XMapRaised (dpy, s->bar_window);

      /* Switch to the default colormap */
      if (current_window())
	XUninstallColormap (dpy, current_window()->colormap);
      XInstallColormap (dpy, s->def_cmap);
    }

  if (multiline || !defaults.bar_sticky)
    XRaiseWindow (dpy, s->bar_window);
  XClearWindow (dpy, s->bar_window);
  XSync (dpy, False);
}
コード例 #14
0
ファイル: xlibWindow.cpp プロジェクト: ardeujho/self
void XPlatformWindow::handle_reparent_event(XEvent& event) {
  Window root;
  int x, y;
  unsigned w, h, border_width, depth;
  if (XGetGeometry(_display, event.xreparent.parent, &root, &x, &y,
                   &w, &h, &border_width, &depth) == 0) 
    return;
  int wdelta = w - width();
  // sanity check: sometimes X gives weird width
  if (wdelta < 0) {
    if (XGetGeometry(_display, event.xreparent.parent, &root, &x, &y,
                     &w, &h, &border_width, &depth) == 0) 
      return;
    wdelta = w - width();
    if (wdelta < 0) {
      return;    // just ignore if X continues to report weird width
    }
  }
  _width = width() - wdelta;
  int display_height = DisplayHeight(_display,
                                     DefaultScreen(_display));

  XMoveResizeWindow(_display, _xwindow, event.xreparent.x,
                    _display_height - h + event.xreparent.y,
                    width(), height());
  tell_platform_size_hints();
}
コード例 #15
0
ファイル: tooltip.c プロジェクト: alaricljs/tint2
void tooltip_update()
{
	if (!g_tooltip.tooltip_text) {
		tooltip_hide(0);
		return;
	}

	tooltip_update_geometry();
	if (just_shown) {
		if (!panel_horizontal)
			y -= height / 2; // center vertically
		just_shown = FALSE;
	}
	tooltip_adjust_geometry();
	XMoveResizeWindow(server.display, g_tooltip.window, x, y, width, height);

	// Stuff for drawing the tooltip
	cairo_surface_t *cs = cairo_xlib_surface_create(server.display, g_tooltip.window, server.visual, width, height);
	cairo_t *c = cairo_create(cs);
	Color bc = g_tooltip.bg->fill_color;
	Border b = g_tooltip.bg->border;
	if (server.real_transparency) {
		clear_pixmap(g_tooltip.window, 0, 0, width, height);
		draw_rect(c, b.width, b.width, width - 2 * b.width, height - 2 * b.width, b.radius - b.width / 1.571);
		cairo_set_source_rgba(c, bc.rgb[0], bc.rgb[1], bc.rgb[2], bc.alpha);
	} else {
		cairo_rectangle(c, 0., 0, width, height);
		cairo_set_source_rgb(c, bc.rgb[0], bc.rgb[1], bc.rgb[2]);
	}
	cairo_fill(c);
	cairo_set_line_width(c, b.width);
	if (server.real_transparency)
		draw_rect(c, b.width / 2.0, b.width / 2.0, width - b.width, height - b.width, b.radius);
	else
		cairo_rectangle(c, b.width / 2.0, b.width / 2.0, width - b.width, height - b.width);
	cairo_set_source_rgba(c, b.color.rgb[0], b.color.rgb[1], b.color.rgb[2], b.color.alpha);
	cairo_stroke(c);

	Color fc = g_tooltip.font_color;
	cairo_set_source_rgba(c, fc.rgb[0], fc.rgb[1], fc.rgb[2], fc.alpha);
	PangoLayout *layout = pango_cairo_create_layout(c);
	pango_layout_set_font_description(layout, g_tooltip.font_desc);
	pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
	pango_layout_set_text(layout, g_tooltip.tooltip_text, -1);
	PangoRectangle r1, r2;
	pango_layout_get_pixel_extents(layout, &r1, &r2);
	pango_layout_set_width(layout, width * PANGO_SCALE);
	pango_layout_set_height(layout, height * PANGO_SCALE);
	pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
	// I do not know why this is the right way, but with the below cairo_move_to it seems to be centered (horiz. and
	// vert.)
	cairo_move_to(c,
				  -r1.x / 2 + g_tooltip.bg->border.width + g_tooltip.paddingx,
				  -r1.y / 2 + 1 + g_tooltip.bg->border.width + g_tooltip.paddingy);
	pango_cairo_show_layout(c, layout);

	g_object_unref(layout);
	cairo_destroy(c);
	cairo_surface_destroy(cs);
}
コード例 #16
0
JNIEXPORT void JNICALL  Java_sun_awt_X11_XlibWrapper_XMoveResizeWindow
(JNIEnv *env, jclass clazz, jlong display, jlong window, jint x , jint y , jint width, jint height) {

    AWT_CHECK_HAVE_LOCK();   
    XMoveResizeWindow( (Display *) display,(Window) window,x,y,width,height);

}
コード例 #17
0
ファイル: xf_floatbar.c プロジェクト: hendwolt/FreeRDP
static void xf_floatbar_resize(xfFloatbar* floatbar, XEvent* event)
{
	int x, width, movement;
	xfContext* xfc = floatbar->xfc;
	/* calculate movement which happened on the root window */
	movement = event->xmotion.x_root - floatbar->last_motion_x_root;

	/* set x and width depending if movement happens on the left or right  */
	if (floatbar->mode == XF_FLOATBAR_MODE_RESIZE_LEFT)
	{
		x = floatbar->x + movement;
		width = floatbar->width + movement * -1;
	}
	else
	{
		x = floatbar->x;
		width = floatbar->width + movement;
	}

	/* only resize and move window if still above minimum width */
	if (FLOATBAR_MIN_WIDTH < width)
	{
		XMoveResizeWindow(xfc->display, floatbar->handle, x, 0, width, floatbar->height);
		floatbar->x = x;
		floatbar->width = width;
	}
}
コード例 #18
0
ファイル: bar.c プロジェクト: ivoarch/antiwm
void
update_window_names (screen_info *s)
{
  char str[100];		/* window names <= 99 char */
  int i;
  int width = calc_bar_width (s->font);
  a_window *cur;
  int cur_x = 5;
  if (!s->bar_is_raised) return;
  XMoveResizeWindow (dpy, s->bar_window, 
		     bar_x (s, width), bar_y (s),
		     width,
		     (FONT_HEIGHT (s->font) + BAR_PADDING * 2));
  XClearWindow (dpy, s->bar_window);
  XRaiseWindow (dpy, s->bar_window);
  if (a_window_head == NULL) return;
  for (i=0, cur = a_window_head; cur; cur = cur->next)
    {
      if (cur->state == STATE_UNMAPPED) continue;
      sprintf (str, "%d-%s", i, cur->name);
      if ( a_current_window == cur) 
	{
	  XDrawString (dpy, s->bar_window, s->bold_gc, cur_x, 
		       BAR_PADDING + s->font->max_bounds.ascent, str, strlen (str));
	}
      else
	{
	  XDrawString (dpy, s->bar_window, s->normal_gc, cur_x, 
		       BAR_PADDING + s->font->max_bounds.ascent, str, strlen (str));
	}
      cur_x += 10 + XTextWidth (s->font, str, strlen (str));
      i++;
    }
}
コード例 #19
0
ファイル: tabterm.c プロジェクト: yhhuang/tabterm
void
handle_maprequest(XEvent *evt)
{
	XMapRequestEvent * mre = &(evt->xmaprequest);
	XWindowAttributes attr;
	if (init_stage == 1) {
		init_stage = 2;
		XGetWindowAttributes(gdi.display, mre->window, &attr);

		init_tabbar(attr.width);
		the_bar.x=0; the_bar.y = attr.height;

		realize_tab_bar(gdi.mainw);

		XResizeWindow(gdi.display, gdi.mainw, attr.width,
			      attr.height + the_bar.height);
		match_size_hints(mre->window, the_bar.height);
		new_tab(mre->window);
	}
	else if(the_bar.win == mre->window) {
	}
	else {	/* it's our new child */
		XMoveResizeWindow(gdi.display, mre->window,
				  0, tab_options.tabs_on_top?the_bar.height:0,
				  gdi.width, gdi.height - the_bar.height);
		new_tab(mre->window);
	}
	XMapWindow(gdi.display, mre->window);
}
コード例 #20
0
ファイル: menus.c プロジェクト: ShadowKyogre/lunchbox
/**
@brief    This function resizes any popup menu based on the Popup_menu struct.
@return   void
**/
void 
resize_popup_menu(Display *display, struct Popup_menu *menu, struct Themes *themes) {

  const int width  = menu->inner_width  + themes->popup_menu[popup_l_edge].w + themes->popup_menu[popup_r_edge].w;
  const int height = menu->inner_height + themes->popup_menu[popup_t_edge].h + themes->popup_menu[popup_b_edge].h;

  XResizeWindow(display, menu->widgets[popup_menu_parent].widget, width, height);

  //This resizes the "base" of the popup menu.
  //A similar loop will be needed for the actual menu items but not in this function
  for(int i = popup_t_edge; i < popup_menu_parent; i++) if(themes->popup_menu[i].exists) { //popup_menu_parent already done

    int x = themes->popup_menu[i].x;
    int y = themes->popup_menu[i].y;
    int w = themes->popup_menu[i].w;
    int h = themes->popup_menu[i].h;

    //only move or resize those which are dependent on the width.
    if(x < 0  ||  y < 0  ||  w <= 0  ||  h <= 0) {
      if(x < 0)  x += width;
      if(y < 0)  y += height; 
      if(w <= 0) w += width;
      if(h <= 0) h += height;

      XMoveResizeWindow(display, menu->widgets[i].widget, x, y, w, h);
    }
  } 

  XFlush(display);
}
コード例 #21
0
ファイル: wm.c プロジェクト: jbohren-forks/skippy-xd
void
wm_set_fullscreen(Display *dpy, Window window, int x, int y, unsigned int width, unsigned int height)
{
	if(WM_PERSONALITY == WM_PERSONALITY_NETWM && NETWM_HAS_FULLSCREEN)
	{
		Atom props[6];
		CARD32 desktop = (CARD32)-1;
		
		props[0] = _NET_WM_STATE_FULLSCREEN;
		props[1] = _NET_WM_STATE_SKIP_TASKBAR;
		props[2] = _NET_WM_STATE_SKIP_PAGER;
		props[3] = _NET_WM_STATE_ABOVE;
		props[4] = _NET_WM_STATE_STICKY;
		props[5] = 0;
		XChangeProperty(dpy, window, _NET_WM_STATE, XA_ATOM, 32, PropModeReplace, (unsigned char*)props, 5);
		XChangeProperty(dpy, window, _NET_WM_DESKTOP, XA_CARDINAL, 32, PropModeReplace, (unsigned char*)&desktop, 1);
	}
	else
	{
		XSetWindowAttributes wattr;
		wattr.override_redirect = True;
		XChangeWindowAttributes(dpy, window, CWOverrideRedirect, &wattr);
		XMoveResizeWindow(dpy, window, x, y, width, height);
	}
}
コード例 #22
0
ファイル: frame.c プロジェクト: sylware/lboxwm
void frame_adjust_area(struct wm_frame *self, gboolean moved, gboolean resized, gboolean fake)
{
	if(resized) {
		self->max_horz = self->client->max_horz;
		self->max_vert = self->client->max_vert;
		if(self->max_horz) {//XXX!!!!!
			self->width = self->client->area.width;
		} else
			self->width = self->client->area.width ;
		STRUT_SET(self->size, 0, 0, 0, 0);
	}
	RECT_SET_SIZE(self->area, self->client->area.width + self->size.left + self->size.right,
					self->client->area.height + self->size.top + self->size.bottom);
	if((moved || resized) && !fake) {
		self->area.x = self->client->area.x;
		self->area.y = self->client->area.y;
	}
	if(!fake) {
		XMoveResizeWindow(t_display, self->window, self->area.x, self->area.y, self->area.width, self->area.height);
		XMoveWindow(t_display, self->client->window, self->size.left, self->size.top);
		if(resized) {
			frame_adjust_shape(self);
		}
		if(!STRUT_EQUAL(self->size, self->oldsize)) {
			gulong vals[4];
			vals[0] = self->size.left;
			vals[1] = self->size.right;
			vals[2] = self->size.top;
			vals[3] = self->size.bottom;
			self->oldsize = self->size;
		}
		if(focus_cycle_target == self->client)
			focus_cycle_update_indicator(self->client);
	}
}
コード例 #23
0
ファイル: wndo-ctrl.c プロジェクト: wijjo/wndo
static int window_move_resize (Display *disp, Window win, char *arg) {/*{{{*/
    signed long x, y, w, h;
    const char *argerr = "The -e option expects a list of comma separated integers: \"X,Y,width,height\"\n";
    
    if (!arg || strlen(arg) == 0) {
        fputs(argerr, stderr);
        return EXIT_FAILURE;
    }

    if (sscanf(arg, "%ld,%ld,%ld,%ld", &x, &y, &w, &h) != 4) {
        fputs(argerr, stderr);
        return EXIT_FAILURE;
    }

    if ((w < 1 || h < 1) && (x >= 0 && y >= 0)) {
        XMoveWindow(disp, win, x, y);
    }
    else if ((x < 0 || y < 0) && (w >= 1 && h >= -1)) {
        XResizeWindow(disp, win, w, h);
    }
    else if (x >= 0 && y >= 0 && w >= 1 && h >= 1) {
        XMoveResizeWindow(disp, win, x, y, w, h);
    }
    return EXIT_SUCCESS;
}/*}}}*/
コード例 #24
0
ファイル: gui.c プロジェクト: chinese-opendesktop/oxim
static void InitWindows(xccore_t *xccore)
{
    gui_status_init();
    gui_root_init();
    gui_preedit_init();
    gui_select_init();
    gui_tray_init();
    gui_menu_init();
    gui_symbol_init();
    gui_keyboard_init();
    gui_xcin_init();
    gui_msgbox_init();
    gui_selectmenu_init();

    int isok = gui_restore_window_pos();

    winlist_t *win = winlist;

    while (win)
    {
	win->data = (void *)xccore;
	if (win->draw)
	{
	    XftDrawDestroy(win->draw);
	}

	win->draw = XftDrawCreate(gui->display, win->window, gui->visual, gui->colormap);

	XSelectInput(gui->display, win->window, (ExposureMask|ButtonPressMask|ButtonReleaseMask|PointerMotionMask|EnterWindowMask|LeaveWindowMask|StructureNotifyMask|KeyPressMask));
 	MakeDefaultFont(win); /* 建立預設字型 */
	XMoveResizeWindow(gui->display, win->window,
			win->pos_x, win->pos_y, win->width, win->height);
	win = win->next;
    }
}
コード例 #25
0
ファイル: x11_window.cpp プロジェクト: DawidNowicki/vlc
void X11Window::moveResize( int left, int top, int width, int height ) const
{
    if( width && height )
        XMoveResizeWindow( XDISPLAY, m_wnd, left, top, width, height );
    else
        XMoveWindow( XDISPLAY, m_wnd, left, top );
}
コード例 #26
0
ファイル: osd.cpp プロジェクト: BackupTheBerlios/lapsus-svn
void LapsusOSD::reposition( QSize newSize )
{
	if( !newSize.isValid() ) newSize = size();

	QPoint newPos = _position;
	const QRect& screen = QApplication::desktop()->screenGeometry( _screen );

	// now to properly resize if put into one of the corners we interpret the position
	// depending on the quadrant
	int midH = screen.width()/2;
	int midV = screen.height()/2;

	if( newPos.x() > midH ) newPos.rx() -= newSize.width();
	if( newPos.y() > midV ) newPos.ry() -= newSize.height();

	newPos = fixupPosition( newPos );

	// correct for screen position
	newPos += screen.topLeft();

	// ensure we are painted before we move
	if( isVisible() ) paintEvent( 0 );

	// fancy X11 move+resize, reduces visual artifacts
	XMoveResizeWindow( x11Display(), winId(), newPos.x(), newPos.y(), newSize.width(), newSize.height() );
}
コード例 #27
0
ファイル: render.c プロジェクト: carriercomm/bmpanel
static int update_tray_positions(int ox, struct tray *trayicons)
{
	tray_pos = ox;
	ox += theme->tray_space_gap;
	int count = 0;
	int y,w,h;
	int th = theme->height_override ? theme->height_override : theme->height;
	w = theme->tray_icon_w;
	h = theme->tray_icon_h;
	struct tray *iter = trayicons;
	while (iter) {
		count++;
		y = (th - h) / 2;
		if (theme->height_override)
			y += theme->height - theme->height_override;
		XWindowAttributes xa;
		memset(&xa, 0, sizeof(xa));
		XGetWindowAttributes(bbdpy, iter->win, &xa);
		if (xa.x != ox || xa.width != w) {
			iter->x = ox;
			iter->y = y;
			XMoveResizeWindow(bbdpy, iter->win, ox, y, w, h);
		}
		ox += w + theme->tray_icons_spacing;
		iter = iter->next;
	}

	tray_width = count * theme->tray_icon_w;
	if (tray_width) {
		tray_width += theme->tray_space_gap * 2 + 
			(count - 1) * theme->tray_icons_spacing;
	}
	return tray_width;
}
コード例 #28
0
int hxc_fileselect::WinProc(hxc_fileselect *This,Window Win,XEvent *Ev)
{
    if (Ev->type==ConfigureNotify) {
        XWindowAttributes wa;
        XGetWindowAttributes(This->XD,Win,&wa);

        int w=wa.width,h=wa.height;
        if (This->DirOutput.handle) XResizeWindow(This->XD,This->DirOutput.handle,max(w-50,30),25);
        if (This->lv.XD) {
            XResizeWindow(This->XD,This->lv.handle,max(w-20,10),max(h-90-35,10));
            if (This->filename_ed.handle) {
                XMoveResizeWindow(This->XD,This->filename_ed.handle,
                                  10,(This->lv.h)+(This->lv.y)+10,max(w-20,10),25);
            }
        }
        XSync(This->XD,0);
    } else if (Ev->type==ClientMessage) {
        if (Ev->xclient.message_type==hxc::XA_WM_PROTOCOLS) {
            if ((Atom)(Ev->xclient.data.l[0])==hxc::XA_WM_DELETE_WINDOW) {
                This->Close=3;
            }
        }
    } else if (Ev->type==Expose) {
        if (Ev->xexpose.count>0) return 0;

        XWindowAttributes wa;
        XGetWindowAttributes(This->XD,Win,&wa);
        hxc::draw_border(This->XD,Win,hxc::gc,0,0,wa.width,wa.height,2,hxc::col_border_light,hxc::col_border_dark);
    }
    return 0;
}
コード例 #29
0
ファイル: window.c プロジェクト: hirkmt/sxiv
bool win_moveresize(win_t *win, int x, int y, unsigned int w, unsigned int h)
{
	if (win == NULL || win->xwin == None)
		return false;

	/* caller knows nothing about the bar */
	h += win->bar.h;

	x = MAX(0, x);
	y = MAX(0, y);
	w = MIN(w, win->env.scrw - 2 * win->bw);
	h = MIN(h, win->env.scrh - 2 * win->bw);

	if (win->x == x && win->y == y && win->w == w && win->h + win->bar.h == h)
		return false;

	win->x = x;
	win->y = y;
	win->w = w;
	win->h = h - win->bar.h;

	win_update_sizehints(win);

	XMoveResizeWindow(win->env.dpy, win->xwin, x, y, w, h);

	if (win->pm != None) {
		XFreePixmap(win->env.dpy, win->pm);
		win->pm = None;
	}

	return true;
}
コード例 #30
0
ファイル: tray.c プロジェクト: guns/subtle
void
subTrayUpdate(void)
{
  subtle->panels.tray.width = 0; ///< Reset width

  if(0 < subtle->trays->ndata)
    {
      int i;

      /* Resize every tray */
      for(i = 0, subtle->panels.tray.width = 3; i < subtle->trays->ndata; i++)
        {
          SubTray *t = TRAY(subtle->trays->data[i]);

          if(t->flags & SUB_TRAY_DEAD) continue;

          XMapWindow(subtle->dpy, t->win);
          XMoveResizeWindow(subtle->dpy, t->win, subtle->panels.tray.width,
            0, t->width, subtle->ph);
          subtle->panels.tray.width += t->width;
        }

      subtle->panels.tray.width += 3; ///< Add padding

      XMapRaised(subtle->dpy, subtle->windows.tray);
      XResizeWindow(subtle->dpy, subtle->windows.tray,
        subtle->panels.tray.width, subtle->ph);
    }
  else XUnmapWindow(subtle->dpy, subtle->windows.tray);
} /* }}} */