SysInfo: Improved screengrab

git-svn-id: svn://ultimatepp.org/upp/trunk@7551 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
koldo 2014-07-29 07:53:29 +00:00
parent ccae012f96
commit 791b333539
3 changed files with 21 additions and 22 deletions

View file

@ -626,37 +626,28 @@ Array <NetAdapter> GetAdapterInfo() {
Array<NetAdapter> GetAdapterInfo() {
Array<NetAdapter> res;
char buf[8192] = {0};
struct ifconf ifc = {0};
struct ifreq *ifr = NULL;
int sck = 0;
int nInterfaces = 0;
int i = 0;
char ip[INET6_ADDRSTRLEN] = {0};
struct ifreq *item;
struct sockaddr *addr;
socklen_t salen;
char hostname[NI_MAXHOST];
sck = socket(PF_INET, SOCK_DGRAM, 0);
int sck = socket(PF_INET, SOCK_DGRAM, 0);
if(sck < 0)
return res;
char buf[8192] = {0};
struct ifconf ifc = {0};
ifc.ifc_len = sizeof(buf);
ifc.ifc_buf = buf;
if(ioctl(sck, SIOCGIFCONF, &ifc) < 0)
return res;
ifr = ifc.ifc_req;
nInterfaces = ifc.ifc_len / sizeof(struct ifreq);
for(i = 0; i < nInterfaces; i++) {
struct ifreq *ifr = ifc.ifc_req;
int nInterfaces = ifc.ifc_len / sizeof(struct ifreq);
for(int i = 0; i < nInterfaces; i++) {
String MAC;
char hostname[NI_MAXHOST];
bzero(hostname, NI_MAXHOST);
item = &ifr[i];
addr = &(item->ifr_addr);
struct ifreq *item = &ifr[i];
struct sockaddr *addr = &(item->ifr_addr);
socklen_t salen;
switch(addr->sa_family) {
case AF_INET: salen = sizeof(struct sockaddr_in); break;
case AF_INET6: salen = sizeof(struct sockaddr_in6); break;
@ -671,6 +662,7 @@ Array<NetAdapter> GetAdapterInfo() {
NetAdapter &adapter = res.Add();
adapter.description = hostname;
char ip[INET6_ADDRSTRLEN] = {0};
switch(addr->sa_family) {
case AF_INET: inet_ntop(AF_INET, &(((struct sockaddr_in *)addr)->sin_addr), ip, INET6_ADDRSTRLEN);
adapter.ip4 = ip;

View file

@ -57,6 +57,8 @@ void GetWindowsList(Upp::Array<int64> &wid, Upp::Array<int64> &pid, Upp::Array<S
Upp::Array<String> &fileName, Upp::Array<String> &title);
Upp::Array<int64> GetWindowsList();
Rect GetDesktopRect();
bool Window_GetRect(int64 windowId, long &left, long &top, long &right, long &bottom);
bool Window_SetRect(int64 windowId, long left, long top, long right, long bottom);
void Window_Bottom(int64 windowId);

View file

@ -519,8 +519,10 @@ Image Window_SaveCapture(int64 windowId, int left, int top, int width, int heigh
windowId = RootWindow(dpy, screen);
else {
windowId = GetToplevelParent(dpy, windowId);
if (windowId < 0)
if (windowId < 0) {
SetX11ErrorHandler();
return Null;
}
}
XWindowAttributes rc;
@ -539,9 +541,12 @@ Image Window_SaveCapture(int64 windowId, int left, int top, int width, int heigh
if (height == -1)
height = rc.height;
XImage *image = XGetImage(dpy, windowId, 0, 0, width, height, XAllPlanes(), ZPixmap);
if (image == NULL)
XImage *image = XGetImage(dpy, windowId, left, top, width, height, XAllPlanes(), ZPixmap);
if (image == NULL) {
XCloseDisplay(dpy);
SetX11ErrorHandler();
return Null;
}
ImageBuffer ib(width, height);