void ModeParser::DisplayCurrentModes(User *user, User* targetuser, Channel* targetchannel, const char* text) { if (targetchannel) { /* Display channel's current mode string */ user->WriteNumeric(RPL_CHANNELMODEIS, "%s %s +%s",user->nick.c_str(), targetchannel->name.c_str(), targetchannel->ChanModes(targetchannel->HasUser(user))); user->WriteNumeric(RPL_CHANNELCREATED, "%s %s %lu", user->nick.c_str(), targetchannel->name.c_str(), (unsigned long)targetchannel->age); return; } else { if (targetuser == user || user->HasPrivPermission("users/auspex")) { /* Display user's current mode string */ user->WriteNumeric(RPL_UMODEIS, "%s :+%s",targetuser->nick.c_str(),targetuser->FormatModes()); if ((targetuser->IsOper())) { ModeHandler* snomask = FindMode('s', MODETYPE_USER); user->WriteNumeric(RPL_SNOMASKIS, "%s %s :Server notice mask", targetuser->nick.c_str(), snomask->GetUserParameter(user).c_str()); } return; } else { user->WriteNumeric(ERR_USERSDONTMATCH, "%s :Can't view modes for other users", user->nick.c_str()); return; } } }
ModResult Call(User* user, Channel* chan, const std::string& restriction) { unsigned int mypfx = chan->GetPrefixValue(user); std::string minmode; ListModeBase::ModeList* list = ec.GetList(chan); if (list) { for (ListModeBase::ModeList::iterator i = list->begin(); i != list->end(); ++i) { std::string::size_type pos = (*i).mask.find(':'); if (pos == std::string::npos) continue; if ((*i).mask.substr(0,pos) == restriction) minmode = (*i).mask.substr(pos + 1); } } PrefixMode* mh = FindMode(minmode); if (mh && mypfx >= mh->GetPrefixRank()) return MOD_RES_ALLOW; if (mh || minmode == "*") return MOD_RES_DENY; return ServerInstance->HandleOnCheckExemption.Call(user, chan, restriction); }
PrefixMode* ModeParser::FindPrefixMode(unsigned char modeletter) { ModeHandler* mh = FindMode(modeletter, MODETYPE_CHANNEL); if (!mh) return NULL; return mh->IsPrefixMode(); }
ModResult AccessCheck(User* source, Channel* channel, std::string ¶meter, bool adding) { std::string::size_type pos = parameter.find(':'); if (pos == 0 || pos == std::string::npos) return adding ? MOD_RES_DENY : MOD_RES_PASSTHRU; unsigned int mylevel = channel->GetPrefixValue(source); std::string mid = parameter.substr(0, pos); ModeHandler* mh = FindMode(mid); if (adding && (!mh || !mh->GetPrefixRank())) { source->WriteNumeric(415, "%s %s :Cannot find prefix mode '%s' for autoop", source->nick.c_str(), mid.c_str(), mid.c_str()); return MOD_RES_DENY; } else if (!mh) return MOD_RES_PASSTHRU; std::string dummy; if (mh->AccessCheck(source, channel, dummy, true) == MOD_RES_DENY) return MOD_RES_DENY; if (mh->GetLevelRequired() > mylevel) { source->WriteNumeric(482, "%s %s :You must be able to set mode '%s' to include it in an autoop", source->nick.c_str(), channel->name.c_str(), mid.c_str()); return MOD_RES_DENY; } return MOD_RES_PASSTHRU; }
BOOLEAN XlateTable::AddLitEscSeq(UNCH mdin, UNCH *seqin, ostream &s){ XlateTableRec* trc = FindMode(mdin); XlateEntryData* p = trc->InsertEntry(seqin); if (p->s[0] == '\0') {p->t = LITCOPY; p->s[0] = 0;} else { ResFile->ResMessage(CONFLICTMSGRESOURCE, s); return FALSE; } return TRUE; };
int EBuffer::ChangeKeys(const char *AMode) { if ((Mode = FindMode(AMode)) != NULL) { HilitProc = 0; if (Mode->fColorize) HilitProc = GetHilitProc(Mode->fColorize->SyntaxParser); FullRedraw(); return 1; } Msg(S_ERROR, "Mode '%s' not found.", AMode); return 0; }
int EBuffer::ChangeFlags(const char *AMode) { if (EMode *XMode = FindMode(AMode)) { Flags = XMode->Flags; HilitProc = 0; if (Mode && Mode->fColorize) HilitProc = GetHilitProc(Mode->fColorize->SyntaxParser); FullRedraw(); return 1; } Msg(S_ERROR, "Mode '%s' not found.", AMode); return 0; }
static int SwitchRes(char inout, int x __UNUSED__, int y __UNUSED__, int w, int h, int *dw, int *dh) { XRRScreenResources *xsr; XRRCrtcInfo *xci; RRCrtc crtc; RRMode ss_mode_new; int ok = 0; Dprintf("%s: inout=%d\n", __func__, inout); xsr = XRRGetScreenResourcesCurrent(disp, WinGetXwin(VROOT)); if (!xsr) goto done; crtc = xsr->crtcs[0]; /* FIXME - Which crtc? */ if (inout) { /* Save current setup */ xci = XRRGetCrtcInfo(disp, xsr, crtc); if (!xci) goto done; ss_mode = xci->mode; ss_rot = xci->rotation; XRRFreeCrtcInfo(xci); /* Select zoomed setup */ ss_mode_new = FindMode(xsr, w, h, dw, dh); /* Set zoomed setup */ SetPanning(xsr, crtc, 1); ok = SetMode(xsr, crtc, ss_mode_new, ss_rot); } else { /* Revert to original setup */ ok = SetMode(xsr, crtc, ss_mode, ss_rot); SetPanning(xsr, crtc, 0); } done: if (xsr) XRRFreeScreenResources(xsr); Dprintf("%s: ok=%d\n", __func__, ok); return ok; }
bool WindowsDisplay::GetBestMode( DisplayMode& result ) const noexcept { if ( output == nullptr ) { return false; } DXGI_OUTPUT_DESC desc; output->GetDesc( &desc ); DisplayMode mode; mode.width = static_cast< int >( desc.DesktopCoordinates.right - desc.DesktopCoordinates.left ); mode.height = static_cast< int >( desc.DesktopCoordinates.bottom - desc.DesktopCoordinates.top ); mode.refreshRateNumerator = 1000; mode.refreshRateDenominator = 1; return FindMode( mode, result ); }
BOOLEAN XlateTable::InsertXlateMode(UNCH mdin, UNCH mdout, UNCH * seqin, DupHanType DupWhat, ostream & s){ XlateTableRec* trc = FindMode(mdin); XlateEntryData* p = trc->InsertEntry(seqin); if ((p->s[0] == '\0') || (DupWhat == UpdateEntry)) { p->t = MODE; ustrcpy(p->s, seqin); p->m = mdout;} else if (((p->t == MODE)||(p->s[0] != '\0')) && (DupWhat == GiveError)) { ResFile->ResMessage(CONFLICTMSGRESOURCE, s); return FALSE; } return TRUE; }
int EView::FileOpenInMode(ExState &State) { char Mode[32] = ""; char FName[MAXPATH]; if (State.GetStrParam(this, Mode, sizeof(Mode)) == 0) if (MView->Win->GetStr("Mode", sizeof(Mode), Mode, HIST_SETUP) != 1) return 0; if (FindMode(Mode) == 0) { MView->Win->Choice(GPC_ERROR, "Error", 1, "O&K", "Invalid mode '%s'", Mode); return 0; } if (GetDefaultDirectory(Model, FName, sizeof(FName)) == 0) return 0; if (State.GetStrParam(this, FName, sizeof(FName)) == 0) if (MView->Win->GetFile("Open file", sizeof(FName), FName, HIST_PATH, GF_OPEN) == 0) return 0; if (IsDirectory(FName)) return OpenDir(FName); if (strlen(FName) == 0) return 0; return MultiFileLoad(0, FName, Mode, this); }
int main(int argc, char *argv[]) { int i; IncludePathEntry *inc, *inc_head, **inc_tail; char *file_basename = NULL; ModeData *mode = NULL; gboolean create_old_typelib = FALSE; /* turn this on for extra checking of our code */ /* IDL_check_cast_enable(TRUE); */ inc_head = xpidl_malloc(sizeof *inc); #ifndef XP_MAC inc_head->directory = "."; #else inc_head->directory = ""; #endif inc_head->next = NULL; inc_tail = &inc_head->next; for (i = 1; i < argc; i++) { if (argv[i][0] != '-') break; switch (argv[i][1]) { case '-': argc++; /* pretend we didn't see this */ /* fall through */ case 0: /* - is a legal input filename (stdin) */ goto done_options; case 'a': emit_typelib_annotations = TRUE; break; case 'w': enable_warnings = TRUE; break; case 'v': verbose_mode = TRUE; break; case 't': { /* Parse for "-t version number" and store it into global boolean * and string variables. */ const gchar* typelib_version_string = NULL; /* * If -t is the last argument on the command line, we have a problem */ if (i + 1 == argc) { fprintf(stderr, "ERROR: missing version number after -t\n"); xpidl_usage(argc, argv); return 1; } /* Do not allow more than one "-t" definition */ if (create_old_typelib) { fprintf(stderr, "ERROR: -t argument used twice. " "Cannot specify more than one version\n"); xpidl_usage(argc, argv); return 1; } /* * Assume that the argument after "-t" is the version number string * and search for it in our internal list of acceptable version * numbers. */ switch (XPT_ParseVersionString(argv[++i], &major_version, &minor_version)) { case XPT_VERSION_CURRENT: break; case XPT_VERSION_OLD: create_old_typelib = TRUE; break; case XPT_VERSION_UNSUPPORTED: fprintf(stderr, "ERROR: version \"%s\" not supported.\n", argv[i]); xpidl_usage(argc, argv); return 1; case XPT_VERSION_UNKNOWN: default: fprintf(stderr, "ERROR: version \"%s\" not recognised.\n", argv[i]); xpidl_usage(argc, argv); return 1; } break; } case 'I': if (argv[i][2] == '\0' && i == argc) { fputs("ERROR: missing path after -I\n", stderr); xpidl_usage(argc, argv); return 1; } inc = xpidl_malloc(sizeof *inc); if (argv[i][2] == '\0') { /* is it the -I foo form? */ inc->directory = argv[++i]; } else { /* must be the -Ifoo form. Don't preincrement i. */ inc->directory = argv[i] + 2; } #ifdef DEBUG_shaver_includes fprintf(stderr, "adding %s to include path\n", inc->directory); #endif inc->next = NULL; *inc_tail = inc; inc_tail = &inc->next; break; case 'o': if (i == argc) { fprintf(stderr, "ERROR: missing basename after -o\n"); xpidl_usage(argc, argv); return 1; } file_basename = argv[++i]; explicit_output_filename = FALSE; break; case 'e': if (i == argc) { fprintf(stderr, "ERROR: missing basename after -e\n"); xpidl_usage(argc, argv); return 1; } file_basename = argv[++i]; explicit_output_filename = TRUE; break; case 'm': if (i + 1 == argc) { fprintf(stderr, "ERROR: missing modename after -m\n"); xpidl_usage(argc, argv); return 1; } if (mode) { fprintf(stderr, "ERROR: must specify exactly one mode " "(first \"%s\", now \"%s\")\n", mode->mode, argv[i + 1]); xpidl_usage(argc, argv); return 1; } mode = FindMode(argv[++i]); if (!mode) { fprintf(stderr, "ERROR: unknown mode \"%s\"\n", argv[i]); xpidl_usage(argc, argv); return 1; } break; default: fprintf(stderr, "unknown option %s\n", argv[i]); xpidl_usage(argc, argv); return 1; } } done_options: if (!mode) { fprintf(stderr, "ERROR: must specify output mode\n"); xpidl_usage(argc, argv); return 1; } if (argc != i + 1) { fprintf(stderr, "ERROR: extra arguments after input file\n"); } /* * Don't try to process multiple files, given that we don't handle -o * multiply. */ if (xpidl_process_idl(argv[i], inc_head, file_basename, mode)) return 0; return 1; }
static int ReadConfigFile(CurPos &cp) { unsigned char obj; unsigned short len; { const char *p; obj = GetObj(cp, len); assert(obj == CF_STRING); if ((p = GetCharStr(cp, len)) == 0) return -1; if (ConfigSourcePath) free(ConfigSourcePath); ConfigSourcePath = strdup(p); } while ((obj = GetObj(cp, len)) != 0xFF) { switch (obj) { case CF_SUB: { const char *CmdName = GetCharStr(cp, len); if (ReadCommands(cp, CmdName) == -1) return -1; } break; case CF_MENU: { const char *MenuName = GetCharStr(cp, len); if (ReadMenu(cp, MenuName) == -1) return -1; } break; case CF_EVENTMAP: { EEventMap *EventMap = 0; const char *MapName = GetCharStr(cp, len); const char *UpMap = 0; if ((obj = GetObj(cp, len)) != CF_PARENT) return -1; if (len > 0) if ((UpMap = GetCharStr(cp, len)) == 0) return -1; // add new mode if ((EventMap = FindEventMap(MapName)) == 0) { EEventMap *OrgMap = 0; if (strcmp(UpMap, "") != 0) OrgMap = FindEventMap(UpMap); EventMap = new EEventMap(MapName, OrgMap); } else { if (EventMap->Parent == 0) EventMap->Parent = FindEventMap(UpMap); } if (ReadEventMap(cp, EventMap, MapName) == -1) return -1; } break; case CF_COLORIZE: { EColorize *Mode = 0; const char *ModeName = GetCharStr(cp, len); const char *UpMode = 0; if ((obj = GetObj(cp, len)) != CF_PARENT) return -1; if (len > 0) if ((UpMode = GetCharStr(cp, len)) == 0) return -1; // add new mode if ((Mode = FindColorizer(ModeName)) == 0) Mode = new EColorize(ModeName, UpMode); else { if (Mode->Parent == 0) Mode->Parent = FindColorizer(UpMode); } if (ReadColorize(cp, Mode, ModeName) == -1) return -1; } break; case CF_MODE: { EMode *Mode = 0; const char *ModeName = GetCharStr(cp, len); const char *UpMode = 0; if ((obj = GetObj(cp, len)) != CF_PARENT) return -1; if (len > 0) if ((UpMode = GetCharStr(cp, len)) == 0) return -1; // add new mode if ((Mode = FindMode(ModeName)) == 0) { EMode *OrgMode = 0; EEventMap *Map; if (strcmp(UpMode, "") != 0) OrgMode = FindMode(UpMode); Map = FindEventMap(ModeName); if (Map == 0) { EEventMap *OrgMap = 0; if (strcmp(UpMode, "") != 0) OrgMap = FindEventMap(UpMode); Map = new EEventMap(ModeName, OrgMap); } Mode = new EMode(OrgMode, Map, ModeName); Mode->fNext = Modes; Modes = Mode; } else { if (Mode->fParent == 0) Mode->fParent = FindMode(UpMode); } if (ReadMode(cp, Mode, ModeName) == -1) return -1; } break; case CF_OBJECT: { const char *ObjName; if ((ObjName = GetCharStr(cp, len)) == 0) return -1; if (ReadObject(cp, ObjName) == -1) return -1; } break; case CF_EOF: return 0; default: return -1; } } return -1; }
int MFDisplay_CreateDisplay(int width, int height, int bpp, int rate, bool vsync, bool triplebuffer, bool wide, bool progressive) { MFCALLSTACK; MFZeroMemory(gXKeys, sizeof(gXKeys)); MFZeroMemory(&gXMouse, sizeof(gXMouse)); gXMouse.x = -1; gDisplay.fullscreenWidth = gDisplay.width = width; gDisplay.fullscreenHeight = gDisplay.height = height; gDisplay.refreshRate = 0; gDisplay.colourDepth = 0; /* Use default. Chances are, it's something sane */ gDisplay.windowed = true; gDisplay.wide = false; gDisplay.progressive = true; if(!(xdisplay = XOpenDisplay(NULL))) { MFDebug_Error("Unable to open display"); MFDisplay_DestroyDisplay(); return 1; } screen = DefaultScreen(xdisplay); rootWindow = RootWindow(xdisplay, screen); // build our internal list of available video modes GetModes(&modes, !gDisplay.windowed); while(!FindMode(modes, width, height)) { if(!gDisplay.windowed) { // no fullscreen mode, try windowed mode instead MFDebug_Warn(1, "No suitable modes for fullscreen mode, trying windowed mode"); gDisplay.windowed = true; FreeModes(); GetModes(&modes, false); } else { // default is some sort of custom mode that doesn't appear in the windowed mode list // HACK: we'll add it to the end.. modes[numModes].width = width; modes[numModes].height = height; currentMode = numModes; ++numModes; break; } } DebugMenu_AddItem("Resolution", "Display Options", &resSelect, ChangeResCallback); DebugMenu_AddItem("Apply", "Display Options", &applyDisplayMode, ApplyDisplayModeCallback); // Set full screen mode, if necessary if(!gDisplay.windowed && numModes > 1) { if(!XF86VidModeSwitchToMode(xdisplay, screen, vidModes[currentMode])) { MFDebug_Error("Unable to switch screenmodes, defaulting to windowed mode"); MFDisplay_DestroyDisplay(); return 1; } } XVisualInfo *MFRenderer_GetVisualInfo(); XVisualInfo *visualInfo = MFRenderer_GetVisualInfo(); if(!visualInfo) return 1; if(!(colorMap = XCreateColormap(xdisplay, rootWindow, visualInfo->visual, AllocNone))) { MFDebug_Error("Unable to create colourmap"); XFree(visualInfo); MFDisplay_DestroyDisplay(); return 1; } XSetWindowAttributes windowAttrs; windowAttrs.colormap = colorMap; windowAttrs.cursor = None; windowAttrs.event_mask = StructureNotifyMask; windowAttrs.border_pixel = BlackPixel(xdisplay, screen); windowAttrs.background_pixel = BlackPixel(xdisplay, screen); if(!(window = XCreateWindow(xdisplay, rootWindow, 0, 0, width, height, 0, visualInfo->depth, InputOutput, visualInfo->visual, CWBackPixel | CWBorderPixel | CWCursor | CWColormap | CWEventMask, &windowAttrs))) { MFDebug_Error("Unable to create X Window"); XFree(visualInfo); MFDisplay_DestroyDisplay(); return 1; } // Tell the window manager not to allow our window to be resized. But some window managers can ignore me and do it anyway. Typical X-Windows. if((sizeHints = XAllocSizeHints()) == NULL) { MFDebug_Error("Unable to alloc XSizeHints structure, out of memory?"); XFree(visualInfo); MFDisplay_DestroyDisplay(); return 1; } sizeHints->flags = PSize | PMinSize | PMaxSize; sizeHints->min_width = sizeHints->max_width = sizeHints->base_width = width; sizeHints->min_height = sizeHints->max_height = sizeHints->base_height = height; XSetWMNormalHints(xdisplay, window, sizeHints); // Window title XStoreName(xdisplay, window, gDefaults.display.pWindowTitle); XWMHints *wmHints; if((wmHints = XAllocWMHints()) == NULL) { MFDebug_Error("Unable to alloc XWMHints structure, out of memory?"); XFree(visualInfo); MFDisplay_DestroyDisplay(); return 1; } wmHints->flags = InputHint | StateHint; wmHints->input = true; wmHints->initial_state = NormalState; if(!XSetWMHints(xdisplay, window, wmHints)) { MFDebug_Error("Unable to set WM hints for window"); XFree(visualInfo); MFDisplay_DestroyDisplay(); return 1; } XFree(wmHints); XFree(visualInfo); // Tell the window manager that I want to be notified if the window's closed wm_delete_window = XInternAtom(xdisplay, "WM_DELETE_WINDOW", false); if(!XSetWMProtocols(xdisplay, window, &wm_delete_window, 1)) { MFDebug_Error("Unable to set Window Manager protocols"); MFDisplay_DestroyDisplay(); return 1; } XSelectInput(xdisplay, window, KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask | PointerMotionMask | StructureNotifyMask | ExposureMask); if(!XMapRaised(xdisplay, window)) { MFDebug_Error("Unable to map new window"); MFDisplay_DestroyDisplay(); return 1; } // Wait for the window to be mapped, etc. The documentation doesn't indicate that this is necessary, but every GLX program I've ever seen does it, so I assume it is. XEvent event; XIfEvent(xdisplay, &event, WaitForNotify, (char *)window); MFRenderer_CreateDisplay(); if(!gDisplay.windowed && numModes > 1) { if(!XF86VidModeSwitchToMode(xdisplay, screen, vidModes[currentMode])) { MFDebug_Error("Unable to set screen mode"); MFDisplay_DestroyDisplay(); return 1; } XGrabPointer(xdisplay, window, True, ButtonPressMask, GrabModeAsync, GrabModeAsync, window, None, CurrentTime); XFlush(xdisplay); // A little trick to make sure the entire window is on the screen XWarpPointer(xdisplay, None, window, 0, 0, 0, 0, width - 1, height - 1); XWarpPointer(xdisplay, None, window, 0, 0, 0, 0, 0, 0); XFlush(xdisplay); } return 0; }
ModeAction ModeParser::TryMode(User* user, User* targetuser, Channel* chan, bool adding, const unsigned char modechar, std::string ¶meter, bool SkipACL) { ModeType type = chan ? MODETYPE_CHANNEL : MODETYPE_USER; ModeHandler *mh = FindMode(modechar, type); int pcnt = mh->GetNumParams(adding); // crop mode parameter size to 250 characters if (parameter.length() > 250 && adding) parameter = parameter.substr(0, 250); ModResult MOD_RESULT; FIRST_MOD_RESULT(OnRawMode, MOD_RESULT, (user, chan, modechar, parameter, adding, pcnt)); if (IS_LOCAL(user) && (MOD_RESULT == MOD_RES_DENY)) return MODEACTION_DENY; if (chan && !SkipACL && (MOD_RESULT != MOD_RES_ALLOW)) { MOD_RESULT = mh->AccessCheck(user, chan, parameter, adding); if (MOD_RESULT == MOD_RES_DENY) return MODEACTION_DENY; if (MOD_RESULT == MOD_RES_PASSTHRU) { unsigned int neededrank = mh->GetLevelRequired(); /* Compare our rank on the channel against the rank of the required prefix, * allow if >= ours. Because mIRC and xchat throw a tizz if the modes shown * in NAMES(X) are not in rank order, we know the most powerful mode is listed * first, so we don't need to iterate, we just look up the first instead. */ unsigned int ourrank = chan->GetPrefixValue(user); if (ourrank < neededrank) { PrefixMode* neededmh = NULL; for(char c='A'; c <= 'z'; c++) { PrefixMode* privmh = FindPrefixMode(c); if (privmh && privmh->GetPrefixRank() >= neededrank) { // this mode is sufficient to allow this action if (!neededmh || privmh->GetPrefixRank() < neededmh->GetPrefixRank()) neededmh = privmh; } } if (neededmh) user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You must have channel %s access or above to %sset channel mode %c", user->nick.c_str(), chan->name.c_str(), neededmh->name.c_str(), adding ? "" : "un", modechar); else user->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :You cannot %sset channel mode %c", user->nick.c_str(), chan->name.c_str(), adding ? "" : "un", modechar); return MODEACTION_DENY; } } } // Ask mode watchers whether this mode change is OK std::pair<ModeWatchIter, ModeWatchIter> itpair = modewatchermap.equal_range(mh->name); for (ModeWatchIter i = itpair.first; i != itpair.second; ++i) { ModeWatcher* mw = i->second; if (mw->GetModeType() == type) { if (!mw->BeforeMode(user, targetuser, chan, parameter, adding)) return MODEACTION_DENY; // A module whacked the parameter completely, and there was one. Abort. if (pcnt && parameter.empty()) return MODEACTION_DENY; } } if (IS_LOCAL(user) && !user->IsOper()) { char* disabled = (type == MODETYPE_CHANNEL) ? ServerInstance->Config->DisabledCModes : ServerInstance->Config->DisabledUModes; if (disabled[modechar - 'A']) { user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - %s mode %c has been locked by the administrator", user->nick.c_str(), type == MODETYPE_CHANNEL ? "channel" : "user", modechar); return MODEACTION_DENY; } } if (adding && IS_LOCAL(user) && mh->NeedsOper() && !user->HasModePermission(modechar, type)) { /* It's an oper only mode, and they don't have access to it. */ if (user->IsOper()) { user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - Oper type %s does not have access to set %s mode %c", user->nick.c_str(), user->oper->name.c_str(), type == MODETYPE_CHANNEL ? "channel" : "user", modechar); } else { user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Permission Denied - Only operators may set %s mode %c", user->nick.c_str(), type == MODETYPE_CHANNEL ? "channel" : "user", modechar); } return MODEACTION_DENY; } /* Call the handler for the mode */ ModeAction ma = mh->OnModeChange(user, targetuser, chan, parameter, adding); if (pcnt && parameter.empty()) return MODEACTION_DENY; if (ma != MODEACTION_ALLOW) return ma; if ((!mh->IsListMode()) && (mh->GetNumParams(true)) && (chan)) chan->SetModeParam(mh, (adding ? parameter : "")); itpair = modewatchermap.equal_range(mh->name); for (ModeWatchIter i = itpair.first; i != itpair.second; ++i) { ModeWatcher* mw = i->second; if (mw->GetModeType() == type) mw->AfterMode(user, targetuser, chan, parameter, adding); } return MODEACTION_ALLOW; }
static int SwitchRes(char inout, int x, int y, int w, int h, int *dw, int *dh) { static int vp_x, vp_y; XF86VidModeModeInfo *mode; int scr; scr = Dpy.screen; if (inout) { XF86VidModeModeLine curmode; int dotclock; int rx, ry; if (!XF86VidModeGetModeLine(disp, scr, &dotclock, &curmode)) return 0; XF86VidModeGetViewPort(disp, scr, &vp_x, &vp_y); mode = FindMode(w, h); if (mode) { #if USE_XRANDR int vw, vh; vw = WinGetW(VROOT); vh = WinGetH(VROOT); /* x and y relative to unrotated display */ if (Mode.screen.rotation == RR_Rotate_90) { rx = y; ry = vw - mode->vdisplay - x; } else if (Mode.screen.rotation == RR_Rotate_270) { rx = vh - mode->hdisplay - y; ry = x; } else if (Mode.screen.rotation == RR_Rotate_180) { rx = vw - mode->hdisplay - x; ry = vh - mode->vdisplay - y; } else #endif { rx = x; ry = y; } #if USE_XRANDR if ((Mode.screen.rotation == RR_Rotate_90) || (Mode.screen.rotation == RR_Rotate_270)) { *dw = mode->vdisplay; *dh = mode->hdisplay; } else #endif { *dw = mode->hdisplay; *dh = mode->vdisplay; } XF86VidModeLockModeSwitch(disp, scr, 0); std_vid_mode_cur = GetModeIndex(dotclock, &curmode); XF86VidModeSwitchToMode(disp, scr, mode); XF86VidModeSetViewPort(disp, scr, rx, ry); XF86VidModeLockModeSwitch(disp, scr, 1); return 1; } } else { mode = std_vid_modes[std_vid_mode_cur]; XF86VidModeLockModeSwitch(disp, scr, 0); XF86VidModeSwitchToMode(disp, scr, mode); XF86VidModeSetViewPort(disp, scr, vp_x, vp_y); #if 0 /* No, don't lock or we can't switch resolution */ XF86VidModeLockModeSwitch(disp, scr, 1); #endif } return 0; }