Example #1
0
void XVWindow::toggleFullscreen() {
	int newX, newY, newWidth, newHeight;
	Window childWindow;
	XWindowAttributes xwattributes;

	if (_state.fullscreen) {
		// not needed with EWMH fs
		if ( ! (_wmType & wm_FULLSCREEN) ) {
			newX = _state.oldx;
			newY = _state.oldy;
			newWidth = _state.oldWidth;
			newHeight = _state.oldHeight;
			setDecoration(true);
		}

		// removes fullscreen state if wm supports EWMH
		setEWMHFullscreen(_NET_WM_STATE_REMOVE);
	} else {
		// sets fullscreen state if wm supports EWMH
		setEWMHFullscreen(_NET_WM_STATE_ADD);

		// not needed with EWMH fs - save window coordinates/size and discover fullscreen window size
		if ( ! (_wmType & wm_FULLSCREEN) ) {
			newX = 0;
			newY = 0;
			newWidth = DisplayWidth(_display, DefaultScreen(_display));
			newHeight = DisplayHeight(_display, DefaultScreen(_display));

			setDecoration(false);
			XFlush(_display);
			XTranslateCoordinates(_display, _XVWindow, RootWindow(_display, DefaultScreen(_display)),
						0,0,&_state.oldx,&_state.oldy, &childWindow);
			XGetWindowAttributes(_display, _XVWindow, &xwattributes);
			_state.oldWidth = xwattributes.width;
			_state.oldHeight = xwattributes.height;
		}
	}
	 // not needed with EWMH fs - create a screen-filling window on top and turn of decorations
	if (!(_wmType & wm_FULLSCREEN) ) {
		setSizeHints(newX, newY, _XVImage->width, _XVImage->height, newWidth, newHeight);
		setLayer((!_state.fullscreen) ? 0 : 1);
		XMoveResizeWindow(_display, _XVWindow, newX, newY, newWidth, newHeight);
	}

	/* some WMs lose ontop after fullscreeen */
	if ((_state.fullscreen) & _state.ontop) {
		setLayer(1);
	}

	XMapRaised(_display, _XVWindow);
	XRaiseWindow(_display, _XVWindow);
	XFlush(_display);
	_state.fullscreen=!_state.fullscreen;
}
Example #2
0
long KWM::getDecoration(Window w){
  static Atom a = 0;
  if (!a)
    a = XInternAtom(qt_xdisplay(), "KWM_WIN_DECORATION", False);
  long result = 1;
  if (!getSimpleProperty(w, a, result)){
    setDecoration(w, result);
  }
  return result;
}
Example #3
0
QRect KWM::setProperties(Window w, const QString &props){
  int a;
  int data[13];
  int d1,d2,d3,d4;
  int n = 0;
  QRect result;
  QString arg = props.data();
  while ((a = arg.find('+', 0)) != -1){
    if (n<13)
      data[n++]=arg.left(a).toInt();
    arg.remove(0,a+1);
  }
  if (n<13)
    data[n++] = arg.toInt();
  if (n!=13){
//     fprintf(stderr, "KWM::setProperties: <bad properties error>\n");
    return result;
  }
  n = 0;
  moveToDesktop(w, data[n++]);
  d1 = data[n++];
  d2 = data[n++];
  d3 = data[n++];
  d4 = data[n++];
  result = QRect(d1,d2,d3,d4);
  setGeometry(w, result);
  d1 = data[n++];
  d2 = data[n++];
  d3 = data[n++];
  d4 = data[n++];
  setGeometryRestore(w, QRect(d1,d2,d3,d4));
  setIconify(w, (data[n++] != 0) );
  setMaximize(w, (data[n] != 0), data[n] );n++;
  setSticky(w, (data[n++] != 0) );
  setDecoration(w, data[n++] );
  return result;
}
Example #4
0
void XVWindow::putFrame(uint8_t* frame, uint16_t width, uint16_t height) {
	XEvent event;

	if ((width!= _XVImage->width) || (height!=_XVImage->height)) {
	    printf ("[x11] dynamic switching of resolution not supported\n");
	    return;
	}

	// event handling
	while (XPending(_display)) {
		XNextEvent(_display, &event);
		if (event.type == ClientMessage) {
//			if "closeWindow" is clicked do nothing right now (window is closed from the Qt Gui
//			if (event.xclient.format == 32 && event.xclient.data.l[0] == (signed) WM_DELETE_WINDOW) exit(0);
		}
		// the window size has changed
		if (event.type == ConfigureNotify) {
			XConfigureEvent* xce = (XConfigureEvent*) &event;
			// if a slave window exists it has to be resized as well
			if (_slave) { _slave->resize(
				xce->width - (int)(xce->width / DEFAULT_SLAVE_RATIO),
				xce->height - (int)(_slave->getYUVHeight() * xce->width / DEFAULT_SLAVE_RATIO / _slave->getYUVWidth()),
				(int)(xce->width / DEFAULT_SLAVE_RATIO),
				(int)(_slave->getYUVHeight() * xce->width / DEFAULT_SLAVE_RATIO / _slave->getYUVWidth()));
			}

			// if we are a slave window the master window takes care of aspect ration
			if (_master) {
				_state.curX=0;
				_state.curY=0;
				_state.curWidth=xce->width;
				_state.curHeight=xce->height;
			// if we are a master window we have to recalculate the window size (important for non 4:3 screens)
			} else {
				if ((xce->width*_XVImage->height/_XVImage->width)>xce->height) {
					_state.curX=(int)((xce->width-(xce->height*_XVImage->width/_XVImage->height))/2);
					_state.curY=0;
					_state.curWidth=(int)(xce->height*_XVImage->width/_XVImage->height);
					_state.curHeight=xce->height;
				} else if ((xce->height*_XVImage->width/_XVImage->height)>xce->width) {
					_state.curX=0;
					_state.curY=(int)((xce->height-(xce->width*_XVImage->height/_XVImage->width))/2);
					_state.curWidth=xce->width;
					_state.curHeight=(int)(xce->width*_XVImage->height/_XVImage->width);
				} else {
					_state.curX=0;
					_state.curY=0;
					_state.curWidth=xce->width;
					_state.curHeight=xce->height;
				}
			}
		}

		// a key is pressed
		if (event.type == KeyPress) {
			XKeyEvent* xke = (XKeyEvent*) &event;
			switch (xke->keycode) {
				case 41:	toggleFullscreen(); // "f"
				break;
				case 40:	setDecoration(!_state.decoration); // "d"
				break;
				case 32:	toggleOntop(); // "o"
				break;
				case 9:		if (_state.fullscreen) { toggleFullscreen(); } // esc
				break;
			}
		}

		// a mouse button is clicked
		if (event.type == ButtonPress) {
			if (_master) {
				_master->toggleFullscreen();
			} else {
				toggleFullscreen();
			}
		}
	}

	// copy image to shared memory
	memcpy(_XVImage->data, frame, (int) (_XVImage->width * _XVImage->height * 3 /2));

	XvShmPutImage(_display, _XVPort, _XVWindow, _gc, _XVImage, 0, 0, _XVImage->width, _XVImage->height,
		_state.curX, _state.curY, _state.curWidth, _state.curHeight, True);

	XFlush(_display);
}