⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kwm.cpp

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 CPP
📖 第 1 页 / 共 2 页
字号:
  int i;  const char* s = command.data();  for (i=0;i<19 && s[i];i++)    ev.xclient.data.b[i]=s[i];  mask = SubstructureRedirectMask;  status = XSendEvent(qt_xdisplay(),		      qt_xrootwin(),		      False, mask, &ev);}QString KWM::title(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_TITLE", False);  QString result;  if (!getQStringProperty(w, a, result)){    getQStringProperty(w, XA_WM_NAME, result);  }  return result;}QString KWM::titleWithState(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_TITLE", False);  QString result;  if (!getQStringProperty(w, a, result)){    getQStringProperty(w, XA_WM_NAME, result);  }  if (isIconified(w)){    result.prepend("(");    result.append(")");  }  return result;}QPixmap KWM::miniIcon(Window w, int width, int height){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_ICON", False);  QPixmap result;  Pixmap p = None;  Pixmap p_mask = None;  long tmp[2] = {None, None};  if (!getDoubleProperty(w, a, tmp[0], tmp[1])){    XWMHints *hints = XGetWMHints(qt_xdisplay(), w);    if (hints && (hints->flags & IconPixmapHint)){      p = hints->icon_pixmap;    }    if (hints && (hints->flags & IconMaskHint)){      p_mask = hints->icon_mask;    }    if (hints)      XFree((char*)hints);  }  else {    p = (Pixmap) tmp[0];    p_mask = (Pixmap) tmp[1];  }  if (p != None){    Window root;    int x, y;    unsigned int w = 0;    unsigned int h = 0;    unsigned int border_w, depth;    XGetGeometry(qt_xdisplay(), p,		 &root,		 &x, &y, &w, &h, &border_w, &depth);    if (w > 0 && h > 0){      QPixmap pm(w, h, depth);      XCopyArea(qt_xdisplay(), p, pm.handle(),		qt_xget_temp_gc(depth==1),		0, 0, w, h, 0, 0);      if (p_mask != None){	QBitmap bm(w, h);	XCopyArea(qt_xdisplay(), p_mask, bm.handle(),		  qt_xget_temp_gc(TRUE),		  0, 0, w, h, 0, 0);	pm.setMask(bm);      }      if (width > 0 && height > 0 && (w > (unsigned int)width				      || h > (unsigned int) height)){	// scale	QWMatrix m;	m.scale(width/(float)w, height/(float)h);	result = pm.xForm(m);      }      else	result = pm;    }  }  else {    XWMHints *hints = XGetWMHints(qt_xdisplay(),  w);    if (hints &&	(hints->flags & WindowGroupHint)	&& hints->window_group != None	&& hints->window_group != w){	Window wg = hints->window_group;	XFree((char*)hints);	return miniIcon(wg, width, height);    }    if (hints)      XFree((char*)hints);    Window trans = None;    if (XGetTransientForHint(qt_xdisplay(), w, &trans)){      if (trans != w)	return miniIcon(trans, width, height);    }  }  return result;}QPixmap KWM::icon(Window w, int width, int height){  QPixmap result;  Pixmap p = None;  Pixmap p_mask = None;  XWMHints *hints = XGetWMHints(qt_xdisplay(), w);  if (hints && (hints->flags & IconPixmapHint)){    p = hints->icon_pixmap;  }  if (hints && (hints->flags & IconMaskHint)){    p_mask = hints->icon_mask;  }  if (hints)    XFree((char*)hints);  if (p != None){    Window root;    int x, y;    unsigned int w = 0;    unsigned int h = 0;    unsigned int border_w, depth;    XGetGeometry(qt_xdisplay(), p,		 &root,		 &x, &y, &w, &h, &border_w, &depth);    if (w > 0 && h > 0){      QPixmap pm(w, h, depth);      XCopyArea(qt_xdisplay(), p, pm.handle(),		qt_xget_temp_gc(depth==1),		0, 0, w, h, 0, 0);      if (p_mask != None){	QBitmap bm(w, h);	XCopyArea(qt_xdisplay(), p_mask, bm.handle(),		  qt_xget_temp_gc(TRUE),		  0, 0, w, h, 0, 0);	pm.setMask(bm);      }      if (width > 0 && height > 0 && (w > (unsigned int)width				      || h > (unsigned int) height)){	// scale	QWMatrix m;	m.scale(width/(float)w, height/(float)h);	result = pm.xForm(m);      }      else	result = pm;    }  }  else {    XWMHints *hints = XGetWMHints(qt_xdisplay(),  w);    if (hints &&	(hints->flags & WindowGroupHint)	&& hints->window_group != None	&& hints->window_group != w){      XFree((char*)hints);      return icon(hints->window_group, width, height);    }    if (hints)      XFree((char*)hints);    Window trans = None;    if (XGetTransientForHint(qt_xdisplay(), w, &trans)){      if (trans != w)	return icon(trans, width, height);    }  }  return result;}int KWM::desktop(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_DESKTOP", False);  if (isSticky(w))      return currentDesktop();  long result = 1;  if (!getSimpleProperty(w, a, result) || result <= 0){    result = currentDesktop();    moveToDesktop(w, (int) result);    kwm_error = TRUE; // restore error  }  return (int) result;}QRect KWM::geometry(Window w, bool including_frame){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_FRAME_GEOMETRY", False);  QRect result;  if (including_frame){    if (getQRectProperty(w, a, result))      return result;  }  XWindowAttributes attr;  if (XGetWindowAttributes(qt_xdisplay(), w, &attr)){    if (getQRectProperty(w, a, result)){      result.setWidth(attr.width);      result.setHeight(attr.height);    }    else{      int x, y;      Window child;      XTranslateCoordinates(qt_xdisplay(),			    w, qt_xrootwin(),			    0, 0, &x, &y, &child);      result.setRect(x, y, attr.width, attr.height);    }  }  return result;}QRect KWM::geometryRestore(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_GEOMETRY_RESTORE", False);  QRect result;  if (!getQRectProperty(w, a, result)){    result = geometry(w);    setGeometryRestore(w, result);  }  return result;}QRect KWM::iconGeometry(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_ICON_GEOMETRY", False);  QRect result;  if (!getQRectProperty(w, a, result) || result.isEmpty()){      QRect geom = geometry(w);      result = QRect(geom.x()+geom.width()/2,		     geom.y()+geom.height()/2,		     0,0);  }  return result;}bool KWM::isIconified(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_ICONIFIED", False);  long result = 0;  if (!getSimpleProperty(w, a, result)){    setIconify(w, result != 0);  }  return result != 0;}bool KWM::isMaximized(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_MAXIMIZED", False);  long result = 0;  if (!getSimpleProperty(w, a, result)){    setMaximize(w, result != 0);  }  return result != 0;}bool KWM::isDoMaximize(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_MAXIMIZE_WINDOW", False);  long result = 0;  if (!getSimpleProperty(w, a, result)){    doMaximize(w, result != 0);  }  return result != 0;}int KWM::maximizeMode(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_MAXIMIZED", False);  long result = 0;  if (!getSimpleProperty(w, a, result) || result == 0){      result = fullscreen;  }  return result;}int KWM::doMaximizeMode(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_MAXIMIZE_WINDOW", False);  long result = 0;  if (!getSimpleProperty(w, a, result) || result == 0){      result = fullscreen;  }  return result;}bool KWM::isSticky(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_STICKY", False);  long result = 0;  if (!getSimpleProperty(w, a, result)){    setSticky(w, result != 0);  }  return result != 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;}bool KWM::fixedSize(Window w){  XSizeHints size;  long msize;  if (XGetWMNormalHints(qt_xdisplay(), w, &size, &msize))    return (size.flags & PMaxSize ) && (size.flags & PMinSize)      && (size.max_width <= size.min_width)      && (size.max_height <= size.min_height);  return FALSE;}bool KWM::containsUnsavedData(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_UNSAVED_DATA", False);  long result = 0;  getSimpleProperty(w, a, result);  return result != 0;}bool KWM::unsavedDataHintDefined(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_UNSAVED_DATA", False);  long tmp = 0;  return getSimpleProperty(w, a, tmp);}bool KWM::isActive(Window w){  return (w == activeWindow());}void KWM::moveToDesktop(Window w, int desk){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_DESKTOP", False);  setSimpleProperty(w, a, (long) desk);}void KWM::setGeometry(Window w, const QRect &geom){  XMoveResizeWindow(qt_xdisplay(), w, geom.x(), geom.y(),		    geom.width(), geom.height());}void KWM::setGeometryRestore(Window w, const QRect &geom){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_GEOMETRY_RESTORE", False);  setQRectProperty(w, a, geom);}void KWM::setIconGeometry(Window w, const QRect &geom){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_ICON_GEOMETRY", False);  setQRectProperty(w, a, geom);}void KWM::move(Window w, const QPoint &pos){  XMoveWindow(qt_xdisplay(), w, pos.x(), pos.y());}void KWM::setMaximize(Window w, bool value){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_MAXIMIZED", False);  setSimpleProperty(w, a, value?fullscreen:0);}void KWM::doMaximize(Window w, bool value) {  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_MAXIMIZE_WINDOW", False);  setSimpleProperty(w, a, value?fullscreen:0);}void KWM::setMaximize(Window w, bool value, int mode){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_MAXIMIZED", False);  setSimpleProperty(w, a, value?mode:0);}void KWM::doMaximize(Window w, bool value, int mode) {  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_MAXIMIZE_WINDOW", False);  setSimpleProperty(w, a, value?mode:0);}void KWM::setIconify(Window w, bool value){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_ICONIFIED", False);  setSimpleProperty(w, a, value?1:0);}void KWM::setSticky(Window w, bool value){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_WIN_STICKY", False);  setSimpleProperty(w, a, value?1:0);}void KWM::close(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "WM_DELETE_WINDOW", False);  static Atom ap = 0;  if (!ap)    ap = XInternAtom(qt_xdisplay(), "WM_PROTOCOLS", False);  // clients with WM_DELETE_WINDOW protocol set are  // closed via wm_delete_window ClientMessage.  // Others are destroyed.  Atom *p;  int i,n;  if (XGetWMProtocols(qt_xdisplay(), w, &p, &n)){    for (i = 0; i < n; i++){      if (p[i] == a){	sendClientMessage(w, ap, a);	XFree((char*)p);	return;      }    }    if (n>0)      XFree(p);  }  // client will not react on wm_delete_window. We have no choice  // but destroy his connection to the XServer.  XKillClient(qt_xdisplay(), w);}void KWM::activate(Window w){  if (desktop(w) != currentDesktop())    switchToDesktop(desktop(w));  if (isIconified(w))    setIconify(w, FALSE);  raise(w);  activateInternal(w);}void KWM::activateInternal(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_ACTIVATE_WINDOW", False);  sendClientMessage(qt_xrootwin(), a, (long) w);}void KWM::raise(Window w){  XRaiseWindow(qt_xdisplay(), w);}void KWM::lower(Window w){  XLowerWindow(qt_xdisplay(), w);}void KWM::prepareForSwallowing(Window w){  XWithdrawWindow(qt_xdisplay(), w, qt_xscreen());  while (getWindowState(w) != WithdrawnState);}void KWM::doNotManage(const QString& title){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_DO_NOT_MANAGE", False);  XEvent ev;  int status;  long mask;  memset(&ev, 0, sizeof(ev));  ev.xclient.type = ClientMessage;  ev.xclient.window = qt_xrootwin();  ev.xclient.message_type = a;  ev.xclient.format = 8;  int i;  const char* s = title.data();  for (i=0;i<19 && s[i];i++)    ev.xclient.data.b[i]=s[i];  mask = SubstructureRedirectMask;  status = XSendEvent(qt_xdisplay(),		      qt_xrootwin(),		      False, mask, &ev);}QString KWM::getMaximizeString(){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_STRING_MAXIMIZE", False);  QString result;  getQStringProperty(qt_xrootwin(), a, result);  return result;}QString KWM::getUnMaximizeString(){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_STRING_UNMAXIMIZE", False);  QString result;  getQStringProperty(qt_xrootwin(), a, result);  return result;}QString KWM::getIconifyString(){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_STRING_ICONIFY", False);  QString result;  getQStringProperty(qt_xrootwin(), a, result);  return result;}QString KWM::getUnIconifyString(){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_STRING_UNICONIFY", False);  QString result;  getQStringProperty(qt_xrootwin(), a, result);  return result;}QString KWM::getStickyString(){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_STRING_STICKY", False);  QString result;  getQStringProperty(qt_xrootwin(), a, result);  return result;}QString KWM::getUnStickyString(){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_STRING_UNSTICKY", False);  QString result;  getQStringProperty(qt_xrootwin(), a, result);  return result;}QString KWM::getMoveString(){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_STRING_MOVE", False);  QString result;  getQStringProperty(qt_xrootwin(), a, result);  return result;}QString KWM::getResizeString(){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_STRING_RESIZE", False);  QString result;  getQStringProperty(qt_xrootwin(), a, result);  return result;}QString KWM::getCloseString(){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_STRING_CLOSE", False);  QString result;  getQStringProperty(qt_xrootwin(), a, result);  return result;}QString KWM::getToDesktopString(){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_STRING_TODESKTOP", False);  QString result;  getQStringProperty(qt_xrootwin(), a, result);  return result;}QString KWM::getOntoCurrentDesktopString(){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_STRING_ONTOCURRENTDESKTOP", False);  QString result;  getQStringProperty(qt_xrootwin(), a, result);  return result;}bool KWM::isDockWindow(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "KWM_DOCKWINDOW", False);  long result = 0;  getSimpleProperty(w, a, result);  return result != 0;}int KWM::getWindowState(Window w){  static Atom a = 0;  if (!a)    a = XInternAtom(qt_xdisplay(), "WM_STATE", False);  long result = WithdrawnState;  getSimpleProperty(w, a, result);  return (int) result;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -