DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
True Drop Box
FTP/SFTP Hosting
Group Account
Team Anywhere
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Cloud-to-Cloud Backup
|
DVR/Camera Backup
FTP, Email & Web Service
FTP/SFTP Hosting
|
Email Hosting
|
Web Hosting
|
Webcam Hosting
Cloud Surveillance & Remote Desktop
Team Anywhere
|
Access Remote PC
|
Cloud Surveillance
|
Virtual CCTV NVR
Quick Links
Security and Privacy
Customer Support
Service Manual
Use Cases
Group Account
Online Help
Support Forum
Contact Us
About DriveHQ
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
Cloud Surveillance & Remote Desktop
Team Anywhere (Remote Desktop Service)
CameraFTP Cloud Surveillance
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
CameraFTP Software & Apps
DriveHQ Team Anywhere
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
CameraFTP Cloud Recording Service Plans
DriveHQ Team Anywhere Service Plans
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Sign up
Help
Support Home
Support Forum
Service Manual
Online Help
Tutorial videos
Remote Support
About DriveHQ
Contact
CameraFTP Support
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
/* * xwindow.c * * Copyright (c) 1995 Silicon Graphics, Inc. * * Permission to use, copy, modify, distribute, and sell this software and * its documentation for any purpose is hereby granted without fee, * provided that (i) the above copyright notices and this permission * notice appear in all copies of the software and related documentation, * and (ii) the name of Silicon Graphics may not be used in any * advertising or publicity relating to the software without the specific, * prior written permission of Silicon Graphics. * * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. * * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, * INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY * DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER * OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. * * $Revision: 1.3 $ */ #include
#include
#include
#include
#include "xwindow.h" /* ARGSUSED dpy */ Bool waitForMapNotify(Display *dpy, XEvent *ev, XPointer arg) { return (ev->type == MapNotify && ev->xmapping.window == *((Window *) arg)); } void createWindowAndContext(Display **dpy, Window *win, GLXContext *cx, int xpos, int ypos, int width, int height, GLboolean pref, XSizeHints *hints, int *prefVisualAttr, int *secVisualAttr, char *title) { XSetWindowAttributes swa; Colormap cmap; XVisualInfo *vi; int isRgba; int i; /* get a connection */ *dpy = XOpenDisplay(NULL); if (*dpy == NULL) { fprintf(stderr, "Can't connect to display `%s'\n", getenv("DISPLAY")); exit(EXIT_FAILURE); } /* get an appropriate visual */ vi = glXChooseVisual(*dpy, DefaultScreen(*dpy), prefVisualAttr); if (vi == NULL) { /* Try secondary attribute list */ if (secVisualAttr != NULL) { vi = glXChooseVisual(*dpy, DefaultScreen(*dpy), secVisualAttr); } if (vi == NULL) { fprintf(stderr, "No matching visual on display `%s'\n", getenv("DISPLAY")); exit(EXIT_FAILURE); } } (void) glXGetConfig(*dpy, vi, GLX_RGBA, &isRgba); /* create a GLX context */ if ((*cx = createContext(*dpy, vi)) == NULL) { exit(EXIT_FAILURE); } /* create a colormap (it's empty for rgba visuals) */ cmap = XCreateColormap(*dpy, RootWindow(*dpy, vi->screen), vi->visual, isRgba ? AllocNone : AllocAll); if (cmap == NULL) { fprintf(stderr,"Cannot create a colormap.\n"); exit(EXIT_FAILURE); } /* fill the colormap with something simple */ if (!isRgba) { static char *cnames[] = { "black","red","green","yellow","blue","magenta","cyan","white" }; for (i = 0; i < sizeof(cnames)/sizeof(cnames[0]); i++) { XStoreNamedColor(*dpy, cmap, cnames[i], i, DoRed|DoGreen|DoBlue); } } /* create a window */ swa.colormap = cmap; swa.border_pixel = 0; swa.event_mask = StructureNotifyMask | ButtonPressMask | KeyPressMask | ExposureMask; *win = XCreateWindow(*dpy, RootWindow(*dpy, vi->screen), xpos, ypos, width, height, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &swa); if (*win == NULL) { fprintf(stderr,"Cannot create a window.\n"); exit(EXIT_FAILURE); } XStoreName(*dpy, *win, title); /* handle "prefposition" style window */ if (pref) { XSizeHints hints; hints.flags = USPosition|USSize; /*was PPosition|PSize which doesn't work*/ hints.x = xpos; hints.y = ypos; hints.width = width; hints.height = height; XSetNormalHints(*dpy, *win,&hints); } else if (hints != NULL) XSetNormalHints(*dpy, *win, hints); mapWindowAndWait(*dpy, *win); /* Connect the context to the window */ if (!glXMakeCurrent(*dpy, *win, *cx)) { fprintf(stderr, "Can't make window current to context\n"); exit(EXIT_FAILURE); } /* Free memory */ XFree( vi ); } void mapWindowAndWait(Display *dpy, Window win) { XEvent event; XMapWindow(dpy, win); XIfEvent(dpy, &event, waitForMapNotify, (XPointer) &win); } /* * simple mouse button polling code for X */ int xGetButton(int button, Display *dpy, Window win) { Window root,child; int x,y; unsigned int m; unsigned int mask = 0; int ok; switch (button) { case 1: mask = Button1Mask; break; case 2: mask = Button2Mask; break; case 3: mask = Button3Mask; break; } ok = XQueryPointer(dpy, win, &root, &child, &x, &y, &x, &y, &m); return ok && (m & mask); } /* * Create a context and print stuff on failure. */ GLXContext createContext(Display *dpy, XVisualInfo *vi) { GLXContext cx; /* create a GLX context */ if ((cx = glXCreateContext(dpy, vi, 0, GL_TRUE)) == NULL) fprintf(stderr,"Cannot create a context.\n"); return cx; }
xwindow.c
Page URL
File URL
Prev
49/50
Next
Download
( 5 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.