Bool EWMH_BugOpts(char *opt, Bool toggle) { Bool save_isw = Scr.bo.do_enable_ewmh_iconic_state_workaround; if (StrEquals(opt,"EWMHIconicStateWorkaround")) { switch (toggle) { case -1: Scr.bo.do_enable_ewmh_iconic_state_workaround ^= 1; break; case 0: case 1: Scr.bo.do_enable_ewmh_iconic_state_workaround = toggle; break; default: Scr.bo.do_enable_ewmh_iconic_state_workaround = 0; break; } if (save_isw != Scr.bo.do_enable_ewmh_iconic_state_workaround) { set_state_workaround(); } return True; } return False; }
static char *get_simple_color( char *string, char **color, colorset_t *cs, int supplied_color, int special_flag, char *special_string) { char *rest; if (*color) { free(*color); *color = NULL; } rest = GetNextToken(string, color); if (*color) { if (special_string && StrEquals(*color, special_string)) { free(*color); *color = NULL; cs->color_flags |= special_flag; cs->color_flags &= ~supplied_color; } else { cs->color_flags |= supplied_color; cs->color_flags &= ~special_flag; } } else { cs->color_flags &= ~(supplied_color | special_flag); } return rest; }
bool StocksResyncEntry(StocksEntry& e, ulong_t skipPortfolio) { const StocksPrefs& prefs = GetPreferences()->stocksPrefs; ulong_t pc = prefs.portfolioCount(); for (ulong_t j = 0; j < pc; ++j) { if (j == skipPortfolio) continue; const StocksPortfolio& pp = prefs.portfolio(j); ulong_t ss = pp.size(); for (ulong_t k = 0; k < ss; ++k) { const StocksEntry& ee = pp.entry(k); if (StrEquals(e.symbol, ee.symbol)) { e.change = ee.change; e.percentChange = ee.percentChange; e.trade = ee.trade; return true; } } } return false; }
/************************************************************************** * * Moves focus to specified window * *************************************************************************/ void FocusOn(FvwmWindow *t, Bool FocusByMouse, char *action) { int dx,dy; int cx,cy; Bool do_not_warp; if (t == NULL || HAS_NEVER_FOCUS(t)) { UngrabEm(GRAB_NORMAL); if (t) { /* give the window a chance to take the focus itself */ MoveFocus(t->w, t, FocusByMouse, 1, 0); } return; } if (!(do_not_warp = StrEquals(PeekToken(action, NULL), "NoWarp"))) { if (t->Desk != Scr.CurrentDesk) { goto_desk(t->Desk); } if (IS_ICONIFIED(t)) { cx = t->icon_xl_loc + t->icon_g.width/2; cy = t->icon_g.y + t->icon_p_height + ICON_HEIGHT(t) / 2; } else { cx = t->frame_g.x + t->frame_g.width/2; cy = t->frame_g.y + t->frame_g.height/2; } dx = (cx + Scr.Vx)/Scr.MyDisplayWidth*Scr.MyDisplayWidth; dy = (cy +Scr.Vy)/Scr.MyDisplayHeight*Scr.MyDisplayHeight; MoveViewport(dx,dy,True); /* If the window is still not visible, make it visible! */ if (((t->frame_g.x + t->frame_g.height)< 0)|| (t->frame_g.y + t->frame_g.width < 0)|| (t->frame_g.x >Scr.MyDisplayWidth)||(t->frame_g.y>Scr.MyDisplayHeight)) { SetupFrame(t, 0, 0, t->frame_g.width, t->frame_g.height, False); if (HAS_MOUSE_FOCUS(t) || HAS_SLOPPY_FOCUS(t)) { XWarpPointer(dpy, None, Scr.Root, 0, 0, 0, 0, 2,2); } } } UngrabEm(GRAB_NORMAL); if (t->Desk == Scr.CurrentDesk) { MoveFocus(t->w, t, FocusByMouse, do_not_warp, 0); } return; }
void list_config_info(unsigned long *body) { char *tline, *token; int color; tline = (char*)&(body[3]); token = PeekToken(tline, &tline); if (StrEquals(token, "Colorset")) { color = LoadColorset(tline); change_colorset(color); } else if (StrEquals(token, XINERAMA_CONFIG_STRING)) { FScreenConfigureModule(tline); } }
void PrintListGeneric(VyParseTree* tree, char oDelim, char cDelim){ printf("%c", oDelim); /* Print each element recursively */ int i; for(i = 0; i < ListTreeSize(tree); i++){ VyParseTree* next = GetListData(tree,i); if(IsQuote(next)){ printf("'"); PrintParseTree(GetListData(next, 1)); } else if(IsSubstitution(next)){ if(IsSplicingSubstitution(next)){ printf("$@"); }else{ printf("$"); } PrintParseTree(GetListData(next, 1)); } else if(next->type == TREE_LIST){ VyParseTree* first = GetListData(next, 0); if(first->type == TREE_IDENT && StrEquals(GetStrData(first), "infix")){ PrintListGeneric(GetListData(next, 1), '{','}'); } else if(first->type == TREE_IDENT && StrEquals(GetStrData(first), "quote-substitutions")){ PrintListGeneric(GetListData(next, 1), '[',']'); }else{ PrintParseTree(next); } } else{ PrintParseTree(next); } } /* If it wasn't an empty list, remove the extra space generated by the item inside */ if(ListTreeSize(tree) > 0){ printf("\b"); } printf("%c ", cDelim); }
int main (){ xsmDetected = #ifdef XSM_BUGGY_DISCARD_COMMAND 1 #else StrEquals(getenv("SESSION_MANAGER_NAME"), "xsm") #endif ; }
DefinitionModel* HoroscopeExtractFromUDF(const UniversalDataFormat& udf, char_t*& date) { DefinitionModel* model = new_nt DefinitionModel(); if (NULL == model) return NULL; ulong_t size = udf.getItemsCount(); for (ulong_t i=0; i < size; i++) { const char* type = udf.getItemData(i, 0); if (StrEquals(horoscopeTitle, type)) { TXT(udf.getItemText(i, 1)); model->last()->setStyle(StyleGetStaticStyle(styleNameBold)); model->last()->setJustification(DefinitionElement::justifyCenter); } else if (StrEquals(horoscopeText, type)) { LBR(); TXT(udf.getItemText(i, 1)); } else if (StrEquals(horoscopeSection, type)) { LBR(); LBR(); TXT(udf.getItemText(i, 1)); model->last()->setStyle(StyleGetStaticStyle(styleNameBold)); } else if (StrEquals(horoscopeSmallSection, type)) { LBR(); TXT(udf.getItemText(i, 1)); model->last()->setStyle(StyleGetStaticStyle(styleNameBold)); } else if (StrEquals(horoscopeDate, type)) { char_t* d = StringCopy(udf.getItemText(i, 1)); free(date); date = d; if (NULL == date) goto Error; } else if (StrEquals(horoscopeUrlLink, type)) { LBR(); TXT(udf.getItemText(i, 1)); model->last()->setActionCallback(HoroscopesLinkCallback, (void*)udf.getItemData(i, 2)); model->last()->setHyperlink("", hyperlinkCallback); } else goto Error; } return model; Error: delete model; return NULL; }
static FlocaleCharset *FlocaleCharsetOfLocaleCharset(char *l) { int j = 0, i = 0; while(FlocaleCharsetTable[j].x != NULL) { if (StrEquals(l, FlocaleCharsetTable[j].x)) { return &FlocaleCharsetTable[j]; } i = 0; while(FlocaleCharsetTable[j].locale[i] != NULL) { if (StrEquals(l, FlocaleCharsetTable[j].locale[i])) { return &FlocaleCharsetTable[j]; } i++; } j++; } return NULL; }
static FlocaleCharset *FlocaleCharsetOfXCharset(char *x) { int j = 0; while(FlocaleCharsetTable[j].x != NULL) { if (StrEquals(x,FlocaleCharsetTable[j].x)) { return &FlocaleCharsetTable[j]; } j++; } return NULL; }
void CMD_DestroyMenu(F_CMD_ARGS) { MenuRoot *mr; MenuRoot *mrContinuation; Bool do_recreate = False; char *token; token = PeekToken(action, &action); if (!token) { return; } if (StrEquals(token, "recreate")) { do_recreate = True; token = PeekToken(action, NULL); } mr = menus_find_menu(token); if (Scr.last_added_item.type == ADDED_MENU) { set_last_added_item(ADDED_NONE, NULL); } while (mr) { /* save continuation before destroy */ mrContinuation = MR_CONTINUATION_MENU(mr); if (!DestroyMenu(mr, do_recreate, True)) { return; } /* Don't recreate the continuations */ do_recreate = False; mr = mrContinuation; } return; }
Bool FlocaleCharsetIsCharsetXLocale(Display *dpy, char *charset, char *module) { #ifdef HAVE_XOUTPUT_METHOD int i; FlocaleCharsetInit(dpy, module); if (FLCXOMCharsetList_num > 0) { for(i = 0; i < FLCXOMCharsetList_num; i++) { if (StrEquals( FLC_DEBUG_GET_X_CHARSET( FLCXOMCharsetList[i]), charset)) { return True; } } } return False; #else return True; /* Hum */ #endif }
static button_info *parse_button_id(char **line) { button_info *b = NULL, *ub = UberButton; int mask; int x, y; int count, i; char *rest; char *s; s = PeekToken(*line, &rest); *line = NULL; if (!s) { show_error("No button id specified\n"); return NULL; } if (*s == '+') { unsigned int JunkWidth; unsigned int JunkHeight; mask = XParseGeometry(s, &x, &y, &JunkWidth, &JunkHeight); if (!(mask & XValue) || (mask & XNegative) || !(mask & YValue) || (mask & YNegative)) { show_error("Illegal button position '%s'\n", s); return NULL; } if (x < 0 || y < 0) { show_error("Button column/row must not be negative\n"); return NULL; } b = get_xy_button(ub, y, x); if (b == NULL) { show_error( "Button at column %d row %d not found\n", x, y); return NULL; } } else if (isdigit(*s)) { x = atoi(s); i = count = -1; /* find the button */ while (NextButton(&ub, &b, &i, 0)) { if (++count == x) break; } if (count != x || b == NULL) { show_error("Button number %d not found\n", x); return NULL; } } else if (isalpha(*s)) { Bool found = False; i = -1; /* find the button */ while (NextButton(&ub, &b, &i, 0)) { if (b->flags.b_Id && StrEquals(b->id, s)) { found = True; break; } } if (found == False) { show_error("Button id '%s' does not exist\n", s); return NULL; } } else { show_error("Invalid button id '%s' specified\n", s); return NULL; } *line = rest; return b; }
/* * Change by PRB ([email protected]), 31/10/93. Prepend a hot key * specifier to each item in the list. This means allocating the * memory for each item (& freeing it) rather than just using the window * title directly. */ void CMD_WindowList(F_CMD_ARGS) { struct MenuRoot *mr; struct MenuParameters mp; char* ret_action = NULL; FvwmWindow *t; FvwmWindow **windowList; FvwmWindow **iconifiedList = NULL; int numWindows; int ii; char tname[128]; char loc[64]; char *name=NULL; Bool free_name = False; int dwidth; int dheight; char *tlabel; int last_desk_done = INT_MIN; int last_desk_displayed = INT_MIN; int next_desk = 0; char *t_hot=NULL; /* Menu label with hotkey added */ char scut = '0'; /* Current short cut key */ char *opts=NULL; char *tok=NULL; int desk = Scr.CurrentDesk; unsigned long flags = SHOW_DEFAULT; char *func = NULL; char *ffunc = NULL; char *tfunc = NULL; char *default_action = NULL; MenuReturn mret; MenuOptions mops; int low_layer = 0; /* show all layers by default */ int high_layer = INT_MAX; int max_label_width = 0; int skiplist_mode = 0; /* do not show skiplist by default */ Bool use_hotkey = True; KeyCode old_sor_keycode; char sor_default_keyname[8] = { 'M', 'e', 't', 'a', '_', 'L' }; char *sor_keyname = sor_default_keyname; /* Condition vars. */ Bool use_condition = False; Bool current_at_end = False; Bool iconified_at_end = False; int ic = 0; int ij; WindowConditionMask mask; char *cond_flags; Bool first_desk = True; Bool empty_menu = True; Bool was_get_menu_opts_called = False; FvwmWindow * const fw = exc->w.fw; const Window w = exc->w.w; const exec_context_t *exc2; memset(&mops, 0, sizeof(mops)); memset(&mret, 0, sizeof(MenuReturn)); /* parse postitioning args - must call this even if no action is given * because it sets the xinerama screen origin */ if (action && *action) { /* Look for condition - CreateFlagString returns NULL if no '(' * or '[' */ cond_flags = CreateFlagString(action, &action); if (cond_flags) { /* Create window mask */ use_condition = True; DefaultConditionMask(&mask); /* override for Current [] */ mask.my_flags.use_circulate_hit = 1; mask.my_flags.use_circulate_hit_icon = 1; CreateConditionMask(cond_flags, &mask); free(cond_flags); } opts = get_menu_options( action, w, fw, NULL, NULL, NULL, &mops); was_get_menu_opts_called = True; /* parse options */ while (opts && *opts) { opts = GetNextSimpleOption(opts, &tok); if (!tok) { break; } if (StrEquals(tok,"NoHotkeys")) { use_hotkey = False; } else if (StrEquals(tok,"Function")) { opts = GetNextSimpleOption(opts, &func); } else if (StrEquals(tok,"Desk")) { free(tok); opts = GetNextSimpleOption(opts, &tok); if (tok) { desk = atoi(tok); flags &= ~SHOW_ALLDESKS; } } else if (StrEquals(tok,"CurrentDesk")) { desk = Scr.CurrentDesk; flags &= ~SHOW_ALLDESKS; } else if (StrEquals(tok,"NotAlphabetic")) { flags &= ~SHOW_ALPHABETIC; } else if (StrEquals(tok,"Alphabetic")) { flags |= SHOW_ALPHABETIC; } else if (StrEquals(tok,"SortByClass")) { flags |= SORT_BYCLASS; } else if (StrEquals(tok,"SortByResource")) { flags |= SORT_BYRESOURCE; } else if (StrEquals(tok,"ReverseOrder")) { flags |= SORT_REVERSE; } else if (StrEquals(tok,"CurrentAtEnd")) { current_at_end = True; } else if (StrEquals(tok,"IconifiedAtEnd")) { iconified_at_end = True; } else if (StrEquals(tok,"NoDeskSort")) { flags |= NO_DESK_SORT; } else if (StrEquals(tok,"ShowPage")) { flags |= SHOW_PAGE_X | SHOW_PAGE_Y; } else if (StrEquals(tok,"ShowPageX")) { flags |= SHOW_PAGE_X; } else if (StrEquals(tok,"ShowPageY")) { flags |= SHOW_PAGE_Y; } else if (StrEquals(tok,"ShowScreen")) { flags |= SHOW_SCREEN; } else if (StrEquals(tok,"UseIconName")) { flags |= SHOW_ICONNAME; } else if (StrEquals(tok,"NoGeometry")) { flags &= ~SHOW_GEOMETRY; flags &= ~SHOW_INFONOTGEO; } else if (StrEquals(tok,"NoGeometryWithInfo")) { flags &= ~SHOW_GEOMETRY; flags |= SHOW_INFONOTGEO; } else if (StrEquals(tok,"Geometry")) { flags |= SHOW_GEOMETRY; flags &= ~SHOW_INFONOTGEO; } else if (StrEquals(tok,"NoIcons")) { flags &= ~SHOW_ICONIC; } else if (StrEquals(tok,"Icons")) { flags |= SHOW_ICONIC; } else if (StrEquals(tok,"OnlyIcons")) { flags = SHOW_ICONIC; } else if (StrEquals(tok,"NoNormal")) { flags &= ~SHOW_NORMAL; } else if (StrEquals(tok,"Normal")) { flags |= SHOW_NORMAL; } else if (StrEquals(tok,"OnlyNormal")) { flags = SHOW_NORMAL; } else if (StrEquals(tok,"NoSticky")) { flags &= ~(SHOW_STICKY_ACROSS_PAGES); flags &= ~(SHOW_STICKY_ACROSS_DESKS); } else if (StrEquals(tok,"NoStickyPage")) { flags &= ~(SHOW_STICKY_ACROSS_PAGES); } else if (StrEquals(tok,"NoStickyDesk")) { flags &= ~(SHOW_STICKY_ACROSS_DESKS); } else if (StrEquals(tok,"Sticky")) { flags |= SHOW_STICKY_ACROSS_PAGES; flags |= SHOW_STICKY_ACROSS_DESKS; } else if (StrEquals(tok,"StickyPage")) { flags |= SHOW_STICKY_ACROSS_PAGES; } else if (StrEquals(tok,"StickyDesk")) { flags |= SHOW_STICKY_ACROSS_DESKS; } else if (StrEquals(tok,"OnlySticky")) { flags = SHOW_STICKY_ACROSS_PAGES; flags = SHOW_STICKY_ACROSS_DESKS; } else if (StrEquals(tok,"OnlyStickyPage")) { flags = SHOW_STICKY_ACROSS_PAGES; } else if (StrEquals(tok,"OnlyStickyDesk")) { flags = SHOW_STICKY_ACROSS_DESKS; } else if (StrEquals(tok,"UseListSkip")) { /* deprecated as of 02-May-2007 (SS) */ fprintf(stderr, "UseListSkip is deprecated. Please use \"UseSkipList\".\n"); skiplist_mode = 1; } else if (StrEquals(tok,"UseSkipList")) { skiplist_mode = 1; } else if (StrEquals(tok,"OnlyListSkip")) { /* deprecated as of 02-May-2007 (SS) */ fprintf(stderr, "OnlyListSkip is deprecated. Please use \"OnlySkipList\".\n"); skiplist_mode = 2; } else if (StrEquals(tok,"OnlySkipList")) { skiplist_mode = 2; } else if (StrEquals(tok,"NoDeskNum")) { flags |= NO_DESK_NUM; } else if (StrEquals(tok,"NoLayer")) { flags |= NO_LAYER; } else if (StrEquals(tok,"NoCurrentDeskTitle")) { flags |= NO_CURRENT_DESK_TITLE; } else if (StrEquals(tok,"TitleForAllDesks")) { flags |= TITLE_FOR_ALL_DESKS; } else if (StrEquals(tok,"NoNumInDeskTitle")) { flags |= NO_NUM_IN_DESK_TITLE; } /* these are a bit dubious, but we should keep the * OnTop options for compatibility */ else if (StrEquals(tok, "NoOnTop")) { if (high_layer >= Scr.TopLayer) { high_layer = Scr.TopLayer - 1; } } else if (StrEquals(tok, "OnTop")) { if (high_layer < Scr.TopLayer) { high_layer = Scr.TopLayer; } } else if (StrEquals(tok, "OnlyOnTop")) { high_layer = low_layer = Scr.TopLayer; } else if (StrEquals(tok, "NoOnBottom")) { if (low_layer <= Scr.BottomLayer) { low_layer = Scr.BottomLayer - 1; } } else if (StrEquals(tok, "OnBottom")) { if (low_layer > Scr.BottomLayer) { low_layer = Scr.BottomLayer; } } else if (StrEquals(tok, "OnlyOnBottom")) { high_layer = low_layer = Scr.BottomLayer; } else if (StrEquals(tok, "Layer")) { free(tok); opts = GetNextSimpleOption(opts, &tok); if (tok) { low_layer = high_layer = atoi(tok); free(tok); opts = GetNextSimpleOption(opts, &tok); if (tok) { high_layer = atoi(tok); } } } else if (StrEquals(tok, "SelectOnRelease")) { if (sor_keyname != sor_default_keyname) { free(sor_keyname); } sor_keyname = NULL; opts = GetNextSimpleOption(opts, &sor_keyname); } else if (StrEquals(tok, "MaxLabelWidth")) { char *wid; opts = GetNextSimpleOption(opts, &wid); if (wid) { max_label_width = atoi(wid); if (max_label_width < 1) { max_label_width = 1; } free(wid); } } else if (!opts || !*opts) { default_action = safestrdup(tok); } else { fvwm_msg( ERR, "WindowList","Unknown option '%s'", tok); } if (tok) { free(tok); } } } if (was_get_menu_opts_called == False) { opts = get_menu_options( action, w, fw, NULL, NULL, NULL, &mops); } tlabel = get_desk_title(desk, flags, True); mr = NewMenuRoot(tlabel); if (!(flags & NO_CURRENT_DESK_TITLE)) { AddToMenu(mr, tlabel, "TITLE", False, False, False); empty_menu = False; } free(tlabel); numWindows = 0; for (t = Scr.FvwmRoot.next; t != NULL; t = t->next) { numWindows++; } windowList = malloc(numWindows*sizeof(t)); if (windowList == NULL) { return; } if (iconified_at_end) { iconifiedList = malloc(numWindows*sizeof(t)); if (iconifiedList == NULL) { free(windowList); return; } } /* get the windowlist starting from the current window (if any)*/ t = get_focus_window(); if (t == NULL) { t = Scr.FvwmRoot.next; } else if (current_at_end) { if (t->next) { t = t->next; } else { t = Scr.FvwmRoot.next; } } for (ii = 0; ii < numWindows; ii++) { if (flags & SORT_REVERSE) { windowList[numWindows - ii - 1] = t; } else if (iconified_at_end && IS_ICONIFIED(t)) { iconifiedList[ic++] = t; } else { windowList[ii - ic] = t; } if (t->next) { t = t->next; } else { t = Scr.FvwmRoot.next; } } if (iconified_at_end && ic > 0) { if (current_at_end && ii > ic) { windowList[numWindows - 1] = windowList[--ii - ic]; } for (ij = 0; ij < ic; ij++) { windowList[ij + (ii - ic)] = iconifiedList[ij]; } } /* Do alphabetic sort */ if (flags & (SHOW_ALPHABETIC | SORT_BYCLASS | SORT_BYRESOURCE)) { /* This will be compare or compareReverse if a reverse order * is selected. */ int (*sort)(const FvwmWindow **a, const FvwmWindow **b); switch (flags & (SHOW_ALPHABETIC | SHOW_ICONNAME | \ SORT_BYCLASS | SORT_BYRESOURCE)) { case SHOW_ALPHABETIC: compare = visibleCompare; break; case SHOW_ALPHABETIC | SHOW_ICONNAME: compare = iconCompare; break; /* Sorting based on class name produces an alphabetic * order so the keyword alphabetic is redundant. */ case SORT_BYCLASS: case SORT_BYCLASS | SHOW_ALPHABETIC: compare = classCompare; break; case SORT_BYCLASS | SHOW_ICONNAME: case SORT_BYCLASS | SHOW_ICONNAME | SHOW_ALPHABETIC: compare = classIconCompare; break; case SORT_BYRESOURCE: case SORT_BYRESOURCE | SORT_BYCLASS: case SORT_BYRESOURCE | SORT_BYCLASS | SHOW_ALPHABETIC: compare = resourceCompare; break; case SORT_BYRESOURCE | SHOW_ICONNAME: case SORT_BYRESOURCE | SHOW_ICONNAME | SORT_BYCLASS: case SORT_BYRESOURCE | SHOW_ICONNAME | SORT_BYCLASS | \ SHOW_ALPHABETIC: compare = resourceIconCompare; break; /* All current cases are covered, but if something * changes in the future we leave compare valid even if * it isn't what is expected. */ default: compare = visibleCompare; break; } if ( flags & SORT_REVERSE ) { sort = compareReverse; } else { sort = compare; } qsort(windowList, numWindows, sizeof(t), (int(*)(const void*, const void*))sort); } while(next_desk != INT_MAX) { /* Sort window list by desktop number */ if ((flags & SHOW_ALLDESKS) && !(flags & NO_DESK_SORT)) { /* run through the windowlist finding the first desk * not already processed */ next_desk = INT_MAX; for (ii = 0; ii < numWindows; ii++) { t = windowList[ii]; if (t->Desk >last_desk_done && t->Desk < next_desk) { next_desk = t->Desk; } } } if (!(flags & SHOW_ALLDESKS)) { /* if only doing one desk and it hasn't been done */ if (last_desk_done == INT_MIN) next_desk = desk; /* select the desk */ else next_desk = INT_MAX; /* flag completion */ } if (flags & NO_DESK_SORT) next_desk = INT_MAX; /* only go through loop once */ last_desk_done = next_desk; for (ii = 0; ii < numWindows; ii++) { t = windowList[ii]; if (t->Desk != next_desk && !(flags & NO_DESK_SORT)) { continue; } if (skiplist_mode == 0 && DO_SKIP_WINDOW_LIST(t)) { /* don't want skiplist windows - skip */ continue; } if (skiplist_mode == 2 && !DO_SKIP_WINDOW_LIST(t)) { /* don't want no skiplist one - skip */ continue; } if (use_condition && !MatchesConditionMask(t, &mask)) { /* doesn't match specified condition */ continue; } if (!(flags & SHOW_ICONIC) && (IS_ICONIFIED(t))) { /* don't want icons - skip */ continue; } if (!(flags & SHOW_STICKY_ACROSS_PAGES) && (IS_STICKY_ACROSS_PAGES(t))) { /* don't want sticky ones - skip */ continue; } if (!(flags & SHOW_STICKY_ACROSS_DESKS) && (IS_STICKY_ACROSS_DESKS(t))) { /* don't want sticky ones - skip */ continue; } if (!(flags & SHOW_NORMAL) && !(IS_ICONIFIED(t) || IS_STICKY_ACROSS_PAGES(t) || IS_STICKY_ACROSS_DESKS(t))) { /* don't want "normal" ones - skip */ continue; } if (get_layer(t) < low_layer || get_layer(t) > high_layer) { /* don't want this layer */ continue; } empty_menu = False; /* add separator between desks when geometry * shown but not at the top*/ if (t->Desk != last_desk_displayed) { if (last_desk_displayed != INT_MIN) { if (((flags & SHOW_GEOMETRY) || (flags & SHOW_INFONOTGEO)) && !(flags & TITLE_FOR_ALL_DESKS)) { AddToMenu( mr, NULL, NULL, False, False, False); } if (flags & TITLE_FOR_ALL_DESKS) { tlabel = get_desk_title( t->Desk, flags, False); AddToMenu( mr, tlabel, "TITLE", False, False, False); free(tlabel); } } last_desk_displayed = t->Desk; } if (first_desk && flags & TITLE_FOR_ALL_DESKS) { tlabel = get_desk_title(t->Desk, flags, False); AddToMenu( mr, tlabel, "TITLE", False, False, False); free(tlabel); } first_desk = False; if (flags & SHOW_ICONNAME) { name = t->visible_icon_name; } else { name = t->visible_name; } free_name = False; if (!name) { name = "NULL_NAME"; } else if (max_label_width > 0 && strlen(name) > max_label_width) { name = strdup(name); name[max_label_width] = '\0'; free_name = True; } t_hot = safemalloc(strlen(name) + 80); if (use_hotkey) { /* Generate label */ sprintf(t_hot, "&%c. ", scut); } else { *t_hot = 0; } if (!(flags & SHOW_INFONOTGEO)) { strcat(t_hot, name); } if (*t_hot == 0) { strcpy(t_hot, " "); } /* Next shortcut key */ if (scut == '9') { scut = 'A'; } else if (scut == 'Z') { scut = '0'; } else { scut++; } if (flags & SHOW_INFONOTGEO) { tname[0]=0; if (!IS_ICONIFIED(t) && !(flags & NO_DESK_NUM)) { sprintf(loc,"%d:", t->Desk); strcat(tname,loc); } if (IS_ICONIFIED(t)) { strcat(tname, "("); } strcat(t_hot,"\t"); strcat(t_hot,tname); strcat(t_hot, name); if (IS_ICONIFIED(t)) { strcat(t_hot, ")"); } } else if (flags & SHOW_GEOMETRY) { size_borders b; tname[0]=0; if (IS_ICONIFIED(t)) { strcpy(tname, "("); } if (!(flags & NO_DESK_NUM)) { sprintf(loc, "%d", t->Desk); strcat(tname, loc); } if (flags & SHOW_SCREEN) { fscreen_scr_arg fscr; int scr; fscr.xypos.x = Scr.Vx + t->g.frame.x + t->g.frame.width / 2; fscr.xypos.y = Scr.Vy + t->g.frame.y + t->g.frame.height / 2; scr = FScreenGetScrId( &fscr, FSCREEN_XYPOS); sprintf(loc, "@%d", scr); strcat(tname, loc); } if (flags & SHOW_PAGE_X) { sprintf(loc, "+%d", (Scr.Vx + t->g.frame.x + t->g.frame.width / 2) / Scr.MyDisplayWidth); strcat(tname, loc); } if (flags & SHOW_PAGE_Y) { sprintf(loc, "+%d", (Scr.Vy + t->g.frame.y + t->g.frame.height/2) / Scr.MyDisplayHeight); strcat(tname, loc); } if (!(flags & NO_LAYER)) { sprintf(loc, "(%d)", (get_layer(t))); strcat(tname, loc); } strcat(tname, ":"); get_window_borders(t, &b); dheight = t->g.frame.height - b.total_size.height; dwidth = t->g.frame.width - b.total_size.width; dwidth = (dwidth - t->hints.base_width) /t->orig_hints.width_inc; dheight = (dheight - t->hints.base_height) /t->orig_hints.height_inc; sprintf(loc,"%d",dwidth); strcat(tname, loc); sprintf(loc,"x%d",dheight); strcat(tname, loc); if (t->g.frame.x >=0) { sprintf(loc,"+%d",t->g.frame.x); } else { sprintf(loc,"%d",t->g.frame.x); } strcat(tname, loc); if (t->g.frame.y >=0) { sprintf(loc,"+%d",t->g.frame.y); } else { sprintf(loc,"%d",t->g.frame.y); } strcat(tname, loc); if (IS_STICKY_ACROSS_PAGES(t) || IS_STICKY_ACROSS_DESKS(t)) { strcat(tname, " S"); } if (IS_ICONIFIED(t)) { strcat(tname, ")"); } strcat(t_hot,"\t"); strcat(t_hot,tname); } ffunc = func ? func : "WindowListFunc"; tfunc = safemalloc(strlen(ffunc) + 36); /* support two ways for now: window context * (new) and window id param (old) */ sprintf(tfunc, "WindowId %lu %s %lu", FW_W(t), ffunc, FW_W(t)); AddToMenu( mr, t_hot, tfunc, False, False, False); free(tfunc); /* Add the title pixmap */ if (FMiniIconsSupported && t->mini_icon) { MI_MINI_ICON(MR_LAST_ITEM(mr))[0] = t->mini_icon; /* increase the cache count. Otherwise the * pixmap will be eventually removed from the * cache by DestroyMenu */ t->mini_icon->count++; } if (t_hot) { free(t_hot); } if (free_name) { free(name); } } } if (empty_menu) { /* force current desk title */ tlabel = get_desk_title(desk, flags, True); AddToMenu(mr, tlabel, "TITLE", False, False, False); free(tlabel); } if (func) { free(func); } free(windowList); if (iconified_at_end) { free(iconifiedList); } /* Use the WindowList menu style if there is one */ change_mr_menu_style(mr, "WindowList"); /* Activate select_on_release style */ old_sor_keycode = MST_SELECT_ON_RELEASE_KEY(mr); if (sor_keyname && (!MST_SELECT_ON_RELEASE_KEY(mr) || sor_keyname != sor_default_keyname)) { MST_SELECT_ON_RELEASE_KEY(mr) = XKeysymToKeycode( dpy, FvwmStringToKeysym(dpy, sor_keyname)); } memset(&mp, 0, sizeof(mp)); mp.menu = mr; exc2 = exc_clone_context(exc, NULL, 0); mp.pexc = &exc2; mp.flags.has_default_action = (default_action && *default_action != 0); mp.flags.is_sticky = 1; mp.flags.is_submenu = 0; mp.flags.is_already_mapped = 0; mp.flags.is_triggered_by_keypress = (!default_action && exc->x.etrigger->type == KeyPress); mp.pops = &mops; mp.ret_paction = &ret_action; do_menu(&mp, &mret); /* Restore old menu style */ MST_SELECT_ON_RELEASE_KEY(mr) = old_sor_keycode; if (ret_action) { free(ret_action); } DestroyMenu(mr, False, False); if (mret.rc == MENU_DOUBLE_CLICKED && default_action && *default_action) { execute_function(cond_rc, exc2, default_action, 0); } if (default_action != NULL) { free(default_action); } if (use_condition) { FreeConditionMask(&mask); } if (sor_keyname && sor_keyname != sor_default_keyname) { free(sor_keyname); } exc_destroy_context(exc2); return; }
void FGettextSetLocalePath(const char *path) { char *exp_path = NULL; char *before = NULL; char *after, *p, *str; int count; if (!HaveNLSSupport || !FGettextInitOk) { return; } FGLastPath = NULL; if (path == NULL || path[0] == '\0') { fgettext_free_fgpath_list(); FGLastPath = (FGettextPath *)safemalloc(sizeof(FGettextPath)); CopyString(&FGLastPath->domain, FGDefaultDomain); CopyString(&FGLastPath->dir, FGDefaultDir); FGPathList = flist_append_obj(FGPathList, FGLastPath); FGLastPath = NULL; return; } exp_path = envDupExpand(path, 0); if (StrEquals(exp_path,"None")) { fgettext_free_fgpath_list(); goto bail; } after = GetQuotedString(exp_path, &before, "+", NULL, NULL, NULL); if ((after && strchr(after, '+')) || (before && strchr(before, '+'))) { fprintf( stderr,"[%s][SetLocalePath]: " "To many '+' in locale path specification: %s\n", FGModuleName, path); goto bail; } if (!strchr(exp_path, '+')) { fgettext_free_fgpath_list(); } while(after && *after) { after = GetQuotedString(after, &p, ":", NULL, NULL, NULL); if (p && *p) { fgettext_add_one_path(p,-1); } if (p) { free(p); } } count = 0; str = before; while (str && *str) { str = GetQuotedString(str, &p, ":", NULL, NULL, NULL); if (p && *p) { fgettext_add_one_path(p,count); count++; } if (p) { free(p); } } bail: if (before) { free(before); } if (exp_path) { free(exp_path); } }
void CMD_WarpToWindow(F_CMD_ARGS) { int val1_unit, val2_unit, n; int val1, val2; struct monitor *m; int do_raise; char *next; char *token; next = GetNextToken(action, &token); if (StrEquals(token, "!raise")) { do_raise = 0; action = next; } else if (StrEquals(token, "raise")) { do_raise = 1; action = next; } else { do_raise = 1; } n = GetTwoArguments(action, &val1, &val2, &val1_unit, &val2_unit); if (exc->w.wcontext != C_UNMANAGED) { if (n == 2) { warp_to_mvwm_window( exc, val1, val1_unit, val2, val2_unit, do_raise); } else { warp_to_mvwm_window(exc, 0, 0, 0, 0, do_raise); } } else { int x = 0; int y = 0; if (n == 2) { int wx; int wy; int ww; int wh; if (exc->w.w == None || !XGetGeometry( dpy, exc->w.w, &JunkRoot, &wx, &wy, (unsigned int*)&ww, (unsigned int*)&wh, (unsigned int*)&JunkBW, (unsigned int*)&JunkDepth)) { return; } /* TA: 2014-09-11: This window is unmanaged. Since * mvwm won't have created a window for this, fw will be * NULL and hence no monitor information will be * present. Since we already know the coordinates of * the unmanaged window, use those in determining the * monitor to use. */ m = monitor_by_xy(wx, wy); if (val1_unit != m->coord.w) { x = val1; } else { x = (ww - 1) * val1 / 100; } if (val2_unit != m->coord.h) { y = val2; } else { y = (wh - 1) * val2 / 100; } if (x < 0) { x += ww; } if (y < 0) { y += wh; } } FWarpPointerUpdateEvpos( exc->x.elast, dpy, None, exc->w.w, 0, 0, 0, 0, x, y); } return; }
/*********************************************************************** * * Procedure: * main - start of module * ***********************************************************************/ int main(int argc, char **argv) { char *display_name = NULL; int itemp,i; char line[100]; short opt_num; Window JunkRoot, JunkChild; int JunkX, JunkY; unsigned JunkMask; #ifdef I18N_MB setlocale(LC_CTYPE, ""); #endif /* Save our program name - for error messages */ MyName = GetFileNameFromPath(argv[0]); if(argc < 6) { fprintf(stderr,"%s Version %s should only be executed by fvwm!\n",MyName, VERSION); exit(1); } #ifdef HAVE_SIGACTION { struct sigaction sigact; sigemptyset(&sigact.sa_mask); sigaddset(&sigact.sa_mask, SIGPIPE); sigaddset(&sigact.sa_mask, SIGTERM); sigaddset(&sigact.sa_mask, SIGQUIT); sigaddset(&sigact.sa_mask, SIGINT); sigaddset(&sigact.sa_mask, SIGHUP); # ifdef SA_INTERRUPT sigact.sa_flags = SA_INTERRUPT; # else sigact.sa_flags = 0; # endif sigact.sa_handler = TerminateHandler; sigaction(SIGPIPE, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); sigaction(SIGQUIT, &sigact, NULL); sigaction(SIGINT, &sigact, NULL); sigaction(SIGHUP, &sigact, NULL); } #else /* We don't have sigaction(), so fall back to less robust methods. */ #ifdef USE_BSD_SIGNALS fvwmSetSignalMask( sigmask(SIGPIPE) | sigmask(SIGTERM) | sigmask(SIGQUIT) | sigmask(SIGINT) | sigmask(SIGHUP) ); #endif signal(SIGPIPE, TerminateHandler); signal(SIGTERM, TerminateHandler); signal(SIGQUIT, TerminateHandler); signal(SIGINT, TerminateHandler); signal(SIGHUP, TerminateHandler); #ifdef HAVE_SIGINTERRUPT siginterrupt(SIGPIPE, 1); siginterrupt(SIGTERM, 1); siginterrupt(SIGQUIT, 1); siginterrupt(SIGINT, 1); siginterrupt(SIGHUP, 1); #endif #endif fd[0] = atoi(argv[1]); fd[1] = atoi(argv[2]); fd_width = GetFdWidth(); opt_num = 6; if (argc >= 7 && (StrEquals(argv[opt_num], "-transient") || StrEquals(argv[opt_num], "transient"))) { opt_num++; is_transient = True; do_ignore_next_button_release = True; } /* Check for an alias */ if (argc >= opt_num + 1) { char *s; if (!StrEquals(argv[opt_num], "*")) { for (s = argv[opt_num]; *s; s++) { if (!isdigit(*s) && (*s != '-' || s != argv[opt_num] || *(s+1) == 0)) { free(MyName); MyName=safestrdup(argv[opt_num]); opt_num++; break; } } } } if (argc < opt_num + 1) { desk1 = Scr.CurrentDesk; desk2 = Scr.CurrentDesk; } else if (StrEquals(argv[opt_num], "*")) { desk1 = Scr.CurrentDesk; desk2 = Scr.CurrentDesk; fAlwaysCurrentDesk = 1; } else { desk1 = atoi(argv[opt_num]); if (argc == opt_num+1) desk2 = desk1; else desk2 = atoi(argv[opt_num+1]); if(desk2 < desk1) { itemp = desk1; desk1 = desk2; desk2 = itemp; } } ndesks = desk2 - desk1 + 1; Desks = (DeskInfo *)safemalloc(ndesks*sizeof(DeskInfo)); memset(Desks, 0, ndesks * sizeof(DeskInfo)); for(i=0;i<ndesks;i++) { sprintf(line,"Desk %d",i+desk1); CopyString(&Desks[i].label,line); Desks[i].colorset = -1; Desks[i].highcolorset = -1; Desks[i].ballooncolorset = -1; } /* Initialize X connection */ if (!(dpy = XOpenDisplay(display_name))) { fprintf(stderr,"%s: can't open display %s", MyName, XDisplayName(display_name)); exit (1); } x_fd = XConnectionNumber(dpy); InitPictureCMap(dpy); FScreenInit(dpy); AllocColorset(0); FShapeInit(dpy); Scr.screen = DefaultScreen(dpy); Scr.Root = RootWindow(dpy, Scr.screen); /* make a temp window for any pixmaps, deleted later */ initialize_viz_pager(); #ifdef DEBUG fprintf(stderr,"[main]: Connection to X server established.\n"); #endif SetMessageMask(fd, M_ADD_WINDOW| M_CONFIGURE_WINDOW| M_DESTROY_WINDOW| M_FOCUS_CHANGE| M_NEW_PAGE| M_NEW_DESK| M_RAISE_WINDOW| M_LOWER_WINDOW| M_ICONIFY| M_ICON_LOCATION| M_DEICONIFY| M_RES_NAME| M_RES_CLASS| M_WINDOW_NAME| M_ICON_NAME| M_CONFIG_INFO| M_END_CONFIG_INFO| M_MINI_ICON| M_END_WINDOWLIST| M_RESTACK); #ifdef DEBUG fprintf(stderr,"[main]: calling ParseOptions\n"); #endif ParseOptions(); if (is_transient) { XQueryPointer(dpy, Scr.Root, &JunkRoot, &JunkChild, &window_x, &window_y, &JunkX, &JunkY, &JunkMask); usposition = 1; xneg = 0; yneg = 0; } #ifdef DEBUG fprintf(stderr, "[main]: back from calling ParseOptions, calling init pager\n"); #endif if (PagerFore == NULL) PagerFore = safestrdup("black"); if (PagerBack == NULL) PagerBack = safestrdup("white"); if (HilightC == NULL) HilightC = safestrdup(PagerFore); if (WindowLabelFormat == NULL) WindowLabelFormat = safestrdup("%i"); if (font_string == NULL) font_string = safestrdup("fixed"); if ((HilightC == NULL) && (HilightPixmap == NULL)) HilightDesks = 0; if (BalloonFont == NULL) BalloonFont = safestrdup("fixed"); if (BalloonBorderColor == NULL) BalloonBorderColor = safestrdup("black"); if (BalloonTypeString == NULL) BalloonTypeString = safestrdup("%i"); if (BalloonFormatString == NULL) BalloonFormatString = safestrdup("%i"); /* open a pager window */ initialize_pager(); #ifdef DEBUG fprintf(stderr,"[main]: back from init pager, getting window list\n"); #endif /* Create a list of all windows */ /* Request a list of all windows, * wait for ConfigureWindow packets */ SendInfo(fd,"Send_WindowList",0); #ifdef DEBUG fprintf(stderr,"[main]: back from getting window list, looping\n"); #endif if (is_transient) { Bool is_pointer_grabbed = False; Bool is_keyboard_grabbed = False; XSync(dpy,0); for (i = 0; i < 50 && !(is_pointer_grabbed && is_keyboard_grabbed); i++) { if (!is_pointer_grabbed && XGrabPointer( dpy, Scr.Root, True, ButtonPressMask|ButtonReleaseMask|ButtonMotionMask| PointerMotionMask|EnterWindowMask|LeaveWindowMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime) == GrabSuccess) { is_pointer_grabbed = True; } if (!is_keyboard_grabbed && XGrabKeyboard( dpy, Scr.Root, True, GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess) { is_keyboard_grabbed = True; } /* If you go too fast, other windows may not get a change to release * any grab that they have. */ usleep(20000); } if (!is_pointer_grabbed) { XBell(dpy, 0); fprintf(stderr, "%s: could not grab pointer in transient mode. exiting.\n", MyName); exit(1); } XSync(dpy,0); } /* tell fvwm we're running */ SendFinishedStartupNotification(fd); Loop(fd); #ifdef DEBUG if (debug_term_signal) { fprintf(stderr,"[main]: Terminated due to signal %d\n", debug_term_signal); } #endif return 0; }
/* translate a colorset spec into a colorset structure */ void parse_colorset(int n, char *line) { int i; int w; int h; int tmp; int percent; colorset_t *cs; char *optstring; char *args; char *option; char *tmp_str; char *fg = NULL; char *bg = NULL; char *hi = NULL; char *sh = NULL; char *fgsh = NULL; char *tint = NULL; char *fg_tint = NULL; char *bg_tint = NULL; char *icon_tint = NULL; Bool have_pixels_changed = False; Bool has_icon_pixels_changed = False; Bool has_fg_changed = False; Bool has_bg_changed = False; Bool has_sh_changed = False; Bool has_hi_changed = False; Bool has_fgsh_changed = False; Bool has_fg_alpha_changed = False; Bool has_tint_changed = False; Bool has_fg_tint_changed = False; Bool has_bg_tint_changed = False; Bool has_icon_tint_changed = False; Bool has_pixmap_changed = False; Bool has_shape_changed = False; Bool has_image_alpha_changed = False; Bool pixmap_is_a_bitmap = False; Bool do_reload_pixmap = False; Bool is_server_grabbed = False; XColor color; XGCValues xgcv; static char *name = "parse_colorset"; Window win = Scr.NoFocusWin; static GC gc = None; /* initialize statics */ if (gc == None) { gc = fvwmlib_XCreateGC(dpy, win, 0, &xgcv); } /* make sure it exists and has sensible contents */ alloc_colorset(n); cs = &Colorset[n]; /*** Parse the options ***/ while (line && *line) { /* Read next option specification delimited by a comma or \0. */ line = GetQuotedString( line, &optstring, ",", NULL, NULL, NULL); if (!optstring) break; args = GetNextToken(optstring, &option); if (!option) { free(optstring); break; } switch((i = GetTokenIndex(option, csetopts, 0, NULL))) { case 0: /* Foreground */ case 1: /* Fore */ case 2: /* fg */ get_simple_color( args, &fg, cs, FG_SUPPLIED, FG_CONTRAST, "contrast"); has_fg_changed = True; break; case 3: /* Background */ case 4: /* Back */ case 5: /* bg */ get_simple_color( args, &bg, cs, BG_SUPPLIED, BG_AVERAGE, "average"); has_bg_changed = True; break; case 6: /* Hilight */ case 7: /* Hilite */ case 8: /* hi */ get_simple_color(args, &hi, cs, HI_SUPPLIED, 0, NULL); has_hi_changed = True; break; case 9: /* Shadow */ case 10: /* Shade */ case 11: /* sh */ get_simple_color(args, &sh, cs, SH_SUPPLIED, 0, NULL); has_sh_changed = True; break; case 12: /* fgsh */ get_simple_color( args, &fgsh, cs, FGSH_SUPPLIED, 0,NULL); has_fgsh_changed = True; break; case 13: /* fg_alpha */ case 14: /* fgAlpha */ if (GetIntegerArguments(args, NULL, &tmp, 1)) { if (tmp > 100) tmp = 100; else if (tmp < 0) tmp = 0; } else { tmp = 100; } if (tmp != cs->fg_alpha_percent) { cs->fg_alpha_percent = tmp; has_fg_alpha_changed = True; } break; case 15: /* TiledPixmap */ case 16: /* Pixmap */ case 17: /* AspectPixmap */ has_pixmap_changed = True; free_colorset_background(cs, True); tmp_str = PeekToken(args, &args); if (tmp_str) { CopyString(&cs->pixmap_args, tmp_str); do_reload_pixmap = True; cs->gradient_type = 0; /* set the flags */ if (csetopts[i][0] == 'T') { cs->pixmap_type = PIXMAP_TILED; } else if (csetopts[i][0] == 'A') { cs->pixmap_type = PIXMAP_STRETCH_ASPECT; } else { cs->pixmap_type = PIXMAP_STRETCH; } } /* the pixmap is build later */ break; case 18: /* Shape */ case 19: /* TiledShape */ case 20: /* AspectShape */ parse_shape(win, cs, i, args, &has_shape_changed); break; case 21: /* Plain */ has_pixmap_changed = True; free_colorset_background(cs, True); break; case 22: /* NoShape */ has_shape_changed = True; if (cs->shape_mask) { add_to_junk(cs->shape_mask); cs->shape_mask = None; } break; case 23: /* Transparent */ /* This is only allowable when the root depth == fvwm * visual depth otherwise bad match errors happen, * it may be even more restrictive but my tests (on * exceed 6.2) show that only == depth is necessary */ if (Pdepth != DefaultDepth(dpy, (DefaultScreen(dpy)))) { fvwm_msg( ERR, name, "can't do Transparent " "when root_depth!=fvwm_depth"); break; } has_pixmap_changed = True; free_colorset_background(cs, True); cs->pixmap = ParentRelative; cs->pixmap_type = PIXMAP_STRETCH; break; case 24: /* RootTransparent */ if (Pdepth != DefaultDepth(dpy, (DefaultScreen(dpy)))) { fvwm_msg( ERR, name, "can't do RootTransparent " "when root_depth!=fvwm_depth"); break; } free_colorset_background(cs, True); has_pixmap_changed = True; cs->pixmap_type = PIXMAP_ROOT_PIXMAP_PURE; do_reload_pixmap = True; tmp_str = PeekToken(args, &args); if (StrEquals(tmp_str, "buffer")) { cs->allows_buffered_transparency = True; } else { cs->allows_buffered_transparency = False; } cs->is_maybe_root_transparent = True; break; case 25: /* Tint */ case 26: /* PixmapTint */ case 27: /* ImageTint */ case 28: /* TintMask */ parse_simple_tint( cs, args, &tint, TINT_SUPPLIED, &has_tint_changed, &percent, "tint"); if (has_tint_changed) { cs->tint_percent = percent; } break; case 29: /* NoTint */ has_tint_changed = True; cs->tint_percent = 0; cs->color_flags &= ~TINT_SUPPLIED; break; case 30: /* fgTint */ parse_simple_tint( cs, args, &fg_tint, FG_TINT_SUPPLIED, &has_fg_tint_changed, &percent, "fgTint"); if (has_fg_tint_changed) { cs->fg_tint_percent = percent; } break; case 31: /* bgTint */ parse_simple_tint( cs, args, &bg_tint, BG_TINT_SUPPLIED, &has_bg_tint_changed, &percent, "bgTint"); if (has_bg_tint_changed) { cs->bg_tint_percent = percent; } break; case 32: /* dither */ if (cs->pixmap_args || cs->gradient_args) { has_pixmap_changed = True; do_reload_pixmap = True; } cs->dither = True; break; case 33: /* nodither */ if (cs->pixmap_args || cs->gradient_args) { has_pixmap_changed = True; do_reload_pixmap = True; } cs->dither = False; break; case 34: /* Alpha */ case 35: /* PixmapAlpha */ case 36: /* ImageAlpha */ if (GetIntegerArguments(args, NULL, &tmp, 1)) { if (tmp > 100) tmp = 100; else if (tmp < 0) tmp = 0; } else { tmp = 100; } if (tmp != cs->image_alpha_percent) { has_image_alpha_changed = True; cs->image_alpha_percent = tmp; } break; /* dither icon is not dynamic (yet) maybe a bad opt: default * to False ? */ case 37: /* ditherIcon */ cs->do_dither_icon = True; break; case 38: /* DoNotDitherIcon */ cs->do_dither_icon = False; break; case 39: /* IconTint */ parse_simple_tint( cs, args, &icon_tint, ICON_TINT_SUPPLIED, &has_icon_tint_changed, &percent, "IconTint"); if (has_icon_tint_changed) { cs->icon_tint_percent = percent; has_icon_pixels_changed = True; } break; case 40: /* NoIconTint */ has_icon_tint_changed = True; if (cs->icon_tint_percent != 0) { has_icon_pixels_changed = True; } cs->icon_tint_percent = 0; break; case 41: /* IconAlpha */ if (GetIntegerArguments(args, NULL, &tmp, 1)) { if (tmp > 100) tmp = 100; else if (tmp < 0) tmp = 0; } else { tmp = 100; } if (tmp != cs->icon_alpha_percent) { has_icon_pixels_changed = True; cs->icon_alpha_percent = tmp; } break; default: /* test for ?Gradient */ if (option[0] && StrEquals(&option[1], "Gradient")) { cs->gradient_type = toupper(option[0]); if (!IsGradientTypeSupported(cs->gradient_type)) break; has_pixmap_changed = True; free_colorset_background(cs, True); CopyString(&cs->gradient_args, args); do_reload_pixmap = True; if (cs->gradient_type == V_GRADIENT) { cs->pixmap_type = PIXMAP_STRETCH_Y; } else if (cs->gradient_type == H_GRADIENT) cs->pixmap_type = PIXMAP_STRETCH_X; else cs->pixmap_type = PIXMAP_STRETCH; } else { fvwm_msg( WARN, name, "bad colorset pixmap " "specifier %s %s", option, line); } break; } /* switch */ if (option) { free(option); option = NULL; } free(optstring); optstring = NULL; } /* while (line && *line) */ /* * ---------- change the "pixmap" tint colour ---------- */ if (has_tint_changed) { /* user specified colour */ if (tint != NULL) { Pixel old_tint = cs->tint; PictureFreeColors(dpy, Pcmap, &cs->tint, 1, 0, True); cs->tint = GetColor(tint); if (old_tint != cs->tint) { have_pixels_changed = True; } } else if (tint == NULL) { /* default */ Pixel old_tint = cs->tint; PictureFreeColors(dpy, Pcmap, &cs->tint, 1, 0, True); cs->tint = GetColor(black); if (old_tint != cs->tint) { have_pixels_changed = True; } } } /* * reload the gradient if the tint or the alpha have changed. * Do this too if we need to recompute the bg average and the * gradient is tinted (perforemence issue). */ if ((has_tint_changed || has_image_alpha_changed || (has_bg_changed && (cs->color_flags & BG_AVERAGE) && cs->tint_percent > 0)) && cs->gradient_args) { do_reload_pixmap = True; } /* * reset the pixmap if the tint or the alpha has changed */ if (!do_reload_pixmap && (has_tint_changed || has_image_alpha_changed || (has_bg_changed && cs->alpha_pixmap != None))) { if (cs->pixmap_type == PIXMAP_ROOT_PIXMAP_PURE || cs->pixmap_type == PIXMAP_ROOT_PIXMAP_TRAN) { do_reload_pixmap = True; } else if (cs->picture != NULL && cs->pixmap) { XSetClipMask(dpy, gc, cs->picture->mask); reset_cs_pixmap(cs, gc); XSetClipMask(dpy, gc, None); has_pixmap_changed = True; } } /* * (re)build the pixmap or the gradient */ if (do_reload_pixmap) { free_colorset_background(cs, False); has_pixmap_changed = True; if (cs->pixmap_type == PIXMAP_ROOT_PIXMAP_PURE || cs->pixmap_type == PIXMAP_ROOT_PIXMAP_TRAN) { cs->pixmap_type = 0; if (root_pic.pixmap) { cs->pixmap = root_pic.pixmap; cs->width = root_pic.width; cs->height = root_pic.height; cs->pixmap_type = PIXMAP_ROOT_PIXMAP_PURE; #if 0 fprintf(stderr,"Cset %i LoadRoot 0x%lx\n", n, cs->pixmap); #endif } } else if (cs->pixmap_args) { parse_pixmap(win, gc, cs, &pixmap_is_a_bitmap); } else if (cs->gradient_args) { cs->pixmap = CreateGradientPixmapFromString( dpy, win, gc, cs->gradient_type, cs->gradient_args, &w, &h, &cs->pixels, &cs->nalloc_pixels, cs->dither); cs->width = w; cs->height = h; } has_pixmap_changed = True; } if (cs->picture != NULL && cs->picture->depth != Pdepth) { pixmap_is_a_bitmap = True; } /* * ---------- change the background colour ---------- */ if (has_bg_changed || (has_pixmap_changed && (cs->color_flags & BG_AVERAGE) && cs->pixmap != None && cs->pixmap != ParentRelative && !pixmap_is_a_bitmap)) { Bool do_set_default_background = False; Pixmap average_pix = None; if (cs->color_flags & BG_AVERAGE) { if (cs->picture != NULL && cs->picture->picture != None) { average_pix = cs->picture->picture; } else if (cs->pixmap != ParentRelative) { average_pix = cs->pixmap; } if (average_pix == root_pic.pixmap) { int w; int h; XID dummy; MyXGrabServer(dpy); is_server_grabbed = True; if (!XGetGeometry( dpy, average_pix, &dummy, (int *)&dummy, (int *)&dummy, (unsigned int *)&w, (unsigned int *)&h, (unsigned int *)&dummy, (unsigned int *)&dummy)) { average_pix = None; } else { if (w != cs->width || h != cs->height) { average_pix = None; } } if (average_pix == None) { MyXUngrabServer(dpy); is_server_grabbed = False; } } } /* note: no average for bitmap */ if ((cs->color_flags & BG_AVERAGE) && average_pix) { /* calculate average background color */ XColor *colors; XImage *image; XImage *mask_image = None; unsigned int i, j, k = 0; unsigned long red = 0, blue = 0, green = 0; unsigned long tred, tblue, tgreen; double dred = 0.0, dblue = 0.0, dgreen = 0.0; has_bg_changed = True; /* create an array to store all the pixmap colors in */ /* Note: this may allocate a lot of memory: * cs->width * cs->height * 12 and then the rest of the * procedure can take a lot of times */ colors = (XColor *)safemalloc( cs->width * cs->height * sizeof(XColor)); /* get the pixmap and mask into an image */ image = XGetImage( dpy, average_pix, 0, 0, cs->width, cs->height, AllPlanes, ZPixmap); if (cs->mask != None) { mask_image = XGetImage( dpy, cs->mask, 0, 0, cs->width, cs->height, AllPlanes, ZPixmap); } if (is_server_grabbed == True) { MyXUngrabServer(dpy); } if (image != None && mask_image != None) { /* only fetch the pixels that are not masked * out */ for (i = 0; i < cs->width; i++) { for (j = 0; j < cs->height; j++) { if ( cs->mask == None || XGetPixel( mask_image, i, j) == 0) { colors[k++].pixel = XGetPixel( image, i, j); } } } } if (image != None) { XDestroyImage(image); } if (mask_image != None) { XDestroyImage(mask_image); } if (k == 0) { do_set_default_background = True; } else { /* look them all up, XQueryColors() can't * handle more than 256 */ for (i = 0; i < k; i += 256) { XQueryColors( dpy, Pcmap, &colors[i], min(k - i, 256)); } /* calculate average, add overflows in a double * .red is short, red is long */ for (i = 0; i < k; i++) { tred = red; red += colors[i].red; if (red < tred) { dred += (double)tred; red = colors[i].red; } tgreen = green; green += colors[i].green; if (green < tgreen) { dgreen += (double)tgreen; green = colors[i].green; } tblue = blue; blue += colors[i].blue; if (blue < tblue) { dblue += (double)tblue; blue = colors[i].blue; } } dred += red; dgreen += green; dblue += blue; /* get it */ color.red = dred / k; color.green = dgreen / k; color.blue = dblue / k; { Pixel old_bg = cs->bg; PictureFreeColors( dpy, Pcmap, &cs->bg, 1, 0, True); PictureAllocColor( dpy, Pcmap, &color, True); cs->bg = color.pixel; if (old_bg != cs->bg) { have_pixels_changed = True; } } } free(colors); } /* average */ else if ((cs->color_flags & BG_SUPPLIED) && bg != NULL) { /* user specified colour */ Pixel old_bg = cs->bg; PictureFreeColors(dpy, Pcmap, &cs->bg, 1, 0, True); cs->bg = GetColor(bg); if (old_bg != cs->bg) { have_pixels_changed = True; } } /* user specified */ else if (bg == NULL && has_bg_changed) { /* default */ do_set_default_background = True; } /* default */ if (do_set_default_background) { Pixel old_bg = cs->bg; PictureFreeColors(dpy, Pcmap, &cs->bg, 1, 0, True); cs->bg = GetColor(white); if (old_bg != cs->bg) { have_pixels_changed = True; } has_bg_changed = True; } if (has_bg_changed) { /* save the bg color for tinting */ cs->bg_saved = cs->bg; } } /* has_bg_changed */ /* * ---------- setup the bg tint colour ---------- */ if (has_bg_tint_changed && cs->bg_tint_percent > 0 && bg_tint != NULL) { PictureFreeColors(dpy, Pcmap, &cs->bg_tint, 1, 0, True); cs->bg_tint = GetColor(bg_tint); } /* * ---------- tint the bg colour ---------- */ if (has_bg_tint_changed || (has_bg_changed && cs->bg_tint_percent > 0)) { if (cs->bg_tint_percent == 0) { Pixel old_bg = cs->bg; PictureFreeColors(dpy, Pcmap, &cs->bg, 1, 0, True); cs->bg = cs->bg_saved; if (old_bg != cs->bg) { have_pixels_changed = True; has_bg_changed = True; } } else { Pixel old_bg = cs->bg; PictureFreeColors(dpy, Pcmap, &cs->bg, 1, 0, True); cs->bg = GetTintedPixel( cs->bg_saved, cs->bg_tint, cs->bg_tint_percent); if (old_bg != cs->bg) { have_pixels_changed = True; has_bg_changed = True; } } } /* * ---------- setup the fg tint colour ---------- */ if (has_fg_tint_changed && cs->fg_tint_percent > 0 && fg_tint != NULL) { PictureFreeColors(dpy, Pcmap, &cs->fg_tint, 1, 0, True); cs->fg_tint = GetColor(fg_tint); } /* * ---------- change the foreground colour ---------- */ if (has_fg_changed || (has_bg_changed && (cs->color_flags & FG_CONTRAST))) { if (cs->color_flags & FG_CONTRAST) { Pixel old_fg = cs->fg; /* calculate contrasting foreground color */ color.pixel = cs->bg; XQueryColor(dpy, Pcmap, &color); color.red = (color.red > 32767) ? 0 : 65535; color.green = (color.green > 32767) ? 0 : 65535; color.blue = (color.blue > 32767) ? 0 : 65535; PictureFreeColors(dpy, Pcmap, &cs->fg, 1, 0, True); PictureAllocColor(dpy, Pcmap, &color, True); cs->fg = color.pixel; if (old_fg != cs->fg) { have_pixels_changed = True; has_fg_changed = 1; } } /* contrast */ else if ((cs->color_flags & FG_SUPPLIED) && fg != NULL) { /* user specified colour */ Pixel old_fg = cs->fg; PictureFreeColors(dpy, Pcmap, &cs->fg, 1, 0, True); cs->fg = GetColor(fg); if (old_fg != cs->fg) { have_pixels_changed = True; has_fg_changed = 1; } } /* user specified */ else if (fg == NULL) { /* default */ Pixel old_fg = cs->fg; PictureFreeColors(dpy, Pcmap, &cs->fg, 1, 0, True); cs->fg = GetColor(black); if (old_fg != cs->fg) { have_pixels_changed = True; has_fg_changed = 1; } } /* save the fg color for tinting */ cs->fg_saved = cs->fg; } /* has_fg_changed */ /* * ---------- tint the foreground colour ---------- */ if (has_fg_tint_changed || (has_fg_changed && cs->fg_tint_percent > 0)) { if (cs->fg_tint_percent == 0) { Pixel old_fg = cs->fg; PictureFreeColors(dpy, Pcmap, &cs->fg, 1, 0, True); cs->fg = cs->fg_saved; if (old_fg != cs->fg) { have_pixels_changed = True; has_fg_changed = 1; } } else { Pixel old_fg = cs->fg; PictureFreeColors(dpy, Pcmap, &cs->fg, 1, 0, True); cs->fg = GetTintedPixel( cs->fg_saved, cs->fg_tint, cs->fg_tint_percent); if (old_fg != cs->fg) { have_pixels_changed = True; has_fg_changed = 1; } } } /* * ---------- change the hilight colour ---------- */ if (has_hi_changed || (has_bg_changed && !(cs->color_flags & HI_SUPPLIED))) { has_hi_changed = 1; if ((cs->color_flags & HI_SUPPLIED) && hi != NULL) { /* user specified colour */ Pixel old_hilite = cs->hilite; PictureFreeColors(dpy, Pcmap, &cs->hilite, 1, 0, True); cs->hilite = GetColor(hi); if (old_hilite != cs->hilite) { have_pixels_changed = True; } } /* user specified */ else if (hi == NULL) { Pixel old_hilite = cs->hilite; PictureFreeColors(dpy, Pcmap, &cs->hilite, 1, 0, True); cs->hilite = GetHilite(cs->bg); if (old_hilite != cs->hilite) { have_pixels_changed = True; } } } /* has_hi_changed */ /* * ---------- change the shadow colour ---------- */ if (has_sh_changed || (has_bg_changed && !(cs->color_flags & SH_SUPPLIED))) { has_sh_changed = 1; if ((cs->color_flags & SH_SUPPLIED) && sh != NULL) { /* user specified colour */ Pixel old_shadow = cs->shadow; PictureFreeColors(dpy, Pcmap, &cs->shadow, 1, 0, True); cs->shadow = GetColor(sh); if (old_shadow != cs->shadow) { have_pixels_changed = True; } } /* user specified */ else if (sh == NULL) { Pixel old_shadow = cs->shadow; PictureFreeColors(dpy, Pcmap, &cs->shadow, 1, 0, True); cs->shadow = GetShadow(cs->bg); if (old_shadow != cs->shadow) { have_pixels_changed = True; } } } /* has_sh_changed */ /* * ---------- change the shadow foreground colour ---------- */ if (has_fgsh_changed || ((has_fg_changed || has_bg_changed) && !(cs->color_flags & FGSH_SUPPLIED))) { has_fgsh_changed = 1; if ((cs->color_flags & FGSH_SUPPLIED) && fgsh != NULL) { /* user specified colour */ Pixel old_fgsh = cs->fgsh; PictureFreeColors(dpy, Pcmap, &cs->fgsh, 1, 0, True); cs->fgsh = GetColor(fgsh); if (old_fgsh != cs->fgsh) { have_pixels_changed = True; } } /* user specified */ else if (fgsh == NULL) { Pixel old_fgsh = cs->fgsh; PictureFreeColors(dpy, Pcmap, &cs->fgsh, 1, 0, True); cs->fgsh = GetForeShadow(cs->fg, cs->bg); if (old_fgsh != cs->fgsh) { have_pixels_changed = True; } } } /* has_fgsh_changed */ /* * ------- the pixmap is a bitmap: create here cs->pixmap ------- */ if (cs->picture != None && pixmap_is_a_bitmap && (has_pixmap_changed || has_bg_changed)) { cs->pixmap = XCreatePixmap( dpy, win, cs->width, cs->height, Pdepth); XSetBackground(dpy, gc, cs->bg); XSetForeground(dpy, gc, cs->fg); reset_cs_pixmap(cs, gc); } /* * ------- change the masked out parts of the background pixmap ------- */ if (cs->pixmap != None && cs->pixmap != ParentRelative && (!CSETS_IS_TRANSPARENT_ROOT(cs)|| cs->allows_buffered_transparency) && (cs->mask != None || cs->alpha_pixmap != None || cs->image_alpha_percent < 100 || cs->tint_percent > 0) && (has_pixmap_changed || has_bg_changed || has_image_alpha_changed || has_tint_changed)) { /* Now that we know the background colour we can update the * pixmap background. */ FvwmRenderAttributes fra; Pixmap temp, mask, alpha; memset(&fra, 0, sizeof(fra)); temp = XCreatePixmap(dpy, win, cs->width, cs->height, Pdepth); if (cs->picture != NULL) { mask = cs->picture->mask; alpha = cs->picture->alpha; } else { mask = None; alpha = None; } XSetForeground(dpy, gc, cs->bg); XFillRectangle( dpy, temp, gc, 0, 0, cs->width, cs->height); fra.mask = FRAM_HAVE_ADDED_ALPHA | FRAM_HAVE_TINT; fra.added_alpha_percent = cs->image_alpha_percent; fra.tint = cs->tint; fra.tint_percent = cs->tint_percent; PGraphicsRenderPixmaps( dpy, win, cs->pixmap, mask, alpha, Pdepth, &fra, temp, gc, Scr.MonoGC, Scr.AlphaGC, 0, 0, cs->width, cs->height, 0, 0, cs->width, cs->height, False); if (cs->pixmap != root_pic.pixmap) { add_to_junk(cs->pixmap); } cs->pixmap = temp; has_pixmap_changed = True; if (CSETS_IS_TRANSPARENT_ROOT(cs)) { cs->pixmap_type = PIXMAP_ROOT_PIXMAP_TRAN; } } /* has_pixmap_changed */ /* * ---------- change the icon tint colour ---------- */ if (has_icon_tint_changed) { /* user specified colour */ if (icon_tint != NULL) { Pixel old_tint = cs->icon_tint; PictureFreeColors( dpy, Pcmap, &cs->icon_tint, 1, 0, True); cs->icon_tint = GetColor(icon_tint); if (old_tint != cs->icon_tint) { has_icon_pixels_changed = True; } } else { /* default */ Pixel old_tint = cs->icon_tint; PictureFreeColors( dpy, Pcmap, &cs->icon_tint, 1, 0, True); cs->icon_tint = GetColor(black); if (old_tint != cs->icon_tint) { has_icon_pixels_changed = True; } } } /* * ---------- send new colorset to fvwm and clean up ---------- */ /* make sure the server has this to avoid races */ XSync(dpy, False); /* inform modules of the change */ if (have_pixels_changed || has_pixmap_changed || has_shape_changed || has_fg_alpha_changed || has_icon_pixels_changed) { BroadcastColorset(n); } if (fg) { free(fg); } if (bg) { free(bg); } if (hi) { free(hi); } if (sh) { free(sh); } if (fgsh) { free(fgsh); } if (tint) { free(tint); } if (fg_tint) { free(fg_tint); } if (bg_tint) { free(bg_tint); } if (icon_tint) { free(icon_tint); } return; }
/* * Change by PRB ([email protected]), 31/10/93. Prepend a hot key * specifier to each item in the list. This means allocating the * memory for each item (& freeing it) rather than just using the window * title directly. */ void do_windowList(XEvent *eventp,Window w,FvwmWindow *tmp_win, unsigned long context, char *action,int *Module) { MenuRoot *mr; MenuItem *miExecuteAction; FvwmWindow *t; FvwmWindow **windowList; int numWindows; int ii; char tname[80] = ""; char loc[40],*name=NULL; int dwidth,dheight; char tlabel[50]=""; int last_desk_done = INT_MIN; int last_desk_displayed = INT_MIN; int next_desk = 0; char *t_hot=NULL; /* Menu label with hotkey added */ char scut = '0'; /* Current short cut key */ char *line=NULL,*tok=NULL; int desk = Scr.CurrentDesk; int flags = SHOW_EVERYTHING; char *func=NULL; char *tfunc=NULL; char *default_action = NULL; MenuStatus menu_retval; XEvent *teventp; MenuOptions mops; size_t hotlen; mops.flags.allflags = 0; if (action && *action) { /* parse postitioning args */ action = GetMenuOptions(action,w,tmp_win,NULL,&mops); line = action; /* parse options */ while (line && *line) { line = GetNextOption(line, &tok); if (!tok) break; if (StrEquals(tok,"Function")) { line = GetNextOption(line, &func); } else if (StrEquals(tok,"Desk")) { free(tok); line = GetNextOption(line, &tok); if (tok) { desk = atoi(tok); flags &= ~SHOW_ALLDESKS; } } else if (StrEquals(tok,"CurrentDesk")) { desk = Scr.CurrentDesk; flags &= ~SHOW_ALLDESKS; } else if (StrEquals(tok,"NotAlphabetic")) flags &= ~SHOW_ALPHABETIC; else if (StrEquals(tok,"Alphabetic")) flags |= SHOW_ALPHABETIC; else if (StrEquals(tok,"NoDeskSort")) flags |= NO_DESK_SORT; else if (StrEquals(tok,"UseIconName")) flags |= SHOW_ICONNAME; else if (StrEquals(tok,"NoGeometry")) flags &= ~SHOW_GEOMETRY; else if (StrEquals(tok,"Geometry")) flags |= SHOW_GEOMETRY; else if (StrEquals(tok,"NoIcons")) flags &= ~SHOW_ICONIC; else if (StrEquals(tok,"Icons")) flags |= SHOW_ICONIC; else if (StrEquals(tok,"OnlyIcons")) flags = SHOW_ICONIC; else if (StrEquals(tok,"NoNormal")) flags &= ~SHOW_NORMAL; else if (StrEquals(tok,"Normal")) flags |= SHOW_NORMAL; else if (StrEquals(tok,"OnlyNormal")) flags = SHOW_NORMAL; else if (StrEquals(tok,"NoSticky")) flags &= ~SHOW_STICKY; else if (StrEquals(tok,"Sticky")) flags |= SHOW_STICKY; else if (StrEquals(tok,"OnlySticky")) flags = SHOW_STICKY; else if (StrEquals(tok,"NoOnTop")) flags &= ~SHOW_ONTOP; else if (StrEquals(tok,"OnTop")) flags |= SHOW_ONTOP; else if (StrEquals(tok,"OnlyOnTop")) flags = SHOW_ONTOP; else if (!line || !*line) default_action = strdup(tok); else { fvwm_msg(ERR,"WindowList","Unknown option '%s'",tok); } if (tok) free(tok); } } globalFlags = flags; if (flags & SHOW_GEOMETRY) { snprintf(tlabel,sizeof(tlabel),"Desk: %d\tGeometry",desk); } else { snprintf(tlabel,sizeof(tlabel),"Desk: %d",desk); } mr=NewMenuRoot(tlabel, False); AddToMenu(mr, tlabel, "TITLE", FALSE, FALSE); numWindows = 0; for (t = Scr.FvwmRoot.next; t != NULL; t = t->next) { numWindows++; } windowList = malloc(numWindows*sizeof(t)); if (windowList == NULL) { return; } /* get the windowlist starting from the current window (if any)*/ if ((t = Scr.Focus) == NULL) t = Scr.FvwmRoot.next; for (ii = 0; ii < numWindows; ii++) { windowList[ii] = t; if (t->next) t = t->next; else t = Scr.FvwmRoot.next; } /* Do alphabetic sort */ if (flags & SHOW_ALPHABETIC) qsort(windowList,numWindows,sizeof(t), (int(*)(const void*,const void*))winCompare); while(next_desk != INT_MAX) { /* Sort window list by desktop number */ if((flags & SHOW_ALLDESKS) && !(flags & NO_DESK_SORT)) { /* run through the windowlist finding the first desk not already processed */ next_desk = INT_MAX; for (ii = 0; ii < numWindows; ii++) { t = windowList[ii]; if((t->Desk >last_desk_done)&&(t->Desk < next_desk)) next_desk = t->Desk; } } if(!(flags & SHOW_ALLDESKS)) { /* if only doing one desk and it hasn't been done */ if(last_desk_done == INT_MIN) next_desk = desk; /* select the desk */ else next_desk = INT_MAX; /* flag completion */ } if(flags & NO_DESK_SORT) next_desk = INT_MAX; /* only go through loop once */ last_desk_done = next_desk; for (ii = 0; ii < numWindows; ii++) { t = windowList[ii]; if(((t->Desk == next_desk) || (flags & NO_DESK_SORT)) && (!(t->flags & WINDOWLISTSKIP))) { if (!(flags & SHOW_ICONIC) && (t->flags & ICONIFIED)) continue; /* don't want icons - skip */ if (!(flags & SHOW_STICKY) && (t->flags & STICKY)) continue; /* don't want sticky ones - skip */ if (!(flags & SHOW_ONTOP) && (t->flags & ONTOP)) continue; /* don't want ontop ones - skip */ if (!(flags & SHOW_NORMAL) && !((t->flags & ICONIFIED) || (t->flags & STICKY) || (t->flags & ONTOP))) continue; /* don't want "normal" ones - skip */ /* put a seperator between desks, but not at the top */ if (t->Desk != last_desk_displayed) { if (last_desk_displayed != INT_MIN) AddToMenu(mr, NULL, NULL, FALSE, FALSE); last_desk_displayed = t->Desk; } if(flags & SHOW_ICONNAME) name = t->icon_name; else name = t->name; hotlen = strlen(name) + strlen(tname) + 48; t_hot = safemalloc(hotlen); snprintf(t_hot, hotlen, "&%c. %s", scut, name); /* Generate label */ if (scut++ == '9') scut = 'A'; /* Next shortcut key */ if (flags & SHOW_GEOMETRY) { tname[0]=0; if(t->flags & ICONIFIED) strlcpy(tname, "(", sizeof(tname)); snprintf(loc, sizeof(loc), "%d:",t->Desk); strlcat(tname, loc, sizeof(tname)); dheight = t->frame_height - t->title_height - 2*t->boundary_width; dwidth = t->frame_width - 2*t->boundary_width; dwidth -= t->hints.base_width; dheight -= t->hints.base_height; dwidth /= t->hints.width_inc; dheight /= t->hints.height_inc; snprintf(loc, sizeof(loc), "%d", dwidth); strlcat(tname, loc,sizeof(tname)); snprintf(loc, sizeof(loc), "x%d", dheight); strlcat(tname, loc,sizeof(tname)); if(t->frame_x >=0) snprintf(loc, sizeof(loc), "+%d", t->frame_x); else snprintf(loc, sizeof(loc), "%d", t->frame_x); strlcat(tname, loc, sizeof(tname)); if(t->frame_y >=0) snprintf(loc, sizeof(loc), "+%d", t->frame_y); else snprintf(loc, sizeof(loc), "%d", t->frame_y); strlcat(tname, loc, sizeof(tname)); if (t->flags & STICKY) strlcat(tname, " S", sizeof(tname)); if (t->flags & ONTOP) strlcat(tname, " T", sizeof(tname)); if (t->flags & ICONIFIED) strlcat(tname, ")", sizeof(tname)); strlcat(t_hot,"\t",hotlen); strlcat(t_hot,tname,hotlen); } if (!func) { tfunc = safemalloc(40); snprintf(tfunc,40,"WindowListFunc %ld",t->w); } else { size_t funclen = strlen(func) + 32; tfunc = safemalloc(funclen); snprintf(tfunc,funclen,"%s %ld",func,t->w); free(func); func = NULL; } AddToMenu(mr, t_hot, tfunc, FALSE, FALSE); free(tfunc); #ifdef MINI_ICONS /* Add the title pixmap */ if (t->mini_icon) { mr->last->lpicture = t->mini_icon; t->mini_icon->count++; /* increase the cache count!! otherwise the pixmap will be eventually removed from the cache by DestroyMenu */ } #endif if (t_hot) free(t_hot); } } } if (func) free(func); free(windowList); MakeMenu(mr); if (!default_action && eventp && eventp->type == KeyPress) teventp = (XEvent *)1; else teventp = eventp; menu_retval = do_menu(mr, NULL, &miExecuteAction, 0, TRUE, teventp, &mops); DestroyMenu(mr); if (menu_retval == MENU_DOUBLE_CLICKED && default_action && *default_action) ExecuteFunction(default_action,tmp_win,eventp,context,*Module); if (default_action != NULL) free(default_action); }
void InitSwallow(struct XObj *xobj) { unsigned long mask; XSetWindowAttributes Attr; static char *my_sm_env = NULL; static char *orig_sm_env = NULL; static int len = 0; static Bool sm_initialized = False; static Bool session_manager = False; char *cmd; /* Enregistrement des couleurs et de la police */ if (xobj->colorset >= 0) { xobj->TabColor[fore] = Colorset[xobj->colorset].fg; xobj->TabColor[back] = Colorset[xobj->colorset].bg; xobj->TabColor[hili] = Colorset[xobj->colorset].hilite; xobj->TabColor[shad] = Colorset[xobj->colorset].shadow; } else { xobj->TabColor[fore] = GetColor(xobj->forecolor); xobj->TabColor[back] = GetColor(xobj->backcolor); xobj->TabColor[hili] = GetColor(xobj->hilicolor); xobj->TabColor[shad] = GetColor(xobj->shadcolor); } mask=0; xobj->win=XCreateWindow(dpy,*xobj->ParentWin, -1000,-1000,xobj->width,xobj->height,0, CopyFromParent,InputOutput,CopyFromParent, mask,&Attr); /* Redimensionnement du widget */ if (xobj->height<30) xobj->height=30; if (xobj->width<30) xobj->width=30; if (xobj->swallow == NULL) { fprintf(stderr,"Error\n"); return; } if (!sm_initialized) { /* use sm only when needed */ sm_initialized = True; orig_sm_env = getenv("SESSION_MANAGER"); if (orig_sm_env && !StrEquals("", orig_sm_env)) { /* this set the new SESSION_MANAGER env */ session_manager = fsm_init(x11base->TabArg[0]); } } if (!session_manager) { SendText(fd, xobj->swallow, 0); return; } if (my_sm_env == NULL) { my_sm_env = getenv("SESSION_MANAGER"); len = 45 + strlen(my_sm_env) + strlen(orig_sm_env); } cmd = safemalloc(len + strlen(xobj->swallow)); sprintf( cmd, "FSMExecFuncWithSessionManagment \"%s\" \"%s\" \"%s\"", my_sm_env, xobj->swallow, orig_sm_env); SendText(fd, cmd, 0); free (cmd); }
/* * * Procedure: * main - start of module * */ int main(int argc, char **argv) { /* The struct holding the module info */ static ModuleArgs* module; char *enter_fn="Silent Raise"; /* default */ char *leave_fn=NULL; char *buf; int len; unsigned long m_mask; unsigned long mx_mask; unsigned long last_win = 0; /* last window handled */ unsigned long focus_win = 0; /* current focus */ unsigned long raised_win = 0; fd_set_size_t fd_width; int fd[2]; int timeout; int sec = 0; int usec = 0; int n; struct timeval value; struct timeval *delay; fd_set in_fdset; Bool do_pass_id = False; Bool use_enter_mode = False; Bool use_leave_mode = False; #ifdef DEBUG int count = 0; #endif #ifdef DEBUGTOFILE freopen(".FvwmAutoDebug","w",stderr); #endif module = ParseModuleArgs(argc,argv,0); /* no alias in this module */ if (module==NULL) { fprintf(stderr,"FvwmAuto Version "VERSION" should only be executed by fvwm!\n"); exit(1); } if (module->user_argc < 1 || module->user_argc > 5) { fprintf(stderr,"FvwmAuto can use one to five arguments.\n"); exit(1); } /* Dead pipes mean fvwm died */ #ifdef HAVE_SIGACTION { struct sigaction sigact; sigemptyset(&sigact.sa_mask); sigaddset(&sigact.sa_mask, SIGPIPE); sigaddset(&sigact.sa_mask, SIGINT); sigaddset(&sigact.sa_mask, SIGHUP); sigaddset(&sigact.sa_mask, SIGQUIT); sigaddset(&sigact.sa_mask, SIGTERM); #ifdef SA_RESTART sigact.sa_flags = SA_RESTART; # else sigact.sa_flags = 0; #endif sigact.sa_handler = TerminateHandler; sigaction(SIGPIPE, &sigact, NULL); sigaction(SIGINT, &sigact, NULL); sigaction(SIGHUP, &sigact, NULL); sigaction(SIGQUIT, &sigact, NULL); sigaction(SIGTERM, &sigact, NULL); } #else /* We don't have sigaction(), so fall back to less robust methods. */ #ifdef USE_BSD_SIGNALS fvwmSetSignalMask( sigmask(SIGPIPE) | sigmask(SIGINT) | sigmask(SIGHUP) | sigmask(SIGQUIT) | sigmask(SIGTERM) ); #endif signal(SIGPIPE, TerminateHandler); signal(SIGINT, TerminateHandler); signal(SIGHUP, TerminateHandler); signal(SIGQUIT, TerminateHandler); signal(SIGTERM, TerminateHandler); #ifdef HAVE_SIGINTERRUPT siginterrupt(SIGPIPE, 0); siginterrupt(SIGINT, 0); siginterrupt(SIGHUP, 0); siginterrupt(SIGQUIT, 0); siginterrupt(SIGTERM, 0); #endif #endif fd[0] = module->to_fvwm; fd[1] = module->from_fvwm; if ((timeout = atoi(module->user_argv[0]) )) { sec = timeout / 1000; usec = (timeout % 1000) * 1000; } else { sec = 0; usec = 1000; } delay = &value; n = 1; if (n < module->user_argc && module->user_argv[n]) { char *token; /* -passid option */ if (n < module->user_argc && *module->user_argv[n] && StrEquals(module->user_argv[n], "-passid")) { do_pass_id = True; n++; } if (n < module->user_argc && *module->user_argv[n] && StrEquals(module->user_argv[n], "-menterleave")) { /* enterleave mode */ use_leave_mode = True; use_enter_mode = True; n++; } else if (n < module->user_argc && *module->user_argv[n] && StrEquals(module->user_argv[n], "-menter")) { /* enter mode */ use_leave_mode = False; use_enter_mode = True; n++; } else if (n < module->user_argc && *module->user_argv[n] && StrEquals(module->user_argv[n], "-mfocus")) { /* focus mode */ use_leave_mode = False; use_enter_mode = False; n++; } /*** enter command ***/ if (n < module->user_argc && *module->user_argv[n] && StrEquals(module->user_argv[n], "Nop")) { /* nop */ enter_fn = NULL; n++; } else if (n < module->user_argc) { /* override default */ enter_fn = module->user_argv[n]; n++; } /* This is a hack to prevent user interaction with old configs. */ if (enter_fn) { token = PeekToken(enter_fn, NULL); if (!StrEquals(token, "Silent")) { enter_fn = safestrdup( CatString2("Silent ", enter_fn)); } } /*** leave command ***/ if (n < module->user_argc && module->user_argv[n] && *module->user_argv[n] && StrEquals(module->user_argv[n], "Nop")) { /* nop */ leave_fn = NULL; n++; } else if (n < module->user_argc) { /* leave function specified */ leave_fn=module->user_argv[n]; n++; } if (leave_fn) { token = PeekToken(leave_fn, NULL); if (!StrEquals(token, "Silent")) { leave_fn = safestrdup( CatString2("Silent ", leave_fn)); } } } /* Exit if nothing to do. */ if (!enter_fn && !leave_fn) { return -1; } if (use_enter_mode) { m_mask = 0; mx_mask = MX_ENTER_WINDOW | MX_LEAVE_WINDOW | M_EXTENDED_MSG; } else { mx_mask = M_EXTENDED_MSG; m_mask = M_FOCUS_CHANGE; } /* Disable special raise/lower support on general actions. * * This works as expected in most of cases. */ if (matchWildcards("*Raise*", CatString2(enter_fn, leave_fn)) || matchWildcards("*Lower*", CatString2(enter_fn, leave_fn))) { m_mask |= M_RAISE_WINDOW | M_LOWER_WINDOW; } /* migo (04/May/2000): It is simply incorrect to listen to raise/lower * packets and change the state if the action itself has no raise/lower. * Detecting whether to listen or not by the action name is good enough. m_mask = M_FOCUS_CHANGE | M_RAISE_WINDOW | M_LOWER_WINDOW; */ SetMessageMask(fd, m_mask); SetMessageMask(fd, mx_mask); /* tell fvwm we're running */ SendFinishedStartupNotification(fd); /* tell fvwm that we want to be lock on send */ SetSyncMask(fd, m_mask); SetSyncMask(fd, mx_mask); fd_width = fd[1] + 1; FD_ZERO(&in_fdset); /* create the command buffer */ len = 0; if (enter_fn != 0) { len = strlen(enter_fn); } if (leave_fn != NULL) { len = max(len, strlen(leave_fn)); } if (do_pass_id) { len += 32; } buf = safemalloc(len); while (!isTerminated) { char raise_window_now; static char have_new_window = 0; FD_SET(fd[1], &in_fdset); myfprintf( (stderr, "\nstart %d (hnw = %d, usec = %d)\n", count++, have_new_window, usec)); /* fill in struct - modified by select() */ delay->tv_sec = sec; delay->tv_usec = usec; #ifdef DEBUG { char tmp[32]; sprintf(tmp, "%d usecs", (delay) ? (int)delay->tv_usec : -1); myfprintf((stderr, "select: delay = %s\n", (have_new_window) ? tmp : "infinite" )); } #endif if (fvwmSelect(fd_width, &in_fdset, NULL, NULL, (have_new_window) ? delay : NULL) == -1) { myfprintf( (stderr, "select: error! (%s)\n", strerror(errno))); break; } raise_window_now = 0; if (FD_ISSET(fd[1], &in_fdset)) { FvwmPacket *packet = ReadFvwmPacket(fd[1]); if (packet == NULL) { myfprintf( (stderr, "Leaving because of null packet\n")); break; } myfprintf( (stderr, "pw = 0x%x, fw=0x%x, rw = 0x%x, lw=0x%x\n", (int)packet->body[0], (int)focus_win, (int)raised_win, (int)last_win)); switch (packet->type) { case MX_ENTER_WINDOW: focus_win = packet->body[0]; if (focus_win != raised_win) { myfprintf((stderr, "entered new window\n")); have_new_window = 1; raise_window_now = 0; } else if (focus_win == last_win) { have_new_window = 0; } else { myfprintf((stderr, "entered other window\n")); } break; case MX_LEAVE_WINDOW: if (use_leave_mode) { if (focus_win == raised_win) { focus_win = 0; } myfprintf((stderr, "left raised window\n")); have_new_window = 1; raise_window_now = 0; } break; case M_FOCUS_CHANGE: /* it's a focus package */ focus_win = packet->body[0]; if (focus_win != raised_win) { myfprintf((stderr, "focus on new window\n")); have_new_window = 1; raise_window_now = 0; } else { myfprintf((stderr, "focus on old window\n")); } break; case M_RAISE_WINDOW: myfprintf( (stderr, "raise packet 0x%x\n", (int)packet->body[0])); raised_win = packet->body[0]; if (have_new_window && focus_win == raised_win) { myfprintf( (stderr, "its the old window:" " don't raise\n")); have_new_window = 0; } break; case M_LOWER_WINDOW: myfprintf( (stderr, "lower packet 0x%x\n", (int)packet->body[0])); if (have_new_window && focus_win == packet->body[0]) { myfprintf( (stderr, "window was explicitly" " lowered, don't raise it" " again\n")); have_new_window = 0; } break; } /* switch */ SendUnlockNotification(fd); } else { if (have_new_window) { myfprintf((stderr, "must raise now\n")); raise_window_now = 1; } } if (raise_window_now) { myfprintf((stderr, "raising 0x%x\n", (int)focus_win)); if (leave_fn && ((last_win && !use_leave_mode) || (raised_win && use_enter_mode))) { /* if focus_win isn't the root */ if (do_pass_id) { sprintf(buf, "%s 0x%x\n", leave_fn, (int)last_win); } else { sprintf(buf, "%s\n", leave_fn); } SendInfo(fd, buf, last_win); if (use_enter_mode) { raised_win = 0; } } if (focus_win && enter_fn) { /* if focus_win isn't the root */ if (do_pass_id) { sprintf(buf, "%s 0x%x\n", enter_fn, (int)focus_win); } else { sprintf(buf, "%s\n", enter_fn); } SendInfo(fd, buf, focus_win); raised_win = focus_win; } else if (focus_win && enter_fn == NULL) { raised_win = focus_win; } /* force fvwm to synchronise on slow X connections to * avoid a race condition. Still possible, but much * less likely. */ SendInfo(fd, "XSync", focus_win); /* switch to wait mode again */ last_win = focus_win; have_new_window = 0; } } /* while */ return 0; }
static void FlocaleInit_X_Charset(Display *dpy, const char *module) { #ifdef HAVE_XOUTPUT_METHOD XOM om; XOMCharSetList cs; int i; om = XOpenOM(dpy, NULL, NULL, NULL); if (om && XGetOMValues(om, XNRequiredCharSet, &cs, NULL) == NULL) { if (cs.charset_count > 0) { if (FLCXOMCharsetList != NULL) { free(FLCXOMCharsetList); } FLCXOMCharsetList_num = cs.charset_count; FLCXOMCharsetList = (FlocaleCharset **)safemalloc( sizeof(FlocaleCharset) * cs.charset_count); for (i = 0; i < FLCXOMCharsetList_num; i++) { FLCXOMCharsetList[i] = FlocaleCharsetOfXCharset( cs.charset_list[i]); #if FLOCALE_DEBUG_CHARSET fprintf(stderr, "[FlocaleInitCharset] XOM charset " "%i: %s, bidi:%s\n", i, FLC_DEBUG_GET_X_CHARSET( FLCXOMCharsetList[i]), FLC_DEBUG_GET_BIDI_CHARSET ( FLCXOMCharsetList[i])); #endif } } } if (om) { XCloseOM(om); } if (FLCXOMCharsetList_num > 0 && FLCXOMCharsetList[0]) { char *best_charset; if (FLCLocaleCharset != NULL) { best_charset = FLCLocaleCharset->x; #if FLOCALE_DEBUG_CHARSET fprintf(stderr, "[FlocaleInitCharset] FLCLocaleCharset: %s\n", best_charset); #endif } else { best_charset = FLOCALE_FALLBACK_XCHARSET; #if FLOCALE_DEBUG_CHARSET fprintf(stderr, "[FlocaleInitCharset] FALLBACK: %s\n", best_charset); #endif } FLCXOMCharset = FLCXOMCharsetList[0]; if (best_charset == NULL) { /* should not happen */ } else { for(i = 0; i < FLCXOMCharsetList_num; i++) { if (StrEquals( best_charset, FLC_DEBUG_GET_X_CHARSET( FLCXOMCharsetList[i]))) { FLCXOMCharset = FLCXOMCharsetList[i]; break; } } } #if FLOCALE_DEBUG_CHARSET fprintf(stderr, "[FlocaleInitCharset] XOM charset " "%i: %s\n", i, FLC_DEBUG_GET_X_CHARSET(FLCXOMCharset)); #endif } #endif }
// Attempt to load the resource file from the locale, first. // If that fails, then just try any subdirectory of of the path provided static void *LoadLocalFile(const MyString &path, const MyString &dllName, LocalizedFileHandler lfh) { if (IsEmptyStr(path) || IsEmptyStr(dllName)) return NULL; MyString pathTemp = path; // Languages are checked in the following order. // 1) The UI language: this is returned by GetUserDefaultUILanguage. // 2) As step 1, but with SUBLANG_DEFAULT // 3) English // 4) Any language that can be found! MyString localePath = FindLocaleDirectory(pathTemp, dllName); if (IsEmptyStr(localePath)) { // None of the default choices exists, so now look for the first version of the dll in the given path. // We don't bother to see if the console supports the dll's language. MyString wildCard = MakePath(pathTemp, W("*.*")); WIN32_FIND_DATAW wfdw; HANDLE hDirs = FindFirstFileW(GetChars(wildCard), &wfdw); if (hDirs == INVALID_HANDLE_VALUE) return NULL; do { // We are only interested in directories, since at this level, that should // be the only thing in this directory, i.e, LCID sub dirs if (wfdw.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { MyString file(wfdw.cFileName); if (StrEquals(file, W("."))) continue; if (StrEquals(file, W(".."))) continue; // Does this dir have the resource dll? MyString fullPath = MakePath(pathTemp, file, dllName); if (GetFileAttributesW(GetChars(fullPath)) != INVALID_FILE_ATTRIBUTES) { localePath = fullPath; // Got it - bail out of here break; } } } while (FindNextFileW(hDirs, &wfdw)); FindClose(hDirs); if (IsEmptyStr(localePath)) { // // With CoreCLR we have the resource dll directly in the bin directory so check there now. // // Does this dir have the resource dll? MyString fullPath = MakePath(path, dllName); if (GetFileAttributesW(GetChars(fullPath)) != INVALID_FILE_ATTRIBUTES) { localePath = fullPath; // Got it - bail out of here } } } // Attempt to load the library // Beware! A dll loaded with LOAD_LIBRARY_AS_DATAFILE won't // let you use LoadIcon and things like that (only general calls like FindResource and LoadResource). return IsEmptyStr(localePath) ? NULL : lfh(GetChars(localePath)); }
static void __execute_function( cond_rc_t *cond_rc, const exec_context_t *exc, char *action, FUNC_FLAGS_TYPE exec_flags, char *args[], Bool has_ref_window_moved) { static int func_depth = 0; cond_rc_t *func_rc = NULL; cond_rc_t dummy_rc; Window w; int j; char *function; char *taction; char *trash; char *trash2; char *expaction = NULL; char *arguments[11]; const func_t *bif; Bool set_silent; Bool must_free_string = False; Bool must_free_function = False; Bool do_keep_rc = False; /* needed to be able to avoid resize to use moved windows for base */ extern Window PressedW; Window dummy_w; if (!action) { return; } /* ignore whitespace at the beginning of all config lines */ action = SkipSpaces(action, NULL, 0); if (!action || action[0] == 0) { /* impossibly short command */ return; } if (action[0] == '#') { /* a comment */ return; } func_depth++; if (func_depth > MAX_FUNCTION_DEPTH) { fvwm_msg( ERR, "__execute_function", "Function '%s' called with a depth of %i, " "stopping function execution!", action, func_depth); func_depth--; return; } if (args) { for (j = 0; j < 11; j++) { arguments[j] = args[j]; } } else { for (j = 0; j < 11; j++) { arguments[j] = NULL; } } if (exc->w.fw == NULL || IS_EWMH_DESKTOP(FW_W(exc->w.fw))) { if (exec_flags & FUNC_IS_UNMANAGED) { w = exc->w.w; } else { w = Scr.Root; } } else { FvwmWindow *tw; w = GetSubwindowFromEvent(dpy, exc->x.elast); if (w == None) { w = exc->x.elast->xany.window; } tw = NULL; if (w != None) { if (XFindContext( dpy, w, FvwmContext, (caddr_t *)&tw) == XCNOENT) { tw = NULL; } } if (w == None || tw != exc->w.fw) { w = FW_W(exc->w.fw); } } set_silent = False; if (action[0] == '-') { exec_flags |= FUNC_DONT_EXPAND_COMMAND; action++; } taction = action; /* parse prefixes */ trash = PeekToken(taction, &trash2); while (trash) { if (StrEquals(trash, PRE_SILENT)) { if (Scr.flags.are_functions_silent == 0) { set_silent = 1; Scr.flags.are_functions_silent = 1; } taction = trash2; trash = PeekToken(taction, &trash2); } else if (StrEquals(trash, PRE_KEEPRC)) { do_keep_rc = True; taction = trash2; trash = PeekToken(taction, &trash2); } else { break; } } if (taction == NULL) { if (set_silent) { Scr.flags.are_functions_silent = 0; } func_depth--; return; } if (cond_rc == NULL || do_keep_rc == True) { condrc_init(&dummy_rc); func_rc = &dummy_rc; } else { func_rc = cond_rc; } GetNextToken(taction, &function); if (function) { char *tmp = function; function = expand_vars( function, arguments, False, False, func_rc, exc); free(tmp); } if (function && function[0] != '*') { #if 1 /* DV: with this piece of code it is impossible to have a * complex function with embedded whitespace that begins with a * builtin function name, e.g. a function "echo hello". */ /* DV: ... and without it some of the complex functions will * fail */ char *tmp = function; while (*tmp && !isspace(*tmp)) { tmp++; } *tmp = 0; #endif bif = find_builtin_function(function); must_free_function = True; } else { bif = NULL; if (function) { free(function); } function = ""; } if (Scr.cur_decor && Scr.cur_decor != &Scr.DefaultDecor && (!bif || !(bif->flags & FUNC_DECOR))) { fvwm_msg( ERR, "__execute_function", "Command can not be added to a decor; executing" " command now: '%s'", action); } if (!(exec_flags & FUNC_DONT_EXPAND_COMMAND)) { expaction = expand_vars( taction, arguments, (bif) ? !!(bif->flags & FUNC_ADD_TO) : False, (taction[0] == '*'), func_rc, exc); if (func_depth <= 1) { must_free_string = set_repeat_data( expaction, REPEAT_COMMAND, bif); } else { must_free_string = True; } } else { expaction = taction; } #ifdef FVWM_COMMAND_LOG fvwm_msg(INFO, "LOG", "%c: %s", (char)exc->type, expaction); #endif /* Note: the module config command, "*" can not be handled by the * regular command table because there is no required white space after * the asterisk. */ if (expaction[0] == '*') { if (Scr.cur_decor && Scr.cur_decor != &Scr.DefaultDecor) { fvwm_msg( WARN, "__execute_function", "Command can not be added to a decor;" " executing command now: '%s'", expaction); } /* process a module config command */ ModuleConfig(expaction); } else { const exec_context_t *exc2; exec_context_changes_t ecc; exec_context_change_mask_t mask; mask = (w != exc->w.w) ? ECC_W : 0; ecc.w.fw = exc->w.fw; ecc.w.w = w; ecc.w.wcontext = exc->w.wcontext; if (bif && bif->func_t != F_FUNCTION) { char *runaction; Bool rc = False; runaction = SkipNTokens(expaction, 1); if ((bif->flags & FUNC_NEEDS_WINDOW) && !(exec_flags & FUNC_DONT_DEFER)) { rc = DeferExecution( &ecc, &mask, bif->cursor, exc->x.elast->type, (bif->flags & FUNC_ALLOW_UNMANAGED)); } else if ((bif->flags & FUNC_NEEDS_WINDOW) && !__context_has_window( exc, bif->flags & FUNC_ALLOW_UNMANAGED)) { /* no context window and not allowed to defer, * skip command */ rc = True; } if (rc == False) { exc2 = exc_clone_context(exc, &ecc, mask); if (has_ref_window_moved && (bif->func_t == F_ANIMATED_MOVE || bif->func_t == F_MOVE || bif->func_t == F_RESIZE || bif->func_t == F_RESIZEMOVE || bif->func_t == F_RESIZE_MAXIMIZE || bif->func_t == F_RESIZEMOVE_MAXIMIZE)) { dummy_w = PressedW; PressedW = None; bif->action(func_rc, exc2, runaction); PressedW = dummy_w; } else { bif->action(func_rc, exc2, runaction); } exc_destroy_context(exc2); } } else { Bool desperate = 1; char *runaction; if (bif) { /* strip "function" command */ runaction = SkipNTokens(expaction, 1); } else { runaction = expaction; } exc2 = exc_clone_context(exc, &ecc, mask); execute_complex_function( func_rc, exc2, runaction, &desperate, has_ref_window_moved); if (!bif && desperate) { if (executeModuleDesperate( func_rc, exc, runaction) == NULL && *function != 0 && !set_silent) { fvwm_msg( ERR, "__execute_function", "No such command '%s'", function); } } exc_destroy_context(exc2); } } if (set_silent) { Scr.flags.are_functions_silent = 0; } if (cond_rc != NULL) { cond_rc->break_levels = func_rc->break_levels; } if (must_free_string) { free(expaction); } if (must_free_function) { free(function); } func_depth--; return; }
/* * * Moves focus to specified window; only to be called bay Focus and FlipFocus * */ static void __activate_window_by_command( F_CMD_ARGS, int is_focus_by_flip_focus_cmd) { int cx; int cy; Bool do_not_warp; sftfwin_args_t sf_args; FvwmWindow * const fw = exc->w.fw; memset(&sf_args, 0, sizeof(sf_args)); sf_args.do_allow_force_broadcast = 1; sf_args.is_focus_by_flip_focus_cmd = is_focus_by_flip_focus_cmd; sf_args.set_by = FOCUS_SET_BY_FUNCTION; sf_args.client_entered = 0; if (fw == NULL || !FP_DO_FOCUS_BY_FUNCTION(FW_FOCUS_POLICY(fw))) { UngrabEm(GRAB_NORMAL); if (fw) { /* give the window a chance to take the focus itself */ sf_args.do_forbid_warp = 1; sf_args.do_force = 0; set_focus_to_fwin(FW_W(fw), fw, &sf_args); } return; } do_not_warp = StrEquals(PeekToken(action, NULL), "NoWarp"); if (!do_not_warp) { if (fw->Desk != Scr.CurrentDesk) { goto_desk(fw->Desk); } if (IS_ICONIFIED(fw)) { rectangle g; Bool rc; rc = get_visible_icon_title_geometry(fw, &g); if (rc == False) { get_visible_icon_picture_geometry(fw, &g); } cx = g.x + g.width / 2; cy = g.y + g.height / 2; } else { cx = fw->g.frame.x + fw->g.frame.width/2; cy = fw->g.frame.y + fw->g.frame.height/2; } if ( cx < 0 || cx >= Scr.MyDisplayWidth || cy < 0 || cy >= Scr.MyDisplayHeight) { int dx; int dy; dx = ((cx + Scr.Vx) / Scr.MyDisplayWidth) * Scr.MyDisplayWidth; dy = ((cy + Scr.Vy) / Scr.MyDisplayHeight) * Scr.MyDisplayHeight; MoveViewport(dx, dy, True); } #if 0 /* can not happen */ /* If the window is still not visible, make it visible! */ if (fw->g.frame.x + fw->g.frame.width < 0 || fw->g.frame.y + fw->g.frame.height < 0 || fw->g.frame.x >= Scr.MyDisplayWidth || fw->g.frame.y >= Scr.MyDisplayHeight) { frame_setup_window( fw, 0, 0, fw->g.frame.width, fw->g.frame.height, False); if ( FP_DO_WARP_POINTER_ON_FOCUS_FUNC( FW_FOCUS_POLICY(fw))) { FWarpPointerUpdateEvpos( exc->x.elast, dpy, None, Scr.Root, 0, 0, 0, 0, 2, 2); } } #endif } UngrabEm(GRAB_NORMAL); if (fw->Desk == Scr.CurrentDesk) { FvwmWindow *sf; sf = get_focus_window(); sf_args.do_forbid_warp = !!do_not_warp; sf_args.do_force = 0; sf_args.client_entered = 0; set_focus_to_fwin(FW_W(fw), fw, &sf_args); if (sf != get_focus_window()) { /* Ignore EnterNotify event while we are waiting for * this window to be focused. */ Scr.focus_in_pending_window = sf; } } return; }
Bool EWMH_CMD_Style(char *token, window_style *ptmpstyle, int on) { int found = False; if (StrEquals(token, "EWMHDonateIcon")) { found = True; S_SET_DO_EWMH_DONATE_ICON(SCF(*ptmpstyle), on); S_SET_DO_EWMH_DONATE_ICON(SCM(*ptmpstyle), 1); S_SET_DO_EWMH_DONATE_ICON(SCC(*ptmpstyle), 1); } else if (StrEquals(token, "EWMHDonateMiniIcon")) { found = True; S_SET_DO_EWMH_DONATE_MINI_ICON(SCF(*ptmpstyle), on); S_SET_DO_EWMH_DONATE_MINI_ICON(SCM(*ptmpstyle), 1); S_SET_DO_EWMH_DONATE_MINI_ICON(SCC(*ptmpstyle), 1); } else if (StrEquals(token, "EWMHDontDonateIcon")) { found = True; S_SET_DO_EWMH_DONATE_ICON(SCF(*ptmpstyle), !on); S_SET_DO_EWMH_DONATE_ICON(SCM(*ptmpstyle), 1); S_SET_DO_EWMH_DONATE_ICON(SCC(*ptmpstyle), 1); } else if (StrEquals(token, "EWMHDontDonateMiniIcon")) { found = True; S_SET_DO_EWMH_DONATE_MINI_ICON(SCF(*ptmpstyle), !on); S_SET_DO_EWMH_DONATE_MINI_ICON(SCM(*ptmpstyle), 1); S_SET_DO_EWMH_DONATE_MINI_ICON(SCC(*ptmpstyle), 1); } else if (StrEquals(token, "EWMHMaximizeIgnoreWorkingArea")) { found = True; S_SET_EWMH_MAXIMIZE_MODE( SCF(*ptmpstyle), EWMH_IGNORE_WORKING_AREA); S_SET_EWMH_MAXIMIZE_MODE( SCM(*ptmpstyle), EWMH_WORKING_AREA_MASK); S_SET_EWMH_MAXIMIZE_MODE( SCC(*ptmpstyle), EWMH_WORKING_AREA_MASK); } else if (StrEquals(token, "EWMHMaximizeUseWorkingArea")) { found = True; S_SET_EWMH_MAXIMIZE_MODE( SCF(*ptmpstyle), EWMH_USE_WORKING_AREA); S_SET_EWMH_MAXIMIZE_MODE( SCM(*ptmpstyle), EWMH_WORKING_AREA_MASK); S_SET_EWMH_MAXIMIZE_MODE( SCC(*ptmpstyle), EWMH_WORKING_AREA_MASK); } else if (StrEquals(token, "EWMHMaximizeUseDynamicWorkingArea")) { found = True; S_SET_EWMH_MAXIMIZE_MODE( SCF(*ptmpstyle), EWMH_USE_DYNAMIC_WORKING_AREA); S_SET_EWMH_MAXIMIZE_MODE( SCM(*ptmpstyle), EWMH_WORKING_AREA_MASK); S_SET_EWMH_MAXIMIZE_MODE( SCC(*ptmpstyle), EWMH_WORKING_AREA_MASK); } else if (StrEquals(token, "EWMHMiniIconOverride")) { found = True; S_SET_DO_EWMH_MINI_ICON_OVERRIDE(SCF(*ptmpstyle), on); S_SET_DO_EWMH_MINI_ICON_OVERRIDE(SCM(*ptmpstyle), 1); S_SET_DO_EWMH_MINI_ICON_OVERRIDE(SCC(*ptmpstyle), 1); } else if (StrEquals(token, "EWMHNoMiniIconOverride")) { found = True; S_SET_DO_EWMH_MINI_ICON_OVERRIDE(SCF(*ptmpstyle), !on); S_SET_DO_EWMH_MINI_ICON_OVERRIDE(SCM(*ptmpstyle), 1); S_SET_DO_EWMH_MINI_ICON_OVERRIDE(SCC(*ptmpstyle), 1); } else if (StrEquals(token, "EWMHPlacementIgnoreWorkingArea")) { found = True; ptmpstyle->flags.ewmh_placement_mode = EWMH_IGNORE_WORKING_AREA; ptmpstyle->flag_mask.ewmh_placement_mode = EWMH_WORKING_AREA_MASK; ptmpstyle->change_mask.ewmh_placement_mode = EWMH_WORKING_AREA_MASK; } else if (StrEquals(token, "EWMHPlacementUseWorkingArea")) { found = True; ptmpstyle->flags.ewmh_placement_mode = EWMH_USE_WORKING_AREA; ptmpstyle->flag_mask.ewmh_placement_mode = EWMH_WORKING_AREA_MASK; ptmpstyle->change_mask.ewmh_placement_mode = EWMH_WORKING_AREA_MASK; } else if (StrEquals(token, "EWMHPlacementUseDynamicWorkingArea")) { found = True; ptmpstyle->flags.ewmh_placement_mode = EWMH_USE_DYNAMIC_WORKING_AREA; ptmpstyle->flag_mask.ewmh_placement_mode = EWMH_WORKING_AREA_MASK; ptmpstyle->change_mask.ewmh_placement_mode = EWMH_WORKING_AREA_MASK; } else if (StrEquals(token, "EWMHUseStackingOrderHints")) { found = True; S_SET_DO_EWMH_USE_STACKING_HINTS(SCF(*ptmpstyle), on); S_SET_DO_EWMH_USE_STACKING_HINTS(SCM(*ptmpstyle), 1); S_SET_DO_EWMH_USE_STACKING_HINTS(SCC(*ptmpstyle), 1); } else if (StrEquals(token, "EWMHIgnoreStackingOrderHints")) { found = True; S_SET_DO_EWMH_USE_STACKING_HINTS(SCF(*ptmpstyle), !on); S_SET_DO_EWMH_USE_STACKING_HINTS(SCM(*ptmpstyle), 1); S_SET_DO_EWMH_USE_STACKING_HINTS(SCC(*ptmpstyle), 1); } else if (StrEquals(token, "EWMHUseStateHints")) { found = True; S_SET_DO_EWMH_IGNORE_STATE_HINTS(SCF(*ptmpstyle), !on); S_SET_DO_EWMH_IGNORE_STATE_HINTS(SCM(*ptmpstyle), 1); S_SET_DO_EWMH_IGNORE_STATE_HINTS(SCC(*ptmpstyle), 1); } else if (StrEquals(token, "EWMHIgnoreStateHints")) { found = True; S_SET_DO_EWMH_IGNORE_STATE_HINTS(SCF(*ptmpstyle), on); S_SET_DO_EWMH_IGNORE_STATE_HINTS(SCM(*ptmpstyle), 1); S_SET_DO_EWMH_IGNORE_STATE_HINTS(SCC(*ptmpstyle), 1); } else if (StrEquals(token, "EWMHUseStrutHints")) { found = True; S_SET_DO_EWMH_IGNORE_STRUT_HINTS(SCF(*ptmpstyle), !on); S_SET_DO_EWMH_IGNORE_STRUT_HINTS(SCM(*ptmpstyle), 1); S_SET_DO_EWMH_IGNORE_STRUT_HINTS(SCC(*ptmpstyle), 1); } else if (StrEquals(token, "EWMHIgnoreStrutHints")) { found = True; S_SET_DO_EWMH_IGNORE_STRUT_HINTS(SCF(*ptmpstyle), on); S_SET_DO_EWMH_IGNORE_STRUT_HINTS(SCM(*ptmpstyle), 1); S_SET_DO_EWMH_IGNORE_STRUT_HINTS(SCC(*ptmpstyle), 1); } else if (StrEquals(token, "EWMHIgnoreWindowType")) { found = True; S_SET_DO_EWMH_IGNORE_WINDOW_TYPE(SCF(*ptmpstyle), on); S_SET_DO_EWMH_IGNORE_WINDOW_TYPE(SCM(*ptmpstyle), 1); S_SET_DO_EWMH_IGNORE_WINDOW_TYPE(SCC(*ptmpstyle), 1); } return found; }
/* This function is really tricky. The two offsets are the offsets of the * colorset members of the DeskInfo and PagerSringList structures to be * modified. The lines accessing this info look very ugly, but they work. */ static void ParseColorset(char *arg1, char *arg2, void *offset_deskinfo, void *offset_item, int *colorset_global) { Bool all_desks = False; int colorset = 0; int i; int desk; unsigned int colorset_offset = (unsigned int)offset_deskinfo; unsigned int item_colorset_offset = (unsigned int)offset_item; sscanf(arg2, "%d", &colorset); AllocColorset(colorset); if (StrEquals(arg1, "*")) { all_desks = True; desk = Scr.CurrentDesk; } else { desk = desk1; sscanf(arg1,"%d",&desk); } if (fAlwaysCurrentDesk) { if (all_desks) { *colorset_global = colorset; } else { PagerStringList *item; item = FindDeskStrings(desk); if (item->next != NULL) { *(int *)(((char *)(item->next)) + item_colorset_offset) = colorset; } else { /* new Dcolor and desktop */ item = NewPagerStringItem(item, desk); *(int *)(((char *)item) + item_colorset_offset) = colorset; } } if (desk == Scr.CurrentDesk || all_desks) { *(int *)(((char *)&Desks[0]) + colorset_offset) = colorset; } } else if (all_desks) { for (i = 0; i < ndesks; i++) { *(int *)(((char *)&Desks[i]) + colorset_offset) = colorset; } } else if((desk >= desk1)&&(desk <=desk2)) { *(int *)(((char *)&Desks[desk - desk1]) + colorset_offset) = colorset; } return; }
void CMD_WarpToWindow(F_CMD_ARGS) { int val1_unit, val2_unit, n; int val1, val2; int do_raise; char *next; char *token; next = GetNextToken(action, &token); if (StrEquals(token, "!raise")) { do_raise = 0; action = next; } else if (StrEquals(token, "raise")) { do_raise = 1; action = next; } else { do_raise = 1; } n = GetTwoArguments(action, &val1, &val2, &val1_unit, &val2_unit); if (exc->w.wcontext != C_UNMANAGED) { if (n == 2) { warp_to_fvwm_window( exc, val1, val1_unit, val2, val2_unit, do_raise); } else { warp_to_fvwm_window(exc, 0, 0, 0, 0, do_raise); } } else { int x = 0; int y = 0; if (n == 2) { int wx; int wy; int ww; int wh; if (!XGetGeometry( dpy, exc->w.w, &JunkRoot, &wx, &wy, (unsigned int*)&ww, (unsigned int*)&wh, (unsigned int*)&JunkBW, (unsigned int*)&JunkDepth)) { return; } if (val1_unit != Scr.MyDisplayWidth) { x = val1; } else { x = (ww - 1) * val1 / 100; } if (val2_unit != Scr.MyDisplayHeight) { y = val2; } else { y = (wh - 1) * val2 / 100; } if (x < 0) { x += ww; } if (y < 0) { y += wh; } } FWarpPointerUpdateEvpos( exc->x.elast, dpy, None, exc->w.w, 0, 0, 0, 0, x, y); } return; }
/***************************************************************************** * * This routine is responsible for reading and parsing the config file * ****************************************************************************/ void ParseOptions(void) { char *tline= NULL; int desk; int dx = 3; int dy = 3; Scr.FvwmRoot = NULL; Scr.Hilite = NULL; Scr.VScale = 32; Scr.MyDisplayWidth = DisplayWidth(dpy, Scr.screen); Scr.MyDisplayHeight = DisplayHeight(dpy, Scr.screen); InitGetConfigLine(fd,CatString3("*",MyName,0)); for (GetConfigLine(fd,&tline); tline != NULL; GetConfigLine(fd,&tline)) { int g_x, g_y, flags; unsigned width,height; char *resource; char *resource_string; char *arg1; char *arg2; char *tline2; char *token; char *next; Bool MoveThresholdSetForModule = False; resource_string = arg1 = arg2 = NULL; token = PeekToken(tline, &next); if (StrEquals(token, "Colorset")) { LoadColorset(next); continue; } else if (StrEquals(token, XINERAMA_CONFIG_STRING)) { FScreenConfigureModule(next); } else if (StrEquals(token, "DesktopSize")) { token = PeekToken(next, &next); if (token) { sscanf(token, "%d", &dx); token = PeekToken(next, &next); if (token) sscanf(token, "%d", &dy); } continue; } else if (StrEquals(token, "ImagePath")) { if (ImagePath != NULL) { free(ImagePath); ImagePath = NULL; } GetNextToken(next, &ImagePath); #ifdef DEBUG fprintf(stderr, "[ParseOptions]: ImagePath = %s\n", ImagePath); #endif continue; } else if (StrEquals(token, "MoveThreshold")) { if (!MoveThresholdSetForModule) { int val; if (GetIntegerArguments(next, NULL, &val, 1) > 0) { if (val >= 0) MoveThreshold = val; else MoveThreshold = DEFAULT_PAGER_MOVE_THRESHOLD; } } continue; } tline2 = GetModuleResource(tline, &resource, MyName); if (!resource) continue; tline2 = GetNextToken(tline2, &arg1); if (!arg1) { arg1 = (char *)safemalloc(1); arg1[0] = 0; } tline2 = GetNextToken(tline2, &arg2); if (!arg2) { arg2 = (char *)safemalloc(1); arg2[0] = 0; } if(StrEquals(resource,"Colorset")) { ParseColorset(arg1, arg2, &(((DeskInfo *)(NULL))->colorset), &(((PagerStringList *)(NULL))->colorset), &globalcolorset); } else if(StrEquals(resource,"BalloonColorset")) { ParseColorset(arg1, arg2, &(((DeskInfo *)(NULL))->ballooncolorset), &(((PagerStringList *)(NULL))->ballooncolorset), &globalballooncolorset); } else if(StrEquals(resource,"HilightColorset")) { ParseColorset(arg1, arg2, &(((DeskInfo *)(NULL))->highcolorset), &(((PagerStringList *)(NULL))->highcolorset), &globalhighcolorset); } else if (StrEquals(resource, "Geometry")) { window_w = 0; window_h = 0; window_x = 0; window_y = 0; xneg = 0; yneg = 0; usposition = 0; flags = FScreenParseGeometry(arg1,&g_x,&g_y,&width,&height); if (flags & WidthValue) { window_w = width; } if (flags & HeightValue) { window_h = height; } if (flags & XValue) { window_x = g_x; usposition = 1; if (flags & XNegative) { xneg = 1; } } if (flags & YValue) { window_y = g_y; usposition = 1; if (flags & YNegative) { yneg = 1; } } } else if (StrEquals(resource, "IconGeometry")) { icon_w = 0; icon_h = 0; icon_x = -10000; icon_y = -10000; icon_xneg = 0; icon_yneg = 0; flags = FScreenParseGeometry(arg1,&g_x,&g_y,&width,&height); if (flags & WidthValue) icon_w = width; if (flags & HeightValue) icon_h = height; if (flags & XValue) { icon_x = g_x; if (flags & XNegative) { icon_xneg = 1; } } if (flags & YValue) { icon_y = g_y; if (flags & YNegative) { icon_yneg = 1; } } } else if (StrEquals(resource, "Label")) { if (StrEquals(arg1, "*")) { desk = Scr.CurrentDesk; } else { desk = desk1; sscanf(arg1,"%d",&desk); } if (fAlwaysCurrentDesk) { PagerStringList *item; item = FindDeskStrings(desk); if (item->next != NULL) { /* replace label */ if (item->next->label != NULL) { free(item->next->label); item->next->label = NULL; } CopyString(&(item->next->label), arg2); } else { /* new Dcolor and desktop */ item = NewPagerStringItem(item, desk); CopyString(&(item->label), arg2); } if (desk == Scr.CurrentDesk) { free(Desks[0].label); CopyString(&Desks[0].label, arg2); } } else if((desk >= desk1)&&(desk <=desk2)) { free(Desks[desk - desk1].label); CopyString(&Desks[desk - desk1].label, arg2); } } else if (StrEquals(resource, "Font")) { if (font_string) free(font_string); if (next && next[0] == '\"') { int l; next++; CopyString(&font_string, next); l = strlen(font_string); if (l > 0 && font_string[l - 1] == '\"') { font_string[l - 1] = 0; } } else { CopyString(&font_string,next); } if(strncasecmp(font_string,"none",4) == 0) uselabel = 0; } else if (StrEquals(resource, "Fore")) { if(Pdepth > 1) { if (PagerFore) free(PagerFore); CopyString(&PagerFore,arg1); } } else if (StrEquals(resource, "Back")) { if(Pdepth > 1) { if (PagerBack) free(PagerBack); CopyString(&PagerBack,arg1); } } else if (StrEquals(resource, "DeskColor")) { if (StrEquals(arg1, "*")) { desk = Scr.CurrentDesk; } else { desk = desk1; sscanf(arg1,"%d",&desk); } if (fAlwaysCurrentDesk) { PagerStringList *item; item = FindDeskStrings(desk); if (item->next != NULL) { /* replace Dcolor */ if (item->next->Dcolor != NULL) { free(item->next->Dcolor); item->next->Dcolor = NULL; } CopyString(&(item->next->Dcolor), arg2); } else { /* new Dcolor and desktop */ item = NewPagerStringItem(item, desk); CopyString(&(item->Dcolor), arg2); } if (desk == Scr.CurrentDesk) { free(Desks[0].Dcolor); CopyString(&Desks[0].Dcolor, arg2); } } else if((desk >= desk1)&&(desk <=desk2)) { free(Desks[desk - desk1].Dcolor); CopyString(&Desks[desk - desk1].Dcolor, arg2); } } else if (StrEquals(resource, "DeskPixmap")) { if (StrEquals(arg1, "*")) { desk = Scr.CurrentDesk; } else { desk = desk1; sscanf(arg1,"%d",&desk); } if (fAlwaysCurrentDesk) { PagerStringList *item; item = FindDeskStrings(desk); if (item->next != NULL) { if (item->next->bgPixmap != NULL) { DestroyPicture(dpy, item->next->bgPixmap); item->next->bgPixmap = NULL; } item->next->bgPixmap = CachePicture (dpy, Scr.Pager_w, ImagePath, arg2, 0); } else { /* new Dcolor and desktop */ item = NewPagerStringItem(item, desk); item->bgPixmap = CachePicture (dpy, Scr.Pager_w, ImagePath, arg2, 0); } if (desk == Scr.CurrentDesk) { if (Desks[0].bgPixmap != NULL) { DestroyPicture(dpy, Desks[0].bgPixmap); Desks[0].bgPixmap = NULL; } Desks[0].bgPixmap = CachePicture (dpy, Scr.Pager_w, ImagePath, arg2, 0); } } else if((desk >= desk1)&&(desk <=desk2)) { int dNr = desk - desk1; if (Desks[dNr].bgPixmap != NULL) { DestroyPicture(dpy, Desks[dNr].bgPixmap); Desks[dNr].bgPixmap = NULL; } Desks[dNr].bgPixmap = CachePicture (dpy, Scr.Pager_w, ImagePath, arg2, 0); } #ifdef DEBUG fprintf(stderr, "[ParseOptions]: Desk %d: bgPixmap = %s\n", desk, arg2); #endif } else if (StrEquals(resource, "Pixmap")) { if(Pdepth > 1) { if (PixmapBack) { DestroyPicture (dpy, PixmapBack); PixmapBack = NULL; } PixmapBack = CachePicture (dpy, Scr.Pager_w, ImagePath, arg1, 0); #ifdef DEBUG fprintf(stderr, "[ParseOptions]: Global: bgPixmap = %s\n", arg1); #endif } } else if (StrEquals(resource, "HilightPixmap")) { if(Pdepth > 1) { if (HilightPixmap) { DestroyPicture (dpy, HilightPixmap); HilightPixmap = NULL; } HilightPixmap = CachePicture (dpy, Scr.Pager_w, ImagePath, arg1, 0); #ifdef DEBUG fprintf(stderr, "[ParseOptions]: HilightPixmap = %s\n", arg1); #endif } } else if (StrEquals(resource, "DeskHilight")) { HilightDesks = 1; } else if (StrEquals(resource, "NoDeskHilight")) { HilightDesks = 0; } else if (StrEquals(resource, "Hilight")) { if(Pdepth > 1) { if (HilightC) free(HilightC); CopyString(&HilightC,arg1); } } else if (StrEquals(resource, "SmallFont")) { if (smallFont) free(smallFont); if (next && next[0] == '\"') { int l; next++; CopyString(&smallFont, next); l = strlen(smallFont); if (l > 0 && smallFont[l - 1] == '\"') { smallFont[l - 1] = 0; } } else { CopyString(&smallFont,next); } if (strncasecmp(smallFont,"none",4) == 0) { free(smallFont); smallFont = NULL; } } else if (StrEquals(resource, "MiniIcons")) { MiniIcons = 1; } else if (StrEquals(resource, "StartIconic")) { StartIconic = 1; } else if (StrEquals(resource, "NoStartIconic")) { StartIconic = 0; } else if (StrEquals(resource, "LabelsBelow")) { LabelsBelow = 1; } else if (StrEquals(resource, "LabelsAbove")) { LabelsBelow = 0; } else if (FHaveShapeExtension && StrEquals(resource, "ShapeLabels")) { ShapeLabels = 1; } else if (FHaveShapeExtension && StrEquals(resource, "NoShapeLabels")) { ShapeLabels = 0; } else if (StrEquals(resource, "Rows")) { sscanf(arg1,"%d",&Rows); } else if (StrEquals(resource, "Columns")) { sscanf(arg1,"%d",&Columns); } else if (StrEquals(resource, "DeskTopScale")) { sscanf(arg1,"%d",&Scr.VScale); } else if (StrEquals(resource, "WindowColors")) { if (Pdepth > 1) { if (WindowFore) free(WindowFore); if (WindowBack) free(WindowBack); if (WindowHiFore) free(WindowHiFore); if (WindowHiBack) free(WindowHiBack); CopyString(&WindowFore, arg1); CopyString(&WindowBack, arg2); tline2 = GetNextToken(tline2, &WindowHiFore); GetNextToken(tline2, &WindowHiBack); } } else if (StrEquals(resource, "WindowBorderWidth")) { sscanf(arg1, "%d", &WindowBorderWidth); MinSize = 2 * WindowBorderWidth + 1; } else if (StrEquals(resource, "Window3dBorders")) { WindowBorders3d = True; } else if (StrEquals(resource,"WindowColorsets")) { sscanf(arg1,"%d",&windowcolorset); AllocColorset(windowcolorset); sscanf(arg2,"%d",&activecolorset); AllocColorset(activecolorset); } else if (StrEquals(resource,"WindowLabelFormat")) { if (WindowLabelFormat) free(WindowLabelFormat); CopyString(&WindowLabelFormat,arg1); } else if (StrEquals(resource, "MoveThreshold")) { int val; if (GetIntegerArguments(next, NULL, &val, 1) > 0 && val >= 0) { MoveThreshold = val; MoveThresholdSetForModule = True; } } else if (StrEquals(resource, "SloppyFocus")) { do_focus_on_enter = True; } else if (StrEquals(resource, "SolidSeparators")) { use_dashed_separators = False; use_no_separators = False; } else if (StrEquals(resource, "NoSeparators")) { use_no_separators = True; } /* ... and get Balloon config options ... -- [email protected] */ else if (StrEquals(resource, "Balloons")) { if (BalloonTypeString) free(BalloonTypeString); CopyString(&BalloonTypeString, arg1); if ( strncasecmp(BalloonTypeString, "Pager", 5) == 0 ) { ShowPagerBalloons = 1; ShowIconBalloons = 0; } else if ( strncasecmp(BalloonTypeString, "Icon", 4) == 0 ) { ShowPagerBalloons = 0; ShowIconBalloons = 1; } else { ShowPagerBalloons = 1; ShowIconBalloons = 1; } /* turn this on initially so balloon window is created; later this variable is changed to match ShowPagerBalloons or ShowIconBalloons whenever we receive iconify or deiconify packets */ ShowBalloons = 1; } else if (StrEquals(resource, "BalloonBack")) { if (Pdepth > 1) { if (BalloonBack) free(BalloonBack); CopyString(&BalloonBack, arg1); } } else if (StrEquals(resource, "BalloonFore")) { if (Pdepth > 1) { if (BalloonFore) free(BalloonFore); CopyString(&BalloonFore, arg1); } } else if (StrEquals(resource, "BalloonFont")) { if (BalloonFont) free(BalloonFont); CopyStringWithQuotes(&BalloonFont, next); } else if (StrEquals(resource, "BalloonBorderColor")) { if (BalloonBorderColor) free(BalloonBorderColor); CopyString(&BalloonBorderColor, arg1); } else if (StrEquals(resource, "BalloonBorderWidth")) { sscanf(arg1, "%d", &BalloonBorderWidth); } else if (StrEquals(resource, "BalloonYOffset")) { sscanf(arg1, "%d", &BalloonYOffset); } else if (StrEquals(resource,"BalloonStringFormat")) { if (BalloonFormatString) free(BalloonFormatString); CopyString(&BalloonFormatString,arg1); } free(resource); free(arg1); free(arg2); } Scr.VxMax = dx * Scr.MyDisplayWidth - Scr.MyDisplayWidth; Scr.VyMax = dy * Scr.MyDisplayHeight - Scr.MyDisplayHeight; if(Scr.VxMax <0) Scr.VxMax = 0; if(Scr.VyMax <0) Scr.VyMax = 0; Scr.VxPages = Scr.VxMax / Scr.MyDisplayWidth; Scr.VyPages = Scr.VyMax / Scr.MyDisplayHeight; Scr.VWidth = Scr.VxMax + Scr.MyDisplayWidth; Scr.VHeight = Scr.VyMax + Scr.MyDisplayHeight; Scr.Vx = 0; Scr.Vy = 0; return; }