示例#1
0
void main(char ch='k')
{
 if(ch=='n')
 {
  fout<<"getch();\nclosegraph();\n}";
  rename("temp.cpp",f);
  fout.close();
  fout.open("temp.cpp");
  write('n');
 }
 else
 {
  int a=400,b=400;
  clrscr();
  int gd=DETECT,gm  ;
  initgraph(&gd,&gm,"\\tc\\bgi");
  if(password())
  {
  setfillstyle(SOLID_FILL,15);
  bar(43,62,597,458.5);
  SCREEN();
  mousecall();
  restrict(0,640,0,480);
  setmouse(a,b);
  write('o');
  }
 }
 closegraph();
}
示例#2
0
文件: screen.c 项目: yugecin/evilwm
void sweep(Client *c) {
    XEvent ev;
    int old_cx = c->x;
    int old_cy = c->y;

    if (!grab_pointer(c->screen->root, MouseMask, resize_curs)) return;

    client_raise(c);
#ifdef INFOBANNER_MOVERESIZE
    create_info_window(c);
#endif
    XGrabServer(dpy);
    draw_outline(c);

    setmouse(c->window, c->width, c->height);
    for (;;) {
        XMaskEvent(dpy, MouseMask, &ev);
        switch (ev.type) {
        case MotionNotify:
            if (ev.xmotion.root != c->screen->root)
                break;
            draw_outline(c); /* clear */
            XUngrabServer(dpy);
            recalculate_sweep(c, old_cx, old_cy, ev.xmotion.x, ev.xmotion.y, ev.xmotion.state & altmask);
#ifdef INFOBANNER_MOVERESIZE
            update_info_window(c);
#endif
            XSync(dpy, False);
            XGrabServer(dpy);
            draw_outline(c);
            break;
        case ButtonRelease:
            draw_outline(c); /* clear */
            XUngrabServer(dpy);
#ifdef INFOBANNER_MOVERESIZE
            remove_info_window();
#endif
            XUngrabPointer(dpy, CurrentTime);
            moveresize(c);
            /* In case maximise state has changed: */
            ewmh_set_net_wm_state(c);
            return;
        default:
            break;
        }
    }
}
示例#3
0
void sweep(Client *c) {
	XEvent ev;
	int old_cx = client_to_Xcoord(c,x);
	int old_cy = client_to_Xcoord(c,y);

	if (!grab_pointer(c->screen->root, MouseMask, resize_curs)) return;

	client_raise(c);
	annotate_create(c, &annotate_sweep_ctx);

	setmouse(c->window, c->width, c->height);
	for (;;) {
		XMaskEvent(dpy, MouseMask, &ev);
		switch (ev.type) {
			case MotionNotify:
				if (ev.xmotion.root != c->screen->root)
					break;
				annotate_preupdate(c, &annotate_sweep_ctx);
				/* perform recalculate_sweep in Xcoordinates, then convert
				 * back relative to the current phy */
				recalculate_sweep(c, old_cx, old_cy, ev.xmotion.x, ev.xmotion.y, ev.xmotion.state & altmask);
				c->nx -= c->phy->xoff;
				c->ny -= c->phy->yoff;
				client_calc_cog(c);
				client_calc_phy(c);
				annotate_update(c, &annotate_sweep_ctx);
				break;
			case ButtonRelease:
				annotate_remove(c, &annotate_sweep_ctx);
				client_calc_phy(c);
				XUngrabPointer(dpy, CurrentTime);
				moveresizeraise(c);
				/* In case maximise state has changed: */
				ewmh_set_net_wm_state(c);
				return;
			default: break;
		}
	}
}
示例#4
0
文件: osx-srv.c 项目: fr1tz/nadir
/* 
 * Handle a single wsysmsg. 
 * Might queue for later (kbd, mouse read)
 */
void
runmsg(Wsysmsg *m)
{
	static uchar buf[65536];
	int n;
	Memimage *i;
	
	switch(m->type){
	case Tinit:
		memimageinit();
		i = attachscreen(m->label, m->winsize);
		_initdisplaymemimage(i);
		replymsg(m);
		break;

	case Trdmouse:
		zlock();
		mousetags.t[mousetags.wi++] = m->tag;
		if(mousetags.wi == nelem(mousetags.t))
			mousetags.wi = 0;
		if(mousetags.wi == mousetags.ri)
			sysfatal("too many queued mouse reads");
		mouse.stall = 0;
		matchmouse();
		zunlock();
		break;

	case Trdkbd:
		zlock();
		kbdtags.t[kbdtags.wi++] = m->tag;
		if(kbdtags.wi == nelem(kbdtags.t))
			kbdtags.wi = 0;
		if(kbdtags.wi == kbdtags.ri)
			sysfatal("too many queued keyboard reads");
		kbd.stall = 0;
		matchkbd();
		zunlock();
		break;

	case Tmoveto:
		setmouse(m->mouse.xy);
		replymsg(m);
		break;

	case Tcursor:
		if(m->arrowcursor)
			setcursor(nil);
		else
			setcursor(&m->cursor);
		replymsg(m);
		break;
			
	case Tbouncemouse:
	//	_xbouncemouse(&m->mouse);
		replymsg(m);
		break;

	case Tlabel:
		kicklabel(m->label);
		replymsg(m);
		break;

	case Trdsnarf:
		m->snarf = getsnarf();
		replymsg(m);
		free(m->snarf);
		break;

	case Twrsnarf:
		putsnarf(m->snarf);
		replymsg(m);
		break;

	case Trddraw:
		n = m->count;
		if(n > sizeof buf)
			n = sizeof buf;
		n = _drawmsgread(buf, n);
		if(n < 0)
			replyerror(m);
		else{
			m->count = n;
			m->data = buf;
			replymsg(m);
		}
		break;

	case Twrdraw:
		if(_drawmsgwrite(m->data, m->count) < 0)
			replyerror(m);
		else
			replymsg(m);
		break;
	
	case Ttop:
	//	_xtopwindow();
		replymsg(m);
		break;
	
	case Tresize:
	//	_xresizewindow(m->rect);
		replymsg(m);
		break;
	}
}
示例#5
0
文件: mouse.c 项目: hoop33/neovim
// Move the cursor to the specified row and column on the screen.
// Change current window if necessary. Returns an integer with the
// CURSOR_MOVED bit set if the cursor has moved or unset otherwise.
//
// The MOUSE_FOLD_CLOSE bit is set when clicked on the '-' in a fold column.
// The MOUSE_FOLD_OPEN bit is set when clicked on the '+' in a fold column.
//
// If flags has MOUSE_FOCUS, then the current window will not be changed, and
// if the mouse is outside the window then the text will scroll, or if the
// mouse was previously on a status line, then the status line may be dragged.
//
// If flags has MOUSE_MAY_VIS, then VIsual mode will be started before the
// cursor is moved unless the cursor was on a status line.
// This function returns one of IN_UNKNOWN, IN_BUFFER, IN_STATUS_LINE or
// IN_SEP_LINE depending on where the cursor was clicked.
//
// If flags has MOUSE_MAY_STOP_VIS, then Visual mode will be stopped, unless
// the mouse is on the status line of the same window.
//
// If flags has MOUSE_DID_MOVE, nothing is done if the mouse didn't move since
// the last call.
//
// If flags has MOUSE_SETPOS, nothing is done, only the current position is
// remembered.
int jump_to_mouse(int flags,
                  bool *inclusive,  // used for inclusive operator, can be NULL
                  int which_button)  // MOUSE_LEFT, MOUSE_RIGHT, MOUSE_MIDDLE
{
  static int on_status_line = 0;        // #lines below bottom of window
  static int on_sep_line = 0;           // on separator right of window
  static int prev_row = -1;
  static int prev_col = -1;
  static win_T *dragwin = NULL;         // window being dragged
  static int did_drag = false;          // drag was noticed

  win_T       *wp, *old_curwin;
  pos_T old_cursor;
  int count;
  bool first;
  int row = mouse_row;
  int col = mouse_col;
  int mouse_char;

  mouse_past_bottom = false;
  mouse_past_eol = false;

  if (flags & MOUSE_RELEASED) {
    // On button release we may change window focus if positioned on a
    // status line and no dragging happened.
    if (dragwin != NULL && !did_drag)
      flags &= ~(MOUSE_FOCUS | MOUSE_DID_MOVE);
    dragwin = NULL;
    did_drag = false;
  }

  if ((flags & MOUSE_DID_MOVE)
      && prev_row == mouse_row
      && prev_col == mouse_col) {
retnomove:
    // before moving the cursor for a left click which is NOT in a status
    // line, stop Visual mode
    if (on_status_line)
      return IN_STATUS_LINE;
    if (on_sep_line)
      return IN_SEP_LINE;
    if (flags & MOUSE_MAY_STOP_VIS) {
      end_visual_mode();
      redraw_curbuf_later(INVERTED);            // delete the inversion
    }
    return IN_BUFFER;
  }

  prev_row = mouse_row;
  prev_col = mouse_col;

  if (flags & MOUSE_SETPOS)
    goto retnomove;                             // ugly goto...

  // Remember the character under the mouse, it might be a '-' or '+' in the
  // fold column.
  if (row >= 0 && row < Rows && col >= 0 && col <= Columns
      && ScreenLines != NULL)
    mouse_char = ScreenLines[LineOffset[row] + (unsigned)col];
  else
    mouse_char = ' ';

  old_curwin = curwin;
  old_cursor = curwin->w_cursor;

  if (!(flags & MOUSE_FOCUS)) {
    if (row < 0 || col < 0)                     // check if it makes sense
      return IN_UNKNOWN;

    // find the window where the row is in
    wp = mouse_find_win(&row, &col);
    dragwin = NULL;
    // winpos and height may change in win_enter()!
    if (row >= wp->w_height) {                  // In (or below) status line
      on_status_line = row - wp->w_height + 1;
      dragwin = wp;
    } else {
      on_status_line = 0;
    }

    if (col >= wp->w_width) {           // In separator line
      on_sep_line = col - wp->w_width + 1;
      dragwin = wp;
    } else {
      on_sep_line = 0;
    }

    // The rightmost character of the status line might be a vertical
    // separator character if there is no connecting window to the right.
    if (on_status_line && on_sep_line) {
      if (stl_connected(wp))
        on_sep_line = 0;
      else
        on_status_line = 0;
    }

    // Before jumping to another buffer, or moving the cursor for a left
    // click, stop Visual mode.
    if (VIsual_active
        && (wp->w_buffer != curwin->w_buffer
            || (!on_status_line
                && !on_sep_line
                && (
                  wp->w_p_rl ? col < wp->w_width - wp->w_p_fdc :
                                     col >= wp->w_p_fdc
                                             + (cmdwin_type == 0 && wp ==
                                                curwin ? 0 : 1)
                  )
                && (flags & MOUSE_MAY_STOP_VIS)))) {
      end_visual_mode();
      redraw_curbuf_later(INVERTED);            // delete the inversion
    }
    if (cmdwin_type != 0 && wp != curwin) {
      // A click outside the command-line window: Use modeless
      // selection if possible.  Allow dragging the status lines.
      on_sep_line = 0;
      row = 0;
      col += wp->w_wincol;
      wp = curwin;
    }
    // Only change window focus when not clicking on or dragging the
    // status line.  Do change focus when releasing the mouse button
    // (MOUSE_FOCUS was set above if we dragged first).
    if (dragwin == NULL || (flags & MOUSE_RELEASED))
      win_enter(wp, true);                      // can make wp invalid!
    // set topline, to be able to check for double click ourselves
    if (curwin != old_curwin)
      set_mouse_topline(curwin);
    if (on_status_line) {                       // In (or below) status line
      // Don't use start_arrow() if we're in the same window
      if (curwin == old_curwin)
        return IN_STATUS_LINE;
      else
        return IN_STATUS_LINE | CURSOR_MOVED;
    }
    if (on_sep_line) {                          // In (or below) status line
      // Don't use start_arrow() if we're in the same window
      if (curwin == old_curwin)
        return IN_SEP_LINE;
      else
        return IN_SEP_LINE | CURSOR_MOVED;
    }

    curwin->w_cursor.lnum = curwin->w_topline;
  } else if (on_status_line && which_button == MOUSE_LEFT)   {
    if (dragwin != NULL) {
      // Drag the status line
      count = row - dragwin->w_winrow - dragwin->w_height + 1
              - on_status_line;
      win_drag_status_line(dragwin, count);
      did_drag |= count;
    }
    return IN_STATUS_LINE;                      // Cursor didn't move
  } else if (on_sep_line && which_button == MOUSE_LEFT)   {
    if (dragwin != NULL) {
      // Drag the separator column
      count = col - dragwin->w_wincol - dragwin->w_width + 1
              - on_sep_line;
      win_drag_vsep_line(dragwin, count);
      did_drag |= count;
    }
    return IN_SEP_LINE;                         // Cursor didn't move
  } else {
    // keep_window_focus must be true
    // before moving the cursor for a left click, stop Visual mode
    if (flags & MOUSE_MAY_STOP_VIS) {
      end_visual_mode();
      redraw_curbuf_later(INVERTED);            // delete the inversion
    }


    row -= curwin->w_winrow;
    col -= curwin->w_wincol;

    // When clicking beyond the end of the window, scroll the screen.
    // Scroll by however many rows outside the window we are.
    if (row < 0) {
      count = 0;
      for (first = true; curwin->w_topline > 1; ) {
        if (curwin->w_topfill < diff_check(curwin, curwin->w_topline))
          ++count;
        else
          count += plines(curwin->w_topline - 1);
        if (!first && count > -row)
          break;
        first = false;
        (void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
        if (curwin->w_topfill < diff_check(curwin, curwin->w_topline)) {
          ++curwin->w_topfill;
        } else {
          --curwin->w_topline;
          curwin->w_topfill = 0;
        }
      }
      check_topfill(curwin, false);
      curwin->w_valid &=
        ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP);
      redraw_later(VALID);
      row = 0;
    } else if (row >= curwin->w_height)   {
      count = 0;
      for (first = true; curwin->w_topline < curbuf->b_ml.ml_line_count; ) {
        if (curwin->w_topfill > 0) {
          ++count;
        } else {
          count += plines(curwin->w_topline);
        }

        if (!first && count > row - curwin->w_height + 1) {
          break;
        }
        first = false;

        if (hasFolding(curwin->w_topline, NULL, &curwin->w_topline)
            && curwin->w_topline == curbuf->b_ml.ml_line_count) {
          break;
        }

        if (curwin->w_topfill > 0) {
          --curwin->w_topfill;
        } else {
          ++curwin->w_topline;
          curwin->w_topfill =
            diff_check_fill(curwin, curwin->w_topline);
        }
      }
      check_topfill(curwin, false);
      redraw_later(VALID);
      curwin->w_valid &=
        ~(VALID_WROW|VALID_CROW|VALID_BOTLINE|VALID_BOTLINE_AP);
      row = curwin->w_height - 1;
    } else if (row == 0)   {
      // When dragging the mouse, while the text has been scrolled up as
      // far as it goes, moving the mouse in the top line should scroll
      // the text down (done later when recomputing w_topline).
      if (mouse_dragging > 0
          && curwin->w_cursor.lnum
          == curwin->w_buffer->b_ml.ml_line_count
          && curwin->w_cursor.lnum == curwin->w_topline) {
        curwin->w_valid &= ~(VALID_TOPLINE);
      }
    }
  }

  // Check for position outside of the fold column.
  if (curwin->w_p_rl ? col < curwin->w_width - curwin->w_p_fdc :
      col >= curwin->w_p_fdc + (cmdwin_type == 0 ? 0 : 1)) {
    mouse_char = ' ';
  }

  // compute the position in the buffer line from the posn on the screen
  if (mouse_comp_pos(curwin, &row, &col, &curwin->w_cursor.lnum)) {
    mouse_past_bottom = true;
  }

  if (!(flags & MOUSE_RELEASED) && which_button == MOUSE_LEFT) {
    col = mouse_adjust_click(curwin, row, col);
  }

  // Start Visual mode before coladvance(), for when 'sel' != "old"
  if ((flags & MOUSE_MAY_VIS) && !VIsual_active) {
    check_visual_highlight();
    VIsual = old_cursor;
    VIsual_active = true;
    VIsual_reselect = true;
    // if 'selectmode' contains "mouse", start Select mode
    may_start_select('o');
    setmouse();

    if (p_smd && msg_silent == 0) {
      redraw_cmdline = true;            // show visual mode later
    }
  }

  curwin->w_curswant = col;
  curwin->w_set_curswant = false;       // May still have been true
  if (coladvance(col) == FAIL) {        // Mouse click beyond end of line
    if (inclusive != NULL) {
      *inclusive = true;
    }
    mouse_past_eol = true;
  } else if (inclusive != NULL) {
    *inclusive = false;
  }

  count = IN_BUFFER;
  if (curwin != old_curwin || curwin->w_cursor.lnum != old_cursor.lnum
      || curwin->w_cursor.col != old_cursor.col) {
    count |= CURSOR_MOVED;              // Cursor has moved
  }

  if (mouse_char == '+') {
    count |= MOUSE_FOLD_OPEN;
  } else if (mouse_char != ' ') {
    count |= MOUSE_FOLD_CLOSE;
  }

  return count;
}
示例#6
0
文件: grab.c 项目: 00001/plan9port
int
menuhit(XButtonEvent *e, Menu *m)
{
	XEvent ev;
	int i, n, cur, old, wide, high, status, drawn, warp;
	int x, y, dx, dy, xmax, ymax;
	ScreenInfo *s;

	if(font == 0)
		return -1;
	s = getscreen(e->root);
	if(s == 0 || e->window == s->menuwin)	   /* ugly event mangling */
		return -1;

	dx = 0;
	for(n = 0; m->item[n]; n++){
		wide = XTextWidth(font, m->item[n], strlen(m->item[n])) + 4;
		if(wide > dx)
			dx = wide;
	}
	wide = dx;
	cur = m->lasthit;
	if(cur >= n)
		cur = n - 1;

	high = font->ascent + font->descent + 1;
	dy = n*high;
	x = e->x - wide/2;
	y = e->y - cur*high - high/2;
	warp = 0;
	xmax = DisplayWidth(dpy, s->num);
	ymax = DisplayHeight(dpy, s->num);
	if(x < 0){
		e->x -= x;
		x = 0;
		warp++;
	}
	if(x+wide >= xmax){
		e->x -= x+wide-xmax;
		x = xmax-wide;
		warp++;
	}
	if(y < 0){
		e->y -= y;
		y = 0;
		warp++;
	}
	if(y+dy >= ymax){
		e->y -= y+dy-ymax;
		y = ymax-dy;
		warp++;
	}
	if(warp)
		setmouse(e->x, e->y, s);
	XMoveResizeWindow(dpy, s->menuwin, x, y, dx, dy);
	XSelectInput(dpy, s->menuwin, MenuMask);
	XMapRaised(dpy, s->menuwin);
	status = grab(s->menuwin, None, MenuGrabMask, None, e->time);
	if(status != GrabSuccess){
		/* graberror("menuhit", status); */
		XUnmapWindow(dpy, s->menuwin);
		return -1;
	}
	drawn = 0;
	for(;;){
		XMaskEvent(dpy, MenuMask, &ev);
		switch (ev.type){
		default:
			fprintf(stderr, "rio: menuhit: unknown ev.type %d\n", ev.type);
			break;
		case ButtonPress:
			break;
		case ButtonRelease:
			if(ev.xbutton.button != e->button)
				break;
			x = ev.xbutton.x;
			y = ev.xbutton.y;
			i = y/high;
			if(cur >= 0 && y >= cur*high-3 && y < (cur+1)*high+3)
				i = cur;
			if(x < 0 || x > wide || y < -3)
				i = -1;
			else if(i < 0 || i >= n)
				i = -1;
			else
				m->lasthit = i;
			if(!nobuttons(&ev.xbutton))
				i = -1;
			ungrab(&ev.xbutton);
			XUnmapWindow(dpy, s->menuwin);
			return i;
		case MotionNotify:
			if(!drawn)
				break;
			x = ev.xbutton.x;
			y = ev.xbutton.y;
			old = cur;
			cur = y/high;
			if(old >= 0 && y >= old*high-3 && y < (old+1)*high+3)
				cur = old;
			if(x < 0 || x > wide || y < -3)
				cur = -1;
			else if(cur < 0 || cur >= n)
				cur = -1;
			if(cur == old)
				break;
			if(old >= 0 && old < n)
				drawstring(dpy, s, m, wide, high, old, 0);
			if(cur >= 0 && cur < n)
				drawstring(dpy, s, m, wide, high, cur, 1);
			break;
		case Expose:
			XClearWindow(dpy, s->menuwin);
			for(i = 0; i < n; i++)
				drawstring(dpy, s, m, wide, high, i, cur==i);
			drawn = 1;
		}
	}
}
示例#7
0
文件: devmouse.c 项目: 0intro/vx32
static long
mousewrite(Chan *c, void *va, long n, vlong offset)
{
	char *p;
	Point pt;
	Cmdbuf *cb;
	Cmdtab *ct;
	char buf[64];
	int nn;

	p = va;
	switch((ulong)c->qid.path){
	case Qdir:
		error(Eisdir);

	case Qcursor:
		if(n < 2*4+2*2*16){
			curs = arrow;
			Cursortocursor(&arrow);
		}else{
			n = 2*4+2*2*16;
			curs.offset.x = BGLONG(p+0);
			curs.offset.y = BGLONG(p+4);
			memmove(curs.clr, p+8, 2*16);
			memmove(curs.set, p+40, 2*16);
			Cursortocursor(&curs);
		}
		qlock(&mouse.qlk);
		mouse.redraw = 1;
		qunlock(&mouse.qlk);
		return n;

	case Qmousectl:
		cb = parsecmd(va, n);
		if(waserror()){
			free(cb);
			nexterror();
		}

		ct = lookupcmd(cb, mousectlmsg, nelem(mousectlmsg));

		switch(ct->index){
		case CMswap:
			if(mouseswap)
				setbuttonmap("123");
			else
				setbuttonmap("321");
			mouseswap ^= 1;
			break;

		case CMscrollswap:
			scrollswap ^= 1;
			break;

		case CMbuttonmap:
			if(cb->nf == 1)
				setbuttonmap("123");
			else
				setbuttonmap(cb->f[1]);
			break;
		}

		free(cb);
		poperror();
		return n;

	case Qmouse:
		if(n > sizeof buf-1)
			n = sizeof buf -1;
		memmove(buf, va, n);
		buf[n] = 0;
		p = 0;
		pt.x = strtoul(buf+1, &p, 0);
		if(p == 0)
			error(Eshort);
		pt.y = strtoul(p, 0, 0);
		qlock(&mouse.qlk);
		if(ptinrect(pt, mouserect)){
			mouse.mstate.xy = pt;
			mouse.redraw = 1;
			mouse.track = 1;
		}
		qunlock(&mouse.qlk);
		setmouse(pt);
		return n;
	
	case Qsnarf:
		if(offset+n >= SnarfSize)
			error("too much snarf");
		if(n == 0)
			return 0;
		assert(mousedir[Qsnarf].qid.path == Qsnarf);
		mousedir[Qsnarf].qid.vers++;
		if(c->aux == nil)
			nn = 0;
		else
			nn = strlen(c->aux);
		if(offset+n > nn){
			nn = offset+n;
			p = smalloc(nn+1);
			if(c->aux){
				strcpy(p, c->aux);
				free(c->aux);
			}
			c->aux = p;
		}
		memmove(c->aux+offset, va, n);
		return n;
	}

	error(Egreg);
	return -1;
}
示例#8
0
文件: mouse.c 项目: bbidulock/larswm
void
move_opaque (Client * c)
{
  XEvent report;
  Client *p;
  int old_x, old_y;
  int move_x, move_y;
  char geo[16];
  int len;

  if (!c)
    return;

  getmouse (&old_x, &old_y, c->screen);

  XMapRaised (dpy, c->parent);
  setmouse (c->x, c->y, c->screen);

  XChangeActivePointerGrab (dpy,
			    PointerMotionHintMask | ButtonMotionMask |
			    ButtonReleaseMask | OwnerGrabButtonMask,
			    c->screen->place, CurrentTime);

  while (1)
    {
      XNextEvent (dpy, &report);

      switch (report.type)
	{
#ifdef THREE_D
	case Expose:
	  p = getclient (report.xexpose.window, 0);

	  if (p)
	    {
	      draw_border (p, p == current ? 1 : 0);
	    }
	  break;
#endif

	case ButtonRelease:
	  if (report.xbutton.button == Button1)
	    {
	      getmouse (&move_x, &move_y, c->screen);

	      c->x = move_x;
	      c->y = move_y;

	      XMoveWindow (dpy, c->parent, c->x, c->y);
	      sendconfig (c);

	      setmouse (old_x, old_y, c->screen);
	      update_tbar ();
	      return;
	    }
	  break;

	case MotionNotify:
	  while (XCheckTypedEvent (dpy, MotionNotify, &report));

	  getmouse (&move_x, &move_y, c->screen);

	  XMoveWindow (dpy, c->parent, move_x, move_y);
	  sendconfig (c);

	  len = sprintf (geo, "+%d+%d", move_x, move_y);

	  XClearWindow (dpy, c->screen->barwin);
#ifdef THREE_D
	  XDrawLine (dpy, c->screen->barwin, c->screen->botwhitegc, 0,
		     prefs.bar_height - 1, BAR_WIDTH (c->screen) - 1,
		     prefs.bar_height - 1);
	  XDrawLine (dpy, c->screen->barwin, c->screen->botwhitegc,
		     BAR_WIDTH (c->screen) - 1, prefs.bar_height - 1,
		     BAR_WIDTH (c->screen) - 1, 0);
	  XDrawLine (dpy, c->screen->barwin, c->screen->topwhitegc, 0, 0,
		     BAR_WIDTH (c->screen) - 1, 0);
	  XDrawLine (dpy, c->screen->barwin, c->screen->topwhitegc, 0, 0, 0,
		     prefs.bar_height - 1);
#endif
	  XDrawString (dpy, c->screen->barwin, c->screen->gc, prefs.bar_height,
		       BAR_TEXT_Y, geo, len);
	  break;
	}
    }
}
示例#9
0
文件: mouse.c 项目: bbidulock/larswm
void
resize_opaque (Client * c)
{
  XEvent report;
  Client *p;
  int old_x, old_y;
  int move_x, move_y;
  char geo[32];
  int len, sx, sy, rx = 0, ry = 0, mx = 0, my = 0;

  if (!c)
    return;

  getmouse (&old_x, &old_y, c->screen);

  if (c->size.flags & PMinSize)
    {
      mx = c->size.min_width;
      my = c->size.min_height;
    }

  if (c->size.flags & PResizeInc)
    {
      rx = c->size.width_inc;
      ry = c->size.height_inc;
    }

  XMapRaised (dpy, c->parent);
  setmouse (c->x + c->dx + 1 + BORDER, c->y + c->dy + 1 + BORDER, c->screen);

  XChangeActivePointerGrab (dpy,
			    PointerMotionHintMask | ButtonMotionMask |
			    ButtonReleaseMask | OwnerGrabButtonMask,
			    c->screen->sweep, CurrentTime);

  while (1)
    {
      XNextEvent (dpy, &report);

      switch (report.type)
	{
#ifdef THREE_D
	case Expose:
	  p = getclient (report.xexpose.window, 0);

	  if (p)
	    {
	      draw_border (p, p == current ? 1 : 0);
	    }
	  break;
#endif

	case ButtonRelease:
	  if (report.xbutton.button == Button1)
	    {
	      getmouse (&move_x, &move_y, c->screen);

	      c->dx = move_x - BORDER - c->x - 1;
	      c->dy = move_y - BORDER - c->y - 1;

	      adjust_hints (c);

	      XResizeWindow (dpy, c->window, c->dx, c->dy);
	      XResizeWindow (dpy, c->parent, c->dx + (2 * BORDER),
			     c->dy + (2 * BORDER));
	      sendconfig (c);

	      if (shape)
		setshape (c);

	      setmouse (old_x, old_y, c->screen);
	      update_tbar ();
	      return;
	    }
	  break;

	case MotionNotify:
	  while (XCheckTypedEvent (dpy, MotionNotify, &report));

	  getmouse (&move_x, &move_y, c->screen);

	  c->dx = move_x - BORDER - c->x - 1;
	  c->dy = move_y - BORDER - c->y - 1;

	  adjust_hints (c);

	  sx = c->dx;
	  sy = c->dy;

	  XResizeWindow (dpy, c->window, c->dx, c->dy);
	  XResizeWindow (dpy, c->parent, c->dx + (2 * BORDER),
			 c->dy + (2 * BORDER));
	  sendconfig (c);

	  if (shape)
	    setshape (c);

	  if (rx)
	    {
	      if (mx)
		sx -= mx;

	      sx /= rx;
	      sx++;
	    }

	  if (ry)
	    {
	      if (my)
		sy -= my;

	      sy /= ry;
	      sy++;
	    }

	  if (rx || ry)
	    len = sprintf (geo, "%dx%d (%dx%d)", sx, sy, c->dx, c->dy);
	  else
	    len = sprintf (geo, "%dx%d", c->dx, c->dy);


	  XClearWindow (dpy, c->screen->barwin);
#ifdef THREE_D
	  XDrawLine (dpy, c->screen->barwin, c->screen->botwhitegc, 0,
		     prefs.bar_height - 1, BAR_WIDTH (c->screen) - 1,
		     prefs.bar_height - 1);
	  XDrawLine (dpy, c->screen->barwin, c->screen->botwhitegc,
		     BAR_WIDTH (c->screen) - 1, prefs.bar_height - 1,
		     BAR_WIDTH (c->screen) - 1, 0);
	  XDrawLine (dpy, c->screen->barwin, c->screen->topwhitegc, 0, 0,
		     BAR_WIDTH (c->screen) - 1, 0);
	  XDrawLine (dpy, c->screen->barwin, c->screen->topwhitegc, 0, 0, 0,
		     prefs.bar_height - 1);
#endif
	  XDrawString (dpy, c->screen->barwin, c->screen->gc, prefs.bar_height,
		       BAR_TEXT_Y, geo, len);
	  break;
	}
    }
}