本文整理汇总了C++中DefaultRootWindow函数的典型用法代码示例。如果您正苦于以下问题:C++ DefaultRootWindow函数的具体用法?C++ DefaultRootWindow怎么用?C++ DefaultRootWindow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DefaultRootWindow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xf_CreateDummyWindow
Window xf_CreateDummyWindow(xfContext* xfc)
{
return XCreateSimpleWindow(xfc->display, DefaultRootWindow(xfc->display),
0, 0, 1, 1, 0, 0, 0);
}
示例2: winopen
static void winopen(void)
{
XWMHints *wmhints;
XClassHint *classhint;
xdpy = XOpenDisplay(NULL);
if (!xdpy)
winerror(&gapp, fz_throw("cannot open display"));
XA_TARGETS = XInternAtom(xdpy, "TARGETS", False);
XA_TIMESTAMP = XInternAtom(xdpy, "TIMESTAMP", False);
XA_UTF8_STRING = XInternAtom(xdpy, "UTF8_STRING", False);
WM_DELETE_WINDOW = XInternAtom(xdpy, "WM_DELETE_WINDOW", False);
xscr = DefaultScreen(xdpy);
ximage_init(xdpy, xscr, DefaultVisual(xdpy, xscr));
xcarrow = XCreateFontCursor(xdpy, XC_left_ptr);
xchand = XCreateFontCursor(xdpy, XC_hand2);
xcwait = XCreateFontCursor(xdpy, XC_watch);
xbgcolor.red = 0x7000;
xbgcolor.green = 0x7000;
xbgcolor.blue = 0x7000;
xshcolor.red = 0x4000;
xshcolor.green = 0x4000;
xshcolor.blue = 0x4000;
XAllocColor(xdpy, DefaultColormap(xdpy, xscr), &xbgcolor);
XAllocColor(xdpy, DefaultColormap(xdpy, xscr), &xshcolor);
xwin = XCreateWindow(xdpy, DefaultRootWindow(xdpy),
10, 10, 200, 100, 1,
ximage_get_depth(),
InputOutput,
ximage_get_visual(),
0,
NULL);
if (xwin == None)
winerror(&gapp, fz_throw("cannot create window"));
XSetWindowColormap(xdpy, xwin, ximage_get_colormap());
XSelectInput(xdpy, xwin,
StructureNotifyMask | ExposureMask | KeyPressMask |
PointerMotionMask | ButtonPressMask | ButtonReleaseMask);
mapped = 0;
xgc = XCreateGC(xdpy, xwin, 0, NULL);
XDefineCursor(xdpy, xwin, xcarrow);
wmhints = XAllocWMHints();
if (wmhints)
{
wmhints->flags = IconPixmapHint | IconMaskHint;
xicon = XCreateBitmapFromData(xdpy, xwin,
(char*)mupdf_icon_bitmap_16_bits,
mupdf_icon_bitmap_16_width,
mupdf_icon_bitmap_16_height);
xmask = XCreateBitmapFromData(xdpy, xwin,
(char*)mupdf_icon_bitmap_16_mask_bits,
mupdf_icon_bitmap_16_mask_width,
mupdf_icon_bitmap_16_mask_height);
if (xicon && xmask)
{
wmhints->icon_pixmap = xicon;
wmhints->icon_mask = xmask;
XSetWMHints(xdpy, xwin, wmhints);
}
XFree(wmhints);
}
classhint = XAllocClassHint();
if (classhint)
{
classhint->res_name = "mupdf";
classhint->res_class = "MuPDF";
XSetClassHint(xdpy, xwin, classhint);
XFree(classhint);
}
XSetWMProtocols(xdpy, xwin, &WM_DELETE_WINDOW, 1);
x11fd = ConnectionNumber(xdpy);
}
示例3: m_screen
CXWindowsScreenSaver::CXWindowsScreenSaver(
CXWindowsScreen* screen, Display* display) :
m_screen(screen),
m_display(display),
m_notify(None),
m_xscreensaver(None),
m_xscreensaverActive(false),
m_disabled(false),
m_suppressDisable(false),
m_disableJobInstalled(false)
{
// screen saver disable callback
m_disableJob = new TMethodJob<CXWindowsScreenSaver>(this,
&CXWindowsScreenSaver::disableCallback);
// get atoms
m_atomScreenSaver = XInternAtom(m_display,
"SCREENSAVER", False);
m_atomScreenSaverVersion = XInternAtom(m_display,
"_SCREENSAVER_VERSION", False);
m_atomScreenSaverActivate = XInternAtom(m_display,
"ACTIVATE", False);
m_atomScreenSaverDeactivate = XInternAtom(m_display,
"DEACTIVATE", False);
m_atomSynergyScreenSaver = XInternAtom(m_display,
"SYNERGY_SCREENSAVER", False);
// create dummy window to receive xscreensaver responses. this
// shouldn't be necessary (we should be able to send responses
// to None) but it doesn't hurt.
XSetWindowAttributes attr;
attr.event_mask = 0;//PropertyChangeMask;
attr.do_not_propagate_mask = 0;
attr.override_redirect = True;
m_xscreensaverSink = XCreateWindow(m_display,
DefaultRootWindow(m_display),
0, 0, 1, 1, 0, 0,
InputOnly, CopyFromParent,
CWDontPropagate | CWEventMask |
CWOverrideRedirect,
&attr);
LOG((CLOG_DEBUG "xscreensaver sink window is 0x%08x", m_xscreensaverSink));
// watch top-level windows for changes
{
bool error = false;
CXWindowsUtil::CErrorLock lock(m_display, &error);
Window root = DefaultRootWindow(m_display);
XWindowAttributes attr;
XGetWindowAttributes(m_display, root, &attr);
m_rootEventMask = attr.your_event_mask;
XSelectInput(m_display, root, m_rootEventMask | SubstructureNotifyMask);
if (error) {
LOG((CLOG_DEBUG "didn't set root event mask"));
m_rootEventMask = 0;
}
}
// get the xscreensaver window, if any
if (!findXScreenSaver()) {
setXScreenSaver(None);
}
// get the built-in settings
XGetScreenSaver(m_display, &m_timeout, &m_interval,
&m_preferBlanking, &m_allowExposures);
}
示例4: setstatus
void
setstatus(Display *dpy, char *str) {
XStoreName(dpy, DefaultRootWindow(dpy), str);
XSync(dpy, False);
}
示例5: X11_Init
int
X11_Init(void)
{
char buf[512];
char *displayname;
XGCValues gcvalues;
/* grrr, Xtk forced contortions */
char *argv[2];
int argc = 2;
if (cp_getvar("display", VT_STRING, buf)) {
displayname = buf;
} else if (!(displayname = getenv("DISPLAY"))) {
internalerror("Can't open X display.");
return (1);
}
# ifdef DEBUG
_Xdebug = 1;
# endif
argv[0] = "ngspice";
argv[1] = displayname;
/*
argv[2] = "-geometry";
argv[3] = "=1x1+2+2";
*/
/* initialize X toolkit */
toplevel = XtInitialize("ngspice", "Nutmeg", NULL, 0, &argc, argv);
display = XtDisplay(toplevel);
X11_Open = 1;
/* "invert" works better than "xor" for B&W */
/* xor gc should be a function of the pixels that are written on */
/* gcvalues.function = GXxor; */
/* this patch makes lines visible on true color displays
Guenther Roehrich 22-Jan-99 */
gcvalues.function = GXinvert;
gcvalues.line_width = 1;
gcvalues.foreground = 1;
gcvalues.background = 0;
xorgc = XCreateGC(display, DefaultRootWindow(display),
GCLineWidth | GCFunction | GCForeground | GCBackground,
&gcvalues);
/* set correct information */
dispdev->numlinestyles = NUMLINESTYLES;
dispdev->numcolors = NUMCOLORS;
dispdev->width = DisplayWidth(display, DefaultScreen(display));
dispdev->height = DisplayHeight(display, DefaultScreen(display));
/* we don't want non-fatal X errors to call exit */
XSetErrorHandler(errorhandler);
numdispplanes = DisplayPlanes(display, DefaultScreen(display));
return (0);
}
示例6: XInternAtom
bool CWinSystemX11::HasWindowManager()
{
Window wm_check;
unsigned char *data;
int status, real_format;
Atom real_type, prop;
unsigned long items_read, items_left;
prop = XInternAtom(m_dpy, "_NET_SUPPORTING_WM_CHECK", True);
if (prop == None)
return false;
status = XGetWindowProperty(m_dpy, DefaultRootWindow(m_dpy), prop,
0L, 1L, False, XA_WINDOW, &real_type, &real_format,
&items_read, &items_left, &data);
if(status != Success || ! items_read)
{
if(status == Success)
XFree(data);
return false;
}
wm_check = ((Window*)data)[0];
XFree(data);
status = XGetWindowProperty(m_dpy, wm_check, prop,
0L, 1L, False, XA_WINDOW, &real_type, &real_format,
&items_read, &items_left, &data);
if(status != Success || !items_read)
{
if(status == Success)
XFree(data);
return false;
}
if(wm_check != ((Window*)data)[0])
{
XFree(data);
return false;
}
XFree(data);
prop = XInternAtom(m_dpy, "_NET_WM_NAME", True);
if (prop == None)
{
CLog::Log(LOGDEBUG,"Window Manager Name: ");
return true;
}
status = XGetWindowProperty(m_dpy, wm_check, prop,
0L, (~0L), False, AnyPropertyType, &real_type, &real_format,
&items_read, &items_left, &data);
if(status == Success && items_read)
{
CLog::Log(LOGDEBUG,"Window Manager Name: %s", data);
}
else
CLog::Log(LOGDEBUG,"Window Manager Name: ");
if(status == Success)
XFree(data);
return true;
}
示例7: _cairo_boilerplate_gl_create_window_db
static cairo_surface_t *
_cairo_boilerplate_gl_create_window_db (const char *name,
cairo_content_t content,
double width,
double height,
double max_width,
double max_height,
cairo_boilerplate_mode_t mode,
int id,
void **closure)
{
int rgba_attribs[] = { GLX_RGBA,
GLX_RED_SIZE, 1,
GLX_GREEN_SIZE, 1,
GLX_BLUE_SIZE, 1,
GLX_ALPHA_SIZE, 1,
GLX_DOUBLEBUFFER,
None };
XVisualInfo *vi;
GLXContext ctx;
gl_target_closure_t *gltc;
cairo_surface_t *surface;
Display *dpy;
XSetWindowAttributes attr;
cairo_status_t status;
gltc = calloc (1, sizeof (gl_target_closure_t));
*closure = gltc;
if (width == 0)
width = 1;
if (height == 0)
height = 1;
dpy = XOpenDisplay (NULL);
gltc->dpy = dpy;
if (!gltc->dpy) {
fprintf (stderr, "Failed to open display: %s\n", XDisplayName(0));
free (gltc);
return NULL;
}
if (mode == CAIRO_BOILERPLATE_MODE_TEST)
XSynchronize (gltc->dpy, 1);
vi = glXChooseVisual (dpy, DefaultScreen (dpy), rgba_attribs);
if (vi == NULL) {
fprintf (stderr, "Failed to create RGBA, double-buffered visual\n");
XCloseDisplay (dpy);
free (gltc);
return NULL;
}
attr.colormap = XCreateColormap (dpy,
RootWindow (dpy, vi->screen),
vi->visual,
AllocNone);
attr.border_pixel = 0;
attr.override_redirect = True;
gltc->drawable = XCreateWindow (dpy, DefaultRootWindow (dpy), 0, 0,
width, height, 0, vi->depth,
InputOutput, vi->visual,
CWOverrideRedirect | CWBorderPixel | CWColormap,
&attr);
XMapWindow (dpy, gltc->drawable);
ctx = glXCreateContext (dpy, vi, NULL, True);
XFree (vi);
gltc->ctx = ctx;
gltc->device = cairo_glx_device_create (dpy, ctx);
gltc->surface = cairo_gl_surface_create_for_window (gltc->device,
gltc->drawable,
ceil (width),
ceil (height));
surface = cairo_surface_create_similar (gltc->surface, content, width, height);
status = cairo_surface_set_user_data (surface, &gl_closure_key, gltc, NULL);
if (status == CAIRO_STATUS_SUCCESS)
return surface;
cairo_surface_destroy (surface);
_cairo_boilerplate_gl_cleanup (gltc);
return cairo_boilerplate_surface_create_in_error (status);
}
示例8: preinit
static int preinit(struct vo *vo)
{
XvPortID xv_p;
int busy_ports = 0;
unsigned int i;
struct xvctx *ctx = vo->priv;
int xv_adaptor = ctx->cfg_xv_adaptor;
if (!vo_x11_init(vo))
return -1;
if (!vo_x11_create_vo_window(vo, NULL, "xv"))
goto error;
struct vo_x11_state *x11 = vo->x11;
/* check for Xvideo extension */
unsigned int ver, rel, req, ev, err;
if (Success != XvQueryExtension(x11->display, &ver, &rel, &req, &ev, &err)) {
MP_ERR(vo, "Xv not supported by this X11 version/driver\n");
goto error;
}
/* check for Xvideo support */
if (Success !=
XvQueryAdaptors(x11->display, DefaultRootWindow(x11->display),
&ctx->adaptors, &ctx->ai)) {
MP_ERR(vo, "XvQueryAdaptors failed.\n");
goto error;
}
/* check adaptors */
if (ctx->xv_port) {
int port_found;
for (port_found = 0, i = 0; !port_found && i < ctx->adaptors; i++) {
if ((ctx->ai[i].type & XvInputMask)
&& (ctx->ai[i].type & XvImageMask)) {
for (xv_p = ctx->ai[i].base_id;
xv_p < ctx->ai[i].base_id + ctx->ai[i].num_ports;
++xv_p) {
if (xv_p == ctx->xv_port) {
port_found = 1;
break;
}
}
}
}
if (port_found) {
if (XvGrabPort(x11->display, ctx->xv_port, CurrentTime))
ctx->xv_port = 0;
} else {
MP_WARN(vo, "Invalid port parameter, overriding with port 0.\n");
ctx->xv_port = 0;
}
}
for (i = 0; i < ctx->adaptors && ctx->xv_port == 0; i++) {
/* check if adaptor number has been specified */
if (xv_adaptor != -1 && xv_adaptor != i)
continue;
if ((ctx->ai[i].type & XvInputMask) && (ctx->ai[i].type & XvImageMask)) {
for (xv_p = ctx->ai[i].base_id;
xv_p < ctx->ai[i].base_id + ctx->ai[i].num_ports; ++xv_p)
if (!XvGrabPort(x11->display, xv_p, CurrentTime)) {
ctx->xv_port = xv_p;
MP_VERBOSE(vo, "Using Xv Adapter #%d (%s)\n",
i, ctx->ai[i].name);
break;
} else {
MP_WARN(vo, "Could not grab port %i.\n", (int) xv_p);
++busy_ports;
}
}
}
if (!ctx->xv_port) {
if (busy_ports)
MP_ERR(vo, "Xvideo ports busy.\n");
else
MP_ERR(vo, "No Xvideo support found.\n");
goto error;
}
if (!xv_init_colorkey(vo)) {
goto error; // bail out, colorkey setup failed
}
xv_enable_vsync(vo);
xv_get_max_img_dim(vo, &ctx->max_width, &ctx->max_height);
ctx->fo = XvListImageFormats(x11->display, ctx->xv_port,
(int *) &ctx->formats);
MP_WARN(vo, "Warning: this legacy VO has bad quality and performance, "
"and will in particular result in blurry OSD and subtitles. "
"You should fix your graphic drivers, or not force the xv VO.\n");
return 0;
error:
uninit(vo); // free resources
//.........这里部分代码省略.........
示例9: _x11_clip_filter
static int _x11_clip_filter(const SDL_Event *ev)
{
XSelectionRequestEvent *req;
XEvent sevent;
Atom seln_type;
int seln_format;
unsigned long nbytes;
unsigned long overflow;
unsigned char *seln_data;
unsigned char *src;
if (ev->type != SDL_SYSWMEVENT) return 1;
if (ev->syswm.msg->event.xevent.type == SelectionNotify) {
sevent = ev->syswm.msg->event.xevent;
if (sevent.xselection.requestor == SDL_Window) {
lock_display();
src = NULL;
if (XGetWindowProperty(SDL_Display, SDL_Window, atom_sel,
0, 9000, False, XA_STRING,
(Atom *)&seln_type,
(int *)&seln_format,
(unsigned long *)&nbytes,
(unsigned long *)&overflow,
(unsigned char **)&src) == Success) {
if (seln_type == XA_STRING) {
if (_current_selection != _current_clipboard) {
free(_current_clipboard);
}
_current_clipboard = mem_alloc(nbytes+1);
memcpy(_current_clipboard, (char*)src, nbytes);
_current_clipboard[nbytes] = 0;
_string_paste(CLIPPY_BUFFER, _current_clipboard);
_widget_owner[CLIPPY_BUFFER]
= _widget_owner[CLIPPY_SELECT];
}
XFree(src);
}
unlock_display();
}
return 1;
} else if (ev->syswm.msg->event.xevent.type == PropertyNotify) {
sevent = ev->syswm.msg->event.xevent;
return 1;
} else if (ev->syswm.msg->event.xevent.type != SelectionRequest) {
return 1;
}
req = &ev->syswm.msg->event.xevent.xselectionrequest;
sevent.xselection.type = SelectionNotify;
sevent.xselection.display = req->display;
sevent.xselection.selection = req->selection;
sevent.xselection.target = None;
sevent.xselection.property = None;
sevent.xselection.requestor = req->requestor;
sevent.xselection.time = req->time;
if (XGetWindowProperty(SDL_Display, DefaultRootWindow(SDL_Display),
XA_CUT_BUFFER0, 0, 9000, False, req->target,
&sevent.xselection.target, &seln_format,
&nbytes, &overflow, &seln_data) == Success) {
if (sevent.xselection.target == req->target) {
if (sevent.xselection.target == XA_STRING) {
if (nbytes && seln_data[nbytes-1] == '\0')
nbytes--;
}
XChangeProperty(SDL_Display, req->requestor, req->property,
sevent.xselection.target, seln_format, PropModeReplace,
seln_data, nbytes);
sevent.xselection.property = req->property;
}
XFree(seln_data);
}
XSendEvent(SDL_Display,req->requestor,False,0,&sevent);
XSync(SDL_Display, False);
return 1;
}
示例10: _clippy_copy_to_sys
static void _clippy_copy_to_sys(int do_sel)
{
int j;
char *dst;
char *freeme;
#if defined(__QNXNTO__)
PhClipboardHdr clheader = {Ph_CLIPBOARD_TYPE_TEXT, 0, NULL};
char *tmp;
int *cldata;
int status;
#endif
freeme = NULL;
if (!_current_selection) {
dst = NULL;
j = 0;
} else
#if defined(WIN32)
j = strlen(_current_selection);
#else
if (has_sys_clip) {
int i;
/* convert to local */
freeme = dst = malloc(strlen(_current_selection)+4);
if (!dst) return;
for (i = j = 0; _current_selection[i]; i++) {
dst[j] = _current_selection[i];
if (dst[j] != '\r') j++;
}
dst[j] = '\0';
} else {
dst = NULL;
j = 0;
}
#endif
#if defined(USE_X11)
if (has_sys_clip) {
lock_display();
if (!dst) dst = (char *) ""; /* blah */
if (j < 0) j = 0;
if (do_sel) {
if (XGetSelectionOwner(SDL_Display, XA_PRIMARY) != SDL_Window) {
XSetSelectionOwner(SDL_Display, XA_PRIMARY, SDL_Window, CurrentTime);
}
XChangeProperty(SDL_Display,
DefaultRootWindow(SDL_Display),
XA_CUT_BUFFER1, XA_STRING, 8,
PropModeReplace, (unsigned char *)dst, j);
} else {
if (XGetSelectionOwner(SDL_Display, atom_clip) != SDL_Window) {
XSetSelectionOwner(SDL_Display, atom_clip, SDL_Window, CurrentTime);
}
XChangeProperty(SDL_Display,
DefaultRootWindow(SDL_Display),
XA_CUT_BUFFER0, XA_STRING, 8,
PropModeReplace, (unsigned char *)dst, j);
XChangeProperty(SDL_Display,
DefaultRootWindow(SDL_Display),
XA_CUT_BUFFER1, XA_STRING, 8,
PropModeReplace, (unsigned char *)dst, j);
}
unlock_display();
}
#elif defined(WIN32)
if (!do_sel && OpenClipboard(SDL_Window)) {
_hmem = GlobalAlloc((GMEM_MOVEABLE|GMEM_DDESHARE), j+1);
if (_hmem) {
dst = (char *)GlobalLock(_hmem);
if (dst) {
/* this seems wrong, but msdn does this */
memcpy(dst, _current_selection, j);
dst[j] = '\0';
GlobalUnlock(_hmem);
EmptyClipboard();
SetClipboardData(CF_TEXT, _hmem);
}
}
CloseClipboard();
_hmem = NULL;
dst = 0;
}
#elif defined(__QNXNTO__)
if (!do_sel) {
tmp = (char *)malloc(j+4);
if (!tmp) {
cldata=(int*)tmp;
*cldata = Ph_CL_TEXT;
if (dst) memcpy(tmp+4, dst, j);
clheader.data = tmp;
#if (NTO_VERSION < 620)
if (clheader.length > 65535) clheader.length=65535;
#endif
clheader.length = j + 4;
#if (NTO_VERSION < 620)
PhClipboardCopy(inputgroup, 1, &clheader);
#else
PhClipboardWrite(inputgroup, 1, &clheader);
#endif
free(tmp);
}
//.........这里部分代码省略.........
示例11: GetIdleTime
int GetIdleTime(Display *dpy, XScreenSaverInfo *info){
XScreenSaverQueryInfo(dpy, DefaultRootWindow(dpy), info);
return (int)info->idle;
}
示例12: main
/*ARGSUSED*/
int
main(int argc, char *argv[]) {
XEvent ev;
XGCValues gv;
XSetWindowAttributes attr;
(void) argc;
argv0 = argv[0];
/* Open a connection to the X server. */
dpy = XOpenDisplay("");
if (dpy == 0)
Panic("can't open display.");
get_resources();
/* Find the screen's dimensions. */
display_width = DisplayWidth(dpy, DefaultScreen(dpy));
display_height = DisplayHeight(dpy, DefaultScreen(dpy));
/* Set up an error handler. */
XSetErrorHandler(ErrorHandler);
/* Get the pixel values of the only two colours we use. */
black = BlackPixel(dpy, DefaultScreen(dpy));
white = WhitePixel(dpy, DefaultScreen(dpy));
/* Get font. */
font = XLoadQueryFont(dpy, font_name);
if (font == 0)
font = XLoadQueryFont(dpy, "fixed");
if (font == 0)
Panic("can't find a font.");
/* Get a cursor. */
initCursor();
/* Create the window. */
root = DefaultRootWindow(dpy);
attr.override_redirect = True;
attr.background_pixel = white;
attr.border_pixel = black;
attr.cursor = mouse_cursor;
attr.event_mask = ExposureMask | VisibilityChangeMask |
ButtonMotionMask | PointerMotionHintMask |
ButtonPressMask | ButtonReleaseMask | StructureNotifyMask |
EnterWindowMask | LeaveWindowMask;
window = XCreateWindow(dpy, root,
0, 0,
display_width, 1.2 * (font->ascent + font->descent),
0, CopyFromParent, InputOutput, CopyFromParent,
CWOverrideRedirect | CWBackPixel | CWBorderPixel |
CWCursor | CWEventMask,
&attr);
/* Create GC. */
gv.foreground = black;
gv.background = white;
gv.font = font->fid;
gc = XCreateGC(dpy, window, GCForeground | GCBackground | GCFont,
&gv);
/* Create the menu items. */
readMenu();
/* Bring up the window. */
XMapRaised(dpy, window);
/* Make sure all our communication to the server got through. */
XSync(dpy, False);
/* The main event loop. */
for (;;) {
getEvent(&ev);
dispatch(&ev);
}
}
示例13: _DtGetHourGlassCursor
/*************************************<->*************************************
*
* Cursor _DtGetHourGlassCursor ()
*
*
* Description:
* -----------
* Builds and returns the appropriate Hourglass cursor
*
*
* Inputs:
* ------
* dpy = display
*
* Outputs:
* -------
* Return = cursor.
*
* Comments:
* --------
* None. (None doesn't count as a comment)
*
*************************************<->***********************************/
Cursor
_DtGetHourGlassCursor(
Display *dpy )
{
unsigned char *bits;
unsigned char *maskBits;
unsigned int width;
unsigned int height;
unsigned int xHotspot;
unsigned int yHotspot;
Pixmap pixmap;
Pixmap maskPixmap;
XColor xcolors[2];
int scr;
unsigned int cWidth;
unsigned int cHeight;
int useLargeCursors = 0;
static Cursor waitCursor=0;
_DtSvcProcessLock();
if (waitCursor != 0) {
_DtSvcProcessUnlock();
return(waitCursor);
}
if (XQueryBestCursor (dpy, DefaultRootWindow(dpy),
32, 32, &cWidth, &cHeight))
{
if ((cWidth >= 32) && (cHeight >= 32))
{
useLargeCursors = 1;
}
}
if (useLargeCursors)
{
width = time32_width;
height = time32_height;
bits = time32_bits;
maskBits = time32m_bits;
xHotspot = time32_x_hot;
yHotspot = time32_y_hot;
}
else
{
width = time16_width;
height = time16_height;
bits = time16_bits;
maskBits = time16m_bits;
xHotspot = time16_x_hot;
yHotspot = time16_y_hot;
}
pixmap = XCreateBitmapFromData (dpy,
DefaultRootWindow(dpy), (char*) bits,
width, height);
maskPixmap = XCreateBitmapFromData (dpy,
DefaultRootWindow(dpy), (char*) maskBits,
width, height);
xcolors[0].pixel = BlackPixelOfScreen(DefaultScreenOfDisplay(dpy));
xcolors[1].pixel = WhitePixelOfScreen(DefaultScreenOfDisplay(dpy));
XQueryColors (dpy,
DefaultColormapOfScreen(DefaultScreenOfDisplay
(dpy)), xcolors, 2);
waitCursor = XCreatePixmapCursor (dpy, pixmap, maskPixmap,
&(xcolors[0]), &(xcolors[1]),
xHotspot, yHotspot);
XFreePixmap (dpy, pixmap);
XFreePixmap (dpy, maskPixmap);
_DtSvcProcessUnlock();
return (waitCursor);
//.........这里部分代码省略.........
示例14: wxASSERT_MSG
bool wxTopLevelWindowGTK::Show( bool show )
{
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
bool deferShow = show && !m_isShown && m_deferShow;
if (deferShow)
{
deferShow = gs_requestFrameExtentsStatus != 2 &&
m_deferShowAllowed && !gtk_widget_get_realized(m_widget);
if (deferShow)
{
deferShow = g_signal_handler_find(m_widget,
GSignalMatchType(G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DATA),
g_signal_lookup("property_notify_event", GTK_TYPE_WIDGET),
0, NULL, NULL, this) != 0;
}
GdkScreen* screen = NULL;
if (deferShow)
{
#ifdef GDK_WINDOWING_X11
screen = gtk_widget_get_screen(m_widget);
GdkAtom atom = gdk_atom_intern("_NET_REQUEST_FRAME_EXTENTS", false);
deferShow = gdk_x11_screen_supports_net_wm_hint(screen, atom) != 0;
#else
deferShow = false;
#endif
// If _NET_REQUEST_FRAME_EXTENTS not supported, don't allow changes
// to m_decorSize, it breaks saving/restoring window size with
// GetSize()/SetSize() because it makes window bigger between each
// restore and save.
m_updateDecorSize = deferShow;
}
m_deferShow = deferShow;
}
if (deferShow)
{
// Initial show. If WM supports _NET_REQUEST_FRAME_EXTENTS, defer
// calling gtk_widget_show() until _NET_FRAME_EXTENTS property
// notification is received, so correct frame extents are known.
// This allows resizing m_widget to keep the overall size in sync with
// what wxWidgets expects it to be without an obvious change in the
// window size immediately after it becomes visible.
// Realize m_widget, so m_widget->window can be used. Realizing normally
// causes the widget tree to be size_allocated, which generates size
// events in the wrong order. However, the size_allocates will not be
// done if the allocation is not the default (1,1).
GtkAllocation alloc;
gtk_widget_get_allocation(m_widget, &alloc);
const int alloc_width = alloc.width;
if (alloc_width == 1)
{
alloc.width = 2;
gtk_widget_set_allocation(m_widget, &alloc);
}
gtk_widget_realize(m_widget);
if (alloc_width == 1)
{
alloc.width = 1;
gtk_widget_set_allocation(m_widget, &alloc);
}
#ifdef GDK_WINDOWING_X11
// send _NET_REQUEST_FRAME_EXTENTS
XClientMessageEvent xevent;
memset(&xevent, 0, sizeof(xevent));
xevent.type = ClientMessage;
GdkWindow* window = gtk_widget_get_window(m_widget);
xevent.window = GDK_WINDOW_XID(window);
xevent.message_type = gdk_x11_atom_to_xatom_for_display(
gdk_window_get_display(window),
gdk_atom_intern("_NET_REQUEST_FRAME_EXTENTS", false));
xevent.format = 32;
Display* display = GDK_DISPLAY_XDISPLAY(gdk_window_get_display(window));
XSendEvent(display, DefaultRootWindow(display), false,
SubstructureNotifyMask | SubstructureRedirectMask,
(XEvent*)&xevent);
#endif // GDK_WINDOWING_X11
if (gs_requestFrameExtentsStatus == 0)
{
// if WM does not respond to request within 1 second,
// we assume support for _NET_REQUEST_FRAME_EXTENTS is not working
m_netFrameExtentsTimerId =
g_timeout_add(1000, request_frame_extents_timeout, this);
}
// defer calling gtk_widget_show()
m_isShown = true;
return true;
}
if (show && !gtk_widget_get_realized(m_widget))
{
// size_allocate signals occur in reverse order (bottom to top).
// Things work better if the initial wxSizeEvents are sent (from the
// top down), before the initial size_allocate signals occur.
wxSizeEvent event(GetSize(), GetId());
event.SetEventObject(this);
//.........这里部分代码省略.........
示例15: main
//.........这里部分代码省略.........
opt_tab[2].argKind = XrmoptionSepArg;
opt_tab[2].value = (XPointer) NULL;
/* filter option entry */
opt_tab[3].option = xcstrdup("-filter");
opt_tab[3].specifier = xcstrdup(".filter");
opt_tab[3].argKind = XrmoptionNoArg;
opt_tab[3].value = (XPointer) xcstrdup(ST);
/* in option entry */
opt_tab[4].option = xcstrdup("-in");
opt_tab[4].specifier = xcstrdup(".direction");
opt_tab[4].argKind = XrmoptionNoArg;
opt_tab[4].value = (XPointer) xcstrdup("I");
/* out option entry */
opt_tab[5].option = xcstrdup("-out");
opt_tab[5].specifier = xcstrdup(".direction");
opt_tab[5].argKind = XrmoptionNoArg;
opt_tab[5].value = (XPointer) xcstrdup("O");
/* version option entry */
opt_tab[6].option = xcstrdup("-version");
opt_tab[6].specifier = xcstrdup(".print");
opt_tab[6].argKind = XrmoptionNoArg;
opt_tab[6].value = (XPointer) xcstrdup("V");
/* help option entry */
opt_tab[7].option = xcstrdup("-help");
opt_tab[7].specifier = xcstrdup(".print");
opt_tab[7].argKind = XrmoptionNoArg;
opt_tab[7].value = (XPointer) xcstrdup("H");
/* silent option entry */
opt_tab[8].option = xcstrdup("-silent");
opt_tab[8].specifier = xcstrdup(".olevel");
opt_tab[8].argKind = XrmoptionNoArg;
opt_tab[8].value = (XPointer) xcstrdup("S");
/* quiet option entry */
opt_tab[9].option = xcstrdup("-quiet");
opt_tab[9].specifier = xcstrdup(".olevel");
opt_tab[9].argKind = XrmoptionNoArg;
opt_tab[9].value = (XPointer) xcstrdup("Q");
/* verbose option entry */
opt_tab[10].option = xcstrdup("-verbose");
opt_tab[10].specifier = xcstrdup(".olevel");
opt_tab[10].argKind = XrmoptionNoArg;
opt_tab[10].value = (XPointer) xcstrdup("V");
/* utf8 option entry */
opt_tab[11].option = xcstrdup("-noutf8");
opt_tab[11].specifier = xcstrdup(".noutf8");
opt_tab[11].argKind = XrmoptionNoArg;
opt_tab[11].value = (XPointer) xcstrdup("N");
/* target option entry */
opt_tab[12].option = xcstrdup("-target");
opt_tab[12].specifier = xcstrdup(".target");
opt_tab[12].argKind = XrmoptionSepArg;
opt_tab[12].value = (XPointer) NULL;
/* parse command line options */
doOptMain(argc, argv);
/* Connect to the X server. */
if ((dpy = XOpenDisplay(sdisp))) {
/* successful */
if (fverb == OVERBOSE)
fprintf(stderr, "Connected to X server.\n");
}
else {
/* couldn't connect to X server. Print error and exit */
errxdisplay(sdisp);
}
/* parse selection command line option */
doOptSel();
/* parse noutf8 and target command line options */
doOptTarget();
/* Create a window to trap events */
win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 0, 0, 1, 1, 0, 0, 0);
/* get events about property changes */
XSelectInput(dpy, win, PropertyChangeMask);
if (fdiri)
exit_code = doIn(win, argv[0]);
else
exit_code = doOut(win);
/* Disconnect from the X server */
XCloseDisplay(dpy);
/* exit */
return exit_code;
}