void nsBox::PropagateDebug(nsBoxLayoutState& aState) { // propagate debug information if (mState & NS_STATE_DEBUG_WAS_SET) { if (mState & NS_STATE_SET_TO_DEBUG) SetDebug(aState, PR_TRUE); else SetDebug(aState, PR_FALSE); } else if (mState & NS_STATE_IS_ROOT) { SetDebug(aState, gDebug); } }
NS_IMETHODIMP nsMenuFrame::InsertFrames(nsIAtom* aListName, nsIFrame* aPrevFrame, nsFrameList& aFrameList) { if (!mPopupFrame && (!aListName || aListName == nsGkAtoms::popupList)) { SetPopupFrame(aFrameList); if (mPopupFrame) { #ifdef DEBUG_LAYOUT nsBoxLayoutState state(PresContext()); SetDebug(state, aFrameList, mState & NS_STATE_CURRENTLY_IN_DEBUG); #endif PresContext()->PresShell()-> FrameNeedsReflow(this, nsIPresShell::eTreeChange, NS_FRAME_HAS_DIRTY_CHILDREN); } } if (aFrameList.IsEmpty()) return NS_OK; if (NS_UNLIKELY(aPrevFrame == mPopupFrame)) { aPrevFrame = nsnull; } return nsBoxFrame::InsertFrames(aListName, aPrevFrame, aFrameList); }
int main(int argc, char *argv[]) { int argPos = 0, argNum = argc; initMemInfo(); for (argPos = 1; argPos < argNum;) { if (NCcmArgTest(argv[argPos], "-d", "--debug")) { SetDebug(); NCcmArgShiftLeft(argPos, argv, argc); argNum--; continue; } if (NCcmArgTest(argv[argPos], "-h", "--help")) { if (argv[argPos + 1][0] == 'e') do_help(NCcmProgName(argv[0]), true); else do_help(NCcmProgName(argv[0]), false); cleanup(NCsucceeded); } if (NCcmArgTest(argv[argPos], "- ", "-- ")) { NCcmArgShiftLeft(argPos, argv, argc); argNum--; continue; } if ((argv[argPos][0] == '-') && (strlen(argv[argPos]) > 1)) { CMmsgPrint(CMmsgUsrError, "Unknown option: %s!", argv[argPos]); cleanup(NCfailed); } argPos++; } cleanup(NCsucceeded); }
int main(int argc, char* argv[]) { int argPos = 0, argNum = argc, ncid; char *fname = (char *) NULL, *tname = "time"; FILE *output = stdout; NCtable_t *tbl = (NCtable_t *) NULL; initMemInfo(); for(argPos = 1; argPos < argNum;) { if (CMargTest(argv[argPos],"-d","--debug")) { SetDebug(); CMargShiftLeft(argPos,argv,argc); argNum--; continue; } if (CMargTest(argv[argPos],"-h","--help")) { if((argPos + 1 < argNum) && (argv[argPos+1][0] == 'e')) doHelp (CMprgName(argv[0]),true); else doHelp (CMprgName (argv[0]),false); cleanup(NCsucceeded); } if (CMargTest(argv[argPos],"-t","--table")) { CMargShiftLeft(argPos,argv,argc); argNum--; tname = argv[argPos]; CMargShiftLeft(argPos,argv,argc); argNum--; continue; } if (CMargTest(argv[argPos],"-f","--file")) { if ((argNum = CMargShiftLeft(argPos,argv,argc)) <= argPos) { CMmsgPrint (CMmsgUsrError,"Missing file!"); return (CMfailed); } fname = argv[argPos]; if ((argNum = CMargShiftLeft(argPos,argv,argc)) <= argPos) break; continue; } if (CMargTest(argv[argPos],"-o","--output")) { if ((argNum = CMargShiftLeft(argPos,argv,argc)) <= argPos) { CMmsgPrint (CMmsgUsrError,"Missing output!"); return (CMfailed); } if(output != stdout) { CMmsgPrint (CMmsgUsrError, "Output file defined twice!"); cleanup(NCfailed); } if((output = fopen(argv[argPos],"w")) == (FILE *) NULL) { CMmsgPrint (CMmsgUsrError, "Cannot open for writing: %s",argv[argPos]); cleanup(NCfailed); } if ((argNum = CMargShiftLeft(argPos,argv,argc)) <= argPos) break; continue; } if ((argv[argPos][0] == '-') && (strlen (argv[argPos]) > 1)) { CMmsgPrint (CMmsgUsrError, "Unknown option: %s!",argv[argPos]); cleanup(NCfailed); } argPos++; } if(fname == (char *) NULL) { doHelp(argv[0],false); CMmsgPrint (CMmsgUsrError, "No file specified!"); cleanup(NCfailed); } if(nc_open(fname,NC_NOWRITE,&ncid) != NC_NOERR) { CMmsgPrint (CMmsgUsrError, "Error opening file!"); cleanup(NCfailed); } if((tbl = NCtableOpen(ncid,tname)) == (NCtable_t *) NULL) { CMmsgPrint (CMmsgUsrError, "Error opening table!"); cleanup(NCfailed); } if(GetDebug()) CMmsgPrint (CMmsgUsrError, "Loaded file!"); NCtableExportAscii(tbl,output); cleanup(NCsucceeded); }
AParticle::AParticle(const AParticle& apart) { SetID(apart.GetID()); SetParticleName(apart.GetParticleName()); SetIsPrimary(apart.GetIsPrimary()); SetCharge(apart.GetCharge()); SetVertex(apart.GetVertex()); SetP4(apart.GetP4()); SetMotherID(apart.GetMotherId()); SetDebug(apart.GetDebug()); std::map <std::string, std::string> props = apart.GetProperties(); for (auto prop : props) SetProperty(prop.first, prop.second); }
NS_IMETHODIMP nsMenuFrame::SetDebug(nsBoxLayoutState& aState, PRBool aDebug) { // see if our state matches the given debug state PRBool debugSet = mState & NS_STATE_CURRENTLY_IN_DEBUG; PRBool debugChanged = (!aDebug && debugSet) || (aDebug && !debugSet); // if it doesn't then tell each child below us the new debug state if (debugChanged) { nsBoxFrame::SetDebug(aState, aDebug); if (mPopupFrame) SetDebug(aState, mPopupFrame, aDebug); } return NS_OK; }
NS_IMETHODIMP nsSliderFrame::DoLayout(nsBoxLayoutState& aState) { // get the thumb should be our only child nsIBox* thumbBox = GetChildBox(); if (!thumbBox) { SyncLayout(aState); return NS_OK; } EnsureOrient(); #ifdef DEBUG_LAYOUT if (mState & NS_STATE_DEBUG_WAS_SET) { if (mState & NS_STATE_SET_TO_DEBUG) SetDebug(aState, PR_TRUE); else SetDebug(aState, PR_FALSE); } #endif // get the content area inside our borders nsRect clientRect; GetClientRect(clientRect); // get the scrollbar nsIBox* scrollbarBox = GetScrollbar(); nsCOMPtr<nsIContent> scrollbar; scrollbar = GetContentOfBox(scrollbarBox); // get the thumb's pref size nsSize thumbSize = thumbBox->GetPrefSize(aState); if (IsHorizontal()) thumbSize.height = clientRect.height; else thumbSize.width = clientRect.width; PRInt32 curPos = GetCurrentPosition(scrollbar); PRInt32 minPos = GetMinPosition(scrollbar); PRInt32 maxPos = GetMaxPosition(scrollbar); PRInt32 pageIncrement = GetPageIncrement(scrollbar); maxPos = NS_MAX(minPos, maxPos); curPos = NS_MAX(minPos, NS_MIN(curPos, maxPos)); nscoord& availableLength = IsHorizontal() ? clientRect.width : clientRect.height; nscoord& thumbLength = IsHorizontal() ? thumbSize.width : thumbSize.height; if ((pageIncrement + maxPos - minPos) > 0 && thumbBox->GetFlex(aState) > 0) { float ratio = float(pageIncrement) / float(maxPos - minPos + pageIncrement); thumbLength = NS_MAX(thumbLength, NSToCoordRound(availableLength * ratio)); } // Round the thumb's length to device pixels. nsPresContext* presContext = PresContext(); thumbLength = presContext->DevPixelsToAppUnits( presContext->AppUnitsToDevPixels(thumbLength)); // mRatio translates the thumb position in app units to the value. mRatio = (minPos != maxPos) ? float(availableLength - thumbLength) / float(maxPos - minPos) : 1; // in reverse mode, curpos is reversed such that lower values are to the // right or bottom and increase leftwards or upwards. In this case, use the // offset from the end instead of the beginning. PRBool reverse = mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::dir, nsGkAtoms::reverse, eCaseMatters); nscoord pos = reverse ? (maxPos - curPos) : (curPos - minPos); // set the thumb's coord to be the current pos * the ratio. nsRect thumbRect(clientRect.x, clientRect.y, thumbSize.width, thumbSize.height); PRInt32& thumbPos = (IsHorizontal() ? thumbRect.x : thumbRect.y); thumbPos += NSToCoordRound(pos * mRatio); nsRect oldThumbRect(thumbBox->GetRect()); LayoutChildAt(aState, thumbBox, thumbRect); SyncLayout(aState); // Redraw only if thumb changed size. if (oldThumbRect != thumbRect) Redraw(aState); return NS_OK; }
int main(int argc, char* argv[]) { char *filename = (char *) NULL, *rename = (char *) NULL, *varname = (char *) NULL; int argPos = 0, argNum = argc, interval = NONE, ncid = 0, *dimIDs = (int *) NULL; // NCdsHandle_t *dsHandle; if(argNum == 1) { doHelp(CMfileName(argv[0])); return (NCsucceeded); } if ((argNum == 2) && (argv[1][0] == '-')) { if (CMargTest (argv[1],"-d","--debug")) SetDebug(); doHelp(CMfileName(argv[0])); return (NCsucceeded); } initMemInfo(); for(argPos = 1; argPos < argNum;) { if (CMargTest(argv[argPos],"-d","--debug")) { SetDebug(); CMargShiftLeft(argPos,argv,argc); argNum--; continue; } if (CMargTest(argv[argPos],"-h","--help")) { doHelp(CMfileName(argv[0])); cleanup(NCsucceeded); } if (CMargTest(argv[argPos],"-f","--file")) { if ((argNum = CMargShiftLeft(argPos,argv,argc)) <= argPos) { CMmsgPrint (CMmsgUsrError,"Missing file!"); return (CMfailed); } filename = argv[argPos]; if ((argNum = CMargShiftLeft(argPos,argv,argc)) <= argPos) break; continue; } if (CMargTest(argv[argPos],"-r","--rename")) { if ((argNum = CMargShiftLeft(argPos,argv,argc)) <= argPos) { CMmsgPrint (CMmsgUsrError,"Missing name!"); return (CMfailed); } if(rename == (char *) NULL) rename = argv[argPos]; else { CMmsgPrint (CMmsgUsrError, "Output field name defined twice!"); cleanup(NCfailed); } if ((argNum = CMargShiftLeft(argPos,argv,argc)) <= argPos) break; continue; } if (CMargTest(argv[argPos],"-s","--set")) { if ((argNum = CMargShiftLeft(argPos,argv,argc)) <= argPos) { CMmsgPrint (CMmsgUsrError,"Time step!"); return (CMfailed); } if(interval != NONE) { CMmsgPrint (CMmsgUsrError, "Interval already set!"); cleanup(NCfailed); } if(NCmathIsNumber(argv[argPos])) interval = atoi(argv[argPos]); else if (strcmp(argv[argPos],"hour") == 0) interval = HOUR; else if (strcmp(argv[argPos],"day") == 0) interval = DAY; else if (strcmp(argv[argPos],"month") == 0) interval = MONTH; else if (strcmp(argv[argPos],"year") == 0) interval = YEAR; else { CMmsgPrint (CMmsgUsrError, "Undefined time interval '%s'",argv[argPos]); cleanup(NCfailed); } if ((argNum = CMargShiftLeft(argPos,argv,argc)) <= argPos) { CMmsgPrint (CMmsgUsrError,"Missing variable!"); return (CMfailed); } if(varname == (char *) NULL) varname = argv[argPos]; else { CMmsgPrint (CMmsgUsrError, "Input field name defined twice!"); cleanup(NCfailed); } if ((argNum = CMargShiftLeft(argPos,argv,argc)) <= argPos) break; continue; } if ((argv[argPos][0] == '-') && (strlen (argv[argPos]) > 1)) { CMmsgPrint (CMmsgUsrError, "Unknown option: %s!",argv[argPos]); cleanup(NCfailed); } argPos++; } if(interval == NONE) { CMmsgPrint (CMmsgUsrError, "Invalid interval!"); cleanup(NCfailed); } if (filename != (char *) NULL) { if(nc_open(filename,NC_WRITE,&ncid) != NC_NOERR) { CMmsgPrint (CMmsgAppError, "Error opening file: %s!",filename); return (NCfailed); } } else if ((argNum > 1) && (strcmp(argv[1],"-") != 0)) { if(nc_open(argv[1],NC_WRITE,&ncid) != NC_NOERR) { CMmsgPrint (CMmsgUsrError, "Error opening file: %s!",argv[1]); return (NCfailed); } } else doHelp(CMfileName(argv[0])); // dsHandle = NCdsHandleOpenById (ncid); /* if((nc_inq_varid(ncid,varname,&inVar)) != NC_NOERR) { CMmsgPrint (CMmsgUsrError, "NC: Error getting varID!"); cleanup(NCfailed); } if(nc_inq_ndims(ncid,&ndims) != NC_NOERR) { CMmsPrint (CMmsgAppError, "Cannot get the ndims!",__FILE__,__LINE__); cleanup(NCfailed); } dimIDs = malloc(sizeof(int) * ndims); if((nc_inq_vardimid(ncid,inVar,dimIDs)) != NC_NOERR) { CMmsgPrint (CMmsgUsrError, "NC: Error getting dimIDs!"); cleanup(NCfailed); } if(nc_redef(ncid) != NC_NOERR) { CMmsgPrint (CMmsgAppError, "Cannot place into redef mode!"); cleanup(NCfailed); } CMmsgPrint (CMmsgUsrError, "id=%d ndims=%d, dimIDs[0]=%d dimIDs[1]=%d dimIDs[2]=%d",ncid,ndims, dimIDs[0],dimIDs[1],dimIDs[2]); if(rename == (char *) NULL) { if((nc_def_var(ncid,"Aggregate",NC_DOUBLE,ndims,dimIDs,&outVar)) != NC_NOERR) { CMmsgPrint (CMmsgUsrError, "NC: Error creating new variable!"); cleanup(NCfailed); } } else { if((nc_def_var(ncid,rename,NC_DOUBLE,ndims,dimIDs,&outVar)) != NC_NOERR) { CMmsgPrint (CMmsgUsrError, "NC: Error creating new variable!"); cleanup(NCfailed); } } CMmsgPrint (CMmsgUsrError, "id=%d ndims=%d, dimIDs[0]=%d dimIDs[1]=%d dimIDs[2]=%d",ncid,ndims, dimIDs[0],dimIDs[1],dimIDs[2]); //if(nc_enddef(ncid) != NC_NOERR) { CMmsgPrint (CMmsgAppError, "Cannot get out of redef mode!"); cleanup(NCfailed); } cleanup(NCsucceeded); if((nc_inq_dimlen(ncid,dimIDs[0],&bLen)) != NC_NOERR) { CMmsgPrint (CMmsgUsrError, "NC: Error getting length of dimension!"); cleanup(NCfailed); } for(i = 0; i < bLen; i++) { idx[0] = i; if(nc_get_var1_double(ncid,inVar,idx, &val) != NC_NOERR) { CMmsgPrint (CMmsgUsrError, "NC: There's a problem getting a value!"); cleanup(NCfailed); } printf("inVar: %d, outVar: %d, val: %f",inVar,outVar,val); }*/ // for (i = 0; i < dsHandle->ColNum * dsHandle->RowNum * dsHandle->TimeNum; i++) printf("i: %f",data[i]); cleanup(NCsucceeded); }
/* Runs the host editor. Another big use for this is to open sites * that are in your host list. */ int HostWindow(void) { int c; char cmd[256]; volatile BookmarkPtr toOpen; vsigproc_t si; int maxy, maxx; int lmaxy; si = (sigproc_t) (-1); if (gWinInit) { gHostListWin = NULL; gHostWin = NULL; gHostWin = newwin(LINES, COLS, 0, 0); if (gHostWin == NULL) return (-1); curs_set(0); cbreak(); /* Set the clear flag for the first update. */ wclear(gHostWin); keypad(gHostWin, TRUE); /* For arrow keys. */ #ifdef HAVE_NOTIMEOUT notimeout(gHostWin, TRUE); #endif #ifdef HAVE_SIGSETJMP if (sigsetjmp(gHostWinJmp, 1) == 0) { #else /* HAVE_SIGSETJMP */ if (setjmp(gHostWinJmp) == 0) { #endif /* HAVE_SIGSETJMP */ /* Gracefully cleanup the screen if the user ^C's. */ si = NcSignal(SIGINT, SigIntHostWin); /* Initialize the page start and select a host to be * the current one. */ gHostListWinStart = 0; gHilitedHost = 0; if (gNumBookmarks == 0) gCurHostListItem = NULL; else gCurHostListItem = &gBookmarkTable[gHilitedHost]; /* Initially, we don't want to connect to any site in * the host list. */ toOpen = NULL; getmaxyx(gHostWin, maxy, maxx); WAttr(gHostWin, kBold, 1); WAddCenteredStr(gHostWin, 0, "NcFTP Bookmark Editor"); WAttr(gHostWin, kBold, 0); DrawStrAt(gHostWin, 3, 2, "Open selected site: <enter>"); DrawStrAt(gHostWin, 4, 2, "Edit selected site: /ed"); DrawStrAt(gHostWin, 5, 2, "Delete selected site: /del"); DrawStrAt(gHostWin, 6, 2, "Duplicate selected site: /dup"); DrawStrAt(gHostWin, 7, 2, "Add a new site: /new"); DrawStrAt(gHostWin, 9, 2, "Up one: <u>"); DrawStrAt(gHostWin, 10, 2, "Down one: <d>"); DrawStrAt(gHostWin, 11, 2, "Previous page: <p>"); DrawStrAt(gHostWin, 12, 2, "Next page: <n>"); DrawStrAt(gHostWin, 14, 2, "Capital letters selects first"); DrawStrAt(gHostWin, 15, 2, " site starting with the letter."); DrawStrAt(gHostWin, 17, 2, "Exit the bookmark editor: <x>"); /* Initialize the scrolling host list window. */ if (maxx < 110) { gHostListWinWide = 0; gHostListWin = subwin( gHostWin, LINES - 7, 40, 3, COLS - 40 - 2 ); } else { gHostListWinWide = COLS - 42; gHostListWin = subwin( gHostWin, LINES - 7, gHostListWinWide, 3, 38 ); } if (gHostListWin == NULL) return (-1); lmaxy = getmaxy(gHostListWin); gHostListPageSize = lmaxy; DrawHostList(); wmove(gHostWin, maxy - 1, 0); UpdateHostWindows(1); for (;;) { c = HostWinGetKey(); if (gNeedToClearMsg) { wmove(gHostWin, maxy - 2, 0); wclrtoeol(gHostWin); wrefresh(gHostWin); } if ((c >= 'A') && (c <= 'Z')) { /* isupper can coredump if wgetch returns a meta key. */ HostWinZoomTo(c); } else if (c == '/') { /* Get an "extended" command. Sort of like vi's * :colon commands. */ HostWinGetStr(cmd, sizeof(cmd)); if (ISTREQ(cmd, "ed")) HostWinEdit(); else if (ISTREQ(cmd, "dup")) HostWinDup(); else if (ISTREQ(cmd, "del")) HostWinDelete(); else if (ISTREQ(cmd, "new")) HostWinNew(); else HostWinMsg("Invalid bookmark editor command."); } else switch(c) { case 10: /* ^J == newline */ goto enter; case 13: /* ^M == carriage return */ goto enter; #ifdef KEY_ENTER case KEY_ENTER: Trace(1, " [0x%04X, %s]\n", c, "ENTER"); #endif enter: if (gCurHostListItem == NULL) HostWinMsg("Nothing to open. Try 'open sitename' from the main screen."); else { toOpen = (BookmarkPtr) gCurHostListItem; goto done; } break; case kControl_L: UpdateHostWindows(1); break; case 'u': case 'k': /* vi up key */ case 'h': /* vi left key */ HostListLineUp(); break; #ifdef KEY_UP case KEY_UP: Trace(1, " [0x%04X, %s]\n", c, "UP"); HostListLineUp(); break; #endif #ifdef KEY_LEFT case KEY_LEFT: Trace(1, " [0x%04X, %s]\n", c, "LEFT"); HostListLineUp(); break; #endif case 'd': case 'j': /* vi down key */ case 'l': /* vi right key */ HostListLineDown(); break; #ifdef KEY_DOWN case KEY_DOWN: Trace(1, " [0x%04X, %s]\n", c, "DOWN"); HostListLineDown(); break; #endif #ifdef KEY_RIGHT case KEY_RIGHT: Trace(1, " [0x%04X, %s]\n", c, "RIGHT"); HostListLineDown(); break; #endif case 'p': HostListPageUp(); break; #ifdef KEY_PPAGE case KEY_PPAGE: Trace(1, " [0x%04X, %s]\n", c, "PPAGE"); HostListPageUp(); break; #endif case 'n': HostListPageDown(); break; #ifdef KEY_NPAGE case KEY_NPAGE: Trace(1, " [0x%04X, %s]\n", c, "NPAGE"); HostListPageDown(); break; #endif case 'x': case 'q': goto done; default: HostWinMsg("Invalid key."); Trace(1, " [0x%04X, %s]\n", c, "<invalid>"); break; } } } NcSignal(SIGINT, (FTPSigProc) SIG_IGN); done: if (gHostListWin != NULL) delwin(gHostListWin); if (gHostWin != NULL) delwin(gHostWin); gHostListWin = gHostWin = NULL; if (si != (sigproc_t) (-1)) NcSignal(SIGINT, si); if (toOpen != (BookmarkPtr) 0) { /* If the user selected a site to open, connect to it now. */ if (gStandAlone != 0) { LaunchNcFTP(toOpen->bookmarkName); /*NOTREACHED*/ Exit(0); } else if (gBookmarkSelectionFile != NULL) { WriteSelectedBMToFile(toOpen->bookmarkName); } return (kNoErr); } } return (kNoErr); } /* HostWindow */ main_void_return_t main(int argc, const char **argv) { int result; int argi; gStandAlone = 1; gBookmarkSelectionFile = NULL; InitUserInfo(); if (LoadBookmarkTable() < 0) { exit(7); } if (argc > 1) { /* The following hack is used by NcFTP * to get the number of columns without * having to link with curses/termcap. * This simplifies things since the * system may or may not have a good * curses implementation, and we don't * want to complicate NcFTP itself with * that. */ argi = 1; if (strcmp(argv[1], "--dimensions") == 0) { result = PrintDimensions(0); exit((result == 0) ? 0 : 1); } else if (strcmp(argv[1], "--dimensions-terse") == 0) { result = PrintDimensions(1); exit((result == 0) ? 0 : 1); } else if (strcmp(argv[1], "--debug") == 0) { SetDebug(1); argi++; } /* Requested that we were run from ncftp. */ gStandAlone = 0; if ((argc > argi) && (argv[argi][0] == '/')) gBookmarkSelectionFile = (const char *) argv[argi]; if (gNumBookmarks < 1) exit(7); } result = FTPInitLibrary(&gLib); if (result < 0) { (void) fprintf(stderr, "ncftp: init library error %d (%s).\n", result, FTPStrError(result)); exit(1); } result = FTPInitConnectionInfo(&gLib, &gConn, kDefaultFTPBufSize); if (result < 0) { (void) fprintf(stderr, "ncftp: init connection info error %d (%s).\n", result, FTPStrError(result)); exit(1); } if (gDebug > 0) OpenTrace(); InitPrefs(); LoadFirewallPrefs(0); LoadPrefs(); InitWindows(); Trace(1, "Terminal size is %d columns by %d rows.\n", gScreenWidth, gScreenHeight); HostWindow(); if (gDebug > 0) CloseTrace(); EndWin(); exit(0); } /* main */
int main(int argc, char *argv[]) { int next_option; const char *const short_options = "hvad:i:mn:w:o:"; const struct option long_options[] = { { "help", 0, NULL, 'h' }, { "verbose", 0, NULL, 'v' }, { "all", 0, NULL, 'a' }, { "display", 1, NULL, 'd' }, { "id", 1, NULL, 'i' }, { "mouse", 0, NULL, 'm' }, { "name", 1, NULL, 'n' }, { "wid", 1, NULL, 'w' }, { "opacity", 1, NULL, 'o' }, { NULL, 0, NULL, 0 } }; int verbose = 0; program_name = argv[0]; double vopacity; unsigned int opacity; char *display_name = NULL; char *window_name = NULL; pid_t pid = 0; unsigned use_mouse = 1; unsigned all = 0; Window wid = 0; unsigned char *data = NULL; Atom actual; int format; unsigned long n, left; do { next_option = getopt_long(argc, argv, short_options, long_options, NULL); switch (next_option) { case 'h': print_usage(stdout, 0); case 'v': verbose = 1; break; case 'd': display_name = optarg; break; case 'i': pid = atoi(optarg); use_mouse = 0; break; case 'm': use_mouse = 1; break; case 'n': window_name = optarg; use_mouse = 0; break; case 'w': wid = atoi(optarg); use_mouse = 0; break; case 'o': vopacity = atof(optarg); opacity = 1; break; case 'a': all = 1; pid = 0; wid = 0; window_name = NULL; break; case '?': print_usage(stderr, 1); case -1: break; default: abort(); } } while (next_option != -1); if (verbose) SetDebug(1); Display *dpy = Open_Display (display_name); unsigned screen = DefaultScreen(dpy); if (opacity) { opacity = (unsigned int) (vopacity * OPAQUE); } else { XGetWindowProperty(dpy, target_win, XInternAtom(dpy, OPACITY, False), 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left, (unsigned char **) &data); if (data != NULL) { memcpy (&opacity, data, sizeof (unsigned int)); XFree(( void *) data ); if (verbose) fprintf(stdout, "Found property: %g\n", (double) opacity / OPAQUE); } else opacity = OPAQUE; if (opacity != OPAQUE) opacity = OPAQUE; else opacity = 0xc0000000; } if (verbose) fprintf(stdout, "opacity 0x%x\n", opacity); if (!all) { if (use_mouse) { if(verbose) fprintf(stdout, "Using mouse for selection.\n"); target_win = Select_Window_by_Mouse(dpy); if(verbose) fprintf(stdout, "Window id : %lu(0x%lx)\n", target_win, target_win); } else if (wid) { if(verbose) fprintf(stdout, "Using window id for selection.\n"); target_win = wid; } else if (pid) { if(verbose) fprintf(stdout, "Using process id for selection.\n"); target_win = Get_Window_by_PID(dpy, pid); if(target_win) target_win = Get_Top_Window(dpy, target_win); if(verbose) fprintf(stdout, "Window id : %lu(0x%lx)\n", target_win, target_win); } else if (window_name != NULL) { if(verbose) fprintf(stdout, "Using window name for selection.\n"); target_win = Get_Window_by_Name(dpy, DefaultRootWindow(dpy), window_name); if(target_win) target_win = Get_Top_Window(dpy, target_win); if(verbose) fprintf(stdout, "Window id : %lu(0x%lx)\n", target_win, target_win); } if ((opacity == OPAQUE)&&(target_win != 0)) XDeleteProperty (dpy, target_win, XInternAtom(dpy, OPACITY, False)); else if (target_win != 0) XChangeProperty(dpy, target_win, XInternAtom(dpy, OPACITY, False), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1L); } if (all) { Get_All_Windows(dpy); while(!STACKempty()) { if (opacity == OPAQUE) XDeleteProperty (dpy, STACKpop(), XInternAtom(dpy, OPACITY, False)); else XChangeProperty(dpy, STACKpop(), XInternAtom(dpy, OPACITY, False), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &opacity, 1L); } } XSync(dpy, False); if(verbose) fprintf(stdout, "Set Property to %g\n", (double) opacity / OPAQUE); return EXIT_SUCCESS; }