static void position_notify (ChamplainLocation *location, G_GNUC_UNUSED GParamSpec *pspec, ChamplainPathLayer *layer) { schedule_redraw (layer); }
void execp_default_font_changed() { gboolean needs_update = FALSE; for (GList *l = panel_config.execp_list; l; l = l->next) { Execp *execp = l->data; if (!execp->backend->has_font) { pango_font_description_free(execp->backend->font_desc); execp->backend->font_desc = NULL; needs_update = TRUE; } } if (!needs_update) return; execp_init_fonts(); for (int i = 0; i < num_panels; i++) { for (GList *l = panels[i].execp_list; l; l = l->next) { Execp *execp = l->data; if (!execp->backend->has_font) { execp->area.resize_needed = TRUE; schedule_redraw(&execp->area); } } } panel_refresh = TRUE; }
void shrink_panel(Panel *panel) { if (!panel_shrink) return; int size = MIN(compute_desired_size(&panel->area), panel->max_size); gboolean update = FALSE; if (panel_horizontal) { if (panel->area.width != size) { panel->area.width = size; update = TRUE; } } else { if (panel->area.height != size) { panel->area.height = size; update = TRUE; } } if (update) { panel_compute_position(panel); set_panel_window_geometry(panel); set_panel_background(panel); panel->area.resize_needed = TRUE; systray.area.resize_needed = TRUE; schedule_redraw(&systray.area); refresh_systray = TRUE; } }
static void redraw_path_cb (G_GNUC_UNUSED GObject *gobject, G_GNUC_UNUSED GParamSpec *arg1, ChamplainPathLayer *layer) { schedule_redraw (layer); }
void ui_stat_job_bar_add(bg_op_t *bg_op) { const int prev_height = ui_stat_job_bar_height(); bg_op_t **p = reallocarray(bar_jobs, nbar_jobs + 1, sizeof(*bar_jobs)); if(p == NULL) { return; } bar_jobs = p; bar_jobs[nbar_jobs] = bg_op; ++nbar_jobs; if(!is_job_bar_visible()) { return; } update_job_bar(); if(ui_stat_job_bar_height() != prev_height) { schedule_redraw(); } }
void ui_stat_job_bar_remove(bg_op_t *bg_op) { size_t i; const int prev_height = ui_stat_job_bar_height(); for(i = 0U; i < nbar_jobs; ++i) { if(bar_jobs[i] == bg_op) { memmove(&bar_jobs[i], &bar_jobs[i + 1], sizeof(*bar_jobs)*(nbar_jobs - 1 - i)); break; } } --nbar_jobs; if(ui_stat_job_bar_height() != 0) { update_job_bar(); } else if(prev_height != 0) { schedule_redraw(); } }
void remove_icon(TrayWindow *traywin) { if (systray_profile) fprintf(stderr, "[%f] %s:%d win = %lu (%s)\n", profiling_get_time(), __FUNCTION__, __LINE__, traywin->win, traywin->name); Panel *panel = systray.area.panel; // remove from our list systray.list_icons = g_slist_remove(systray.list_icons, traywin); fprintf(stderr, YELLOW "remove_icon: %lu (%s)" RESET "\n", traywin->win, traywin->name); XSelectInput(server.display, traywin->win, NoEventMask); if (traywin->damage) XDamageDestroy(server.display, traywin->damage); // reparent to root XSync(server.display, False); error = FALSE; XErrorHandler old = XSetErrorHandler(window_error_handler); XUnmapWindow(server.display, traywin->win); XReparentWindow(server.display, traywin->win, server.root_win, 0, 0); XDestroyWindow(server.display, traywin->parent); XSync(server.display, False); XSetErrorHandler(old); stop_timeout(traywin->render_timeout); stop_timeout(traywin->resize_timeout); free(traywin->name); if (traywin->image) { imlib_context_set_image(traywin->image); imlib_free_image_and_decache(); } g_free(traywin); // check empty systray int count = 0; GSList *l; for (l = systray.list_icons; l; l = l->next) { count++; } if (count == 0) hide(&systray.area); // Resize and redraw the systray if (systray_profile) fprintf(stderr, BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n", profiling_get_time(), __FUNCTION__, __LINE__); systray.area.resize_needed = TRUE; panel->area.resize_needed = TRUE; schedule_redraw(&systray.area); refresh_systray = TRUE; }
static void relocate_cb (G_GNUC_UNUSED GObject *gobject, ChamplainPathLayer *layer) { g_return_if_fail (CHAMPLAIN_IS_PATH_LAYER (layer)); schedule_redraw (layer); }
void set_panel_background(Panel *p) { panel_clear_background(p); schedule_redraw(&p->area); if (p->hidden_pixmap) { XFreePixmap(server.display, p->hidden_pixmap); p->hidden_pixmap = 0; } }
void init_systray_panel(void *p) { Panel *panel = (Panel *)p; systray.area.parent = panel; systray.area.panel = panel; if (!systray.area.bg) systray.area.bg = &g_array_index(backgrounds, Background, 0); show(&systray.area); schedule_redraw(&systray.area); refresh_systray = TRUE; }
/** * champlain_path_layer_set_closed: * @layer: a #ChamplainPathLayer * @value: TRUE to make the path closed * * Makes the path closed. * * Since: 0.10 */ void champlain_path_layer_set_closed (ChamplainPathLayer *layer, gboolean value) { g_return_if_fail (CHAMPLAIN_IS_PATH_LAYER (layer)); layer->priv->closed_path = value; g_object_notify (G_OBJECT (layer), "closed"); schedule_redraw (layer); }
/** * champlain_path_layer_set_stroke_width: * @layer: a #ChamplainPathLayer * @value: the width of the stroke (in pixels) * * Sets the width of the stroke * * Since: 0.10 */ void champlain_path_layer_set_stroke_width (ChamplainPathLayer *layer, gdouble value) { g_return_if_fail (CHAMPLAIN_IS_PATH_LAYER (layer)); layer->priv->stroke_width = value; g_object_notify (G_OBJECT (layer), "stroke-width"); schedule_redraw (layer); }
void add_area(Area *a, Area *parent) { g_assert_null(a->parent); a->parent = parent; if (parent) { parent->children = g_list_append(parent->children, a); parent->resize_needed = TRUE; schedule_redraw(parent); panel_refresh = TRUE; } }
/* Handle term resizing in X */ static void received_sigwinch(void) { if(curr_stats.save_msg != 2) curr_stats.save_msg = 0; if(!isendwin()) { schedule_redraw(); } else { curr_stats.need_update = UT_FULL; } }
/** * champlain_path_layer_remove_node: * @layer: a #ChamplainPathLayer * @location: a #ChamplainLocation * * Removes the #ChamplainLocation object from the layer. * * Since: 0.10 */ void champlain_path_layer_remove_node (ChamplainPathLayer *layer, ChamplainLocation *location) { ChamplainPathLayerPrivate *priv = layer->priv; g_return_if_fail (CHAMPLAIN_IS_PATH_LAYER (layer)); g_return_if_fail (CHAMPLAIN_IS_LOCATION (location)); g_signal_handlers_disconnect_by_func (G_OBJECT (location), G_CALLBACK (position_notify), layer); priv->nodes = g_list_remove (priv->nodes, location); g_object_unref (location); schedule_redraw (layer); }
void remove_area(Area *a) { Area *area = (Area *)a; Area *parent = (Area *)area->parent; if (parent) { parent->children = g_list_remove(parent->children, area); parent->resize_needed = TRUE; panel_refresh = TRUE; schedule_redraw(parent); } if (mouse_over_area == a) { mouse_out(); } }
gboolean resize_clock(void *obj) { Clock *clock = (Clock *)obj; Panel *panel = (Panel *)clock->area.panel; gboolean result = FALSE; schedule_redraw(&clock->area); int time_height_ink, time_height, time_width, date_height_ink, date_height, date_width; clock_compute_text_geometry(panel, &time_height_ink, &time_height, &time_width, &date_height_ink, &date_height, &date_width); int new_size = clock_compute_desired_size(clock); if (panel_horizontal) { if (new_size > clock->area.width || new_size < (clock->area.width - 6)) { // we try to limit the number of resizes clock->area.width = new_size + 1; clock->time1_posy = (clock->area.height - time_height) / 2; if (time2_format) { clock->time1_posy -= (date_height) / 2; clock->time2_posy = clock->time1_posy + time_height; } result = TRUE; } } else { if (new_size != clock->area.height) { // we try to limit the number of resizes clock->area.height = new_size; clock->time1_posy = (clock->area.height - time_height) / 2; if (time2_format) { clock->time1_posy -= (date_height) / 2; clock->time2_posy = clock->time1_posy + time_height; } result = TRUE; } } return result; }
static void add_node (ChamplainPathLayer *layer, ChamplainLocation *location, gboolean prepend, guint position) { ChamplainPathLayerPrivate *priv = layer->priv; g_signal_connect (G_OBJECT (location), "notify::latitude", G_CALLBACK (position_notify), layer); g_object_ref_sink (location); if (prepend) priv->nodes = g_list_prepend (priv->nodes, location); else priv->nodes = g_list_insert (priv->nodes, location, position); schedule_redraw (layer); }
/** * champlain_path_layer_set_stroke_color: * @layer: a #ChamplainPathLayer * @color: (allow-none): The path's stroke color or NULL to reset to the * default color. The color parameter is copied. * * Set the path's stroke color. * * Since: 0.10 */ void champlain_path_layer_set_stroke_color (ChamplainPathLayer *layer, const ClutterColor *color) { g_return_if_fail (CHAMPLAIN_IS_PATH_LAYER (layer)); ChamplainPathLayerPrivate *priv = layer->priv; if (priv->stroke_color != NULL) clutter_color_free (priv->stroke_color); if (color == NULL) color = &DEFAULT_STROKE_COLOR; priv->stroke_color = clutter_color_copy (color); g_object_notify (G_OBJECT (layer), "stroke-color"); schedule_redraw (layer); }
void clock_default_font_changed() { if (!clock_enabled) return; if (time1_has_font && time2_has_font) return; if (!time1_has_font) { pango_font_description_free(time1_font_desc); time1_font_desc = NULL; } if (!time2_has_font) { pango_font_description_free(time2_font_desc); time2_font_desc = NULL; } clock_init_fonts(); for (int i = 0; i < num_panels; i++) { panels[i].clock.area.resize_needed = TRUE; schedule_redraw(&panels[i].clock.area); } schedule_panel_redraw(); }
void schedule_redraw(Area *a) { a->_redraw_needed = TRUE; if (a->has_mouse_over_effect) { for (int i = 0; i < MOUSE_STATE_COUNT; i++) { XFreePixmap(server.display, a->pix_by_state[i]); if (a->pix == a->pix_by_state[i]) a->pix = None; a->pix_by_state[i] = None; } if (a->pix) { XFreePixmap(server.display, a->pix); a->pix = None; } } for (GList *l = a->children; l; l = l->next) schedule_redraw((Area *)l->data); panel_refresh = TRUE; }
gboolean resize_separator(void *obj) { Separator *separator = (Separator *)obj; if (!separator->area.on_screen) return FALSE; if (panel_horizontal) { separator->area.width = separator->thickness + 2 * separator->area.paddingxlr + left_right_border_width(&separator->area); separator->length = separator->area.height - 2 * separator->area.paddingy - top_bottom_border_width(&separator->area); } else { separator->area.height = separator->thickness + 2 * separator->area.paddingxlr + top_bottom_border_width(&separator->area); separator->length = separator->area.width - 2 * separator->area.paddingy - left_right_border_width(&separator->area); } schedule_redraw(&separator->area); panel_refresh = TRUE; return TRUE; }
/** * champlain_path_layer_remove_all: * @layer: a #ChamplainPathLayer * * Removes all #ChamplainLocation objects from the layer. * * Since: 0.10 */ void champlain_path_layer_remove_all (ChamplainPathLayer *layer) { ChamplainPathLayerPrivate *priv = layer->priv; GList *elem; g_return_if_fail (CHAMPLAIN_IS_PATH_LAYER (layer)); for (elem = priv->nodes; elem != NULL; elem = elem->next) { GObject *node = G_OBJECT (elem->data); g_signal_handlers_disconnect_by_func (node, G_CALLBACK (position_notify), layer); g_object_unref (node); } g_list_free (priv->nodes); priv->nodes = NULL; schedule_redraw (layer); }
gboolean resize_freespace(void *obj) { FreeSpace *freespace = (FreeSpace *)obj; Panel *panel = (Panel *)freespace->area.panel; if (!freespace->area.on_screen) return FALSE; int old_size = panel_horizontal ? freespace->area.width : freespace->area.height; int size = freespace_get_max_size(panel); if (old_size == size) return FALSE; if (panel_horizontal) { freespace->area.width = size; } else { freespace->area.height = size; } schedule_redraw(&freespace->area); schedule_panel_redraw(); return TRUE; }
static void set_view (ChamplainLayer *layer, ChamplainView *view) { g_return_if_fail (CHAMPLAIN_IS_PATH_LAYER (layer) && (CHAMPLAIN_IS_VIEW (view) || view == NULL)); ChamplainPathLayer *path_layer = CHAMPLAIN_PATH_LAYER (layer); if (path_layer->priv->view != NULL) { g_signal_handlers_disconnect_by_func (path_layer->priv->view, G_CALLBACK (relocate_cb), path_layer); g_signal_handlers_disconnect_by_func (path_layer->priv->view, G_CALLBACK (redraw_path_cb), path_layer); g_object_unref (path_layer->priv->view); } path_layer->priv->view = view; if (view != NULL) { g_object_ref (view); g_signal_connect (view, "layer-relocated", G_CALLBACK (relocate_cb), layer); g_signal_connect (view, "notify::latitude", G_CALLBACK (redraw_path_cb), layer); g_signal_connect (view, "notify::zoom-level", G_CALLBACK (redraw_path_cb), layer); schedule_redraw (path_layer); } }
static void received_sigcont(void) { reset_prog_mode(); schedule_redraw(); }
/* Redraws the screen. */ static void cmd_ctrl_l(key_info_t key_info, keys_info_t *keys_info) { schedule_redraw(); }
gboolean add_icon(Window win) { // Avoid duplicates for (GSList *l = systray.list_icons; l; l = l->next) { TrayWindow *other = (TrayWindow *)l->data; if (other->win == win) { return FALSE; } } XTextProperty xname; char *name; if (XGetWMName(server.display, win, &xname)) { name = strdup((char *)xname.value); XFree(xname.value); } else { name = strdup(""); } if (systray_profile) fprintf(stderr, "[%f] %s:%d win = %lu (%s)\n", profiling_get_time(), __FUNCTION__, __LINE__, win, name); Panel *panel = systray.area.panel; // Get the process ID of the application that created the window int pid = 0; { Atom actual_type; int actual_format; unsigned long nitems; unsigned long bytes_after; unsigned char *prop = 0; int ret = XGetWindowProperty(server.display, win, server.atom._NET_WM_PID, 0, 1024, False, AnyPropertyType, &actual_type, &actual_format, &nitems, &bytes_after, &prop); if (ret == Success && prop) { pid = prop[1] * 256; pid += prop[0]; } } // Create the parent window that will embed the icon XWindowAttributes attr; if (systray_profile) fprintf(stderr, "XGetWindowAttributes(server.display, win = %ld, &attr)\n", win); if (XGetWindowAttributes(server.display, win, &attr) == False) { free(name); return FALSE; } unsigned long mask = 0; XSetWindowAttributes set_attr; Visual *visual = server.visual; fprintf(stderr, GREEN "add_icon: %lu (%s), pid %d, visual %p, colormap %lu, depth %d, width %d, height %d" RESET "\n", win, name, pid, attr.visual, attr.colormap, attr.depth, attr.width, attr.height); if (server.disable_transparency) { set_attr.background_pixmap = ParentRelative; mask = CWBackPixmap; if (systray_composited || attr.depth != server.depth) { visual = attr.visual; set_attr.colormap = attr.colormap; mask |= CWColormap; } } else { if (systray_composited || attr.depth != server.depth) { visual = attr.visual; set_attr.background_pixel = 0; set_attr.border_pixel = 0; set_attr.colormap = attr.colormap; mask = CWColormap | CWBackPixel | CWBorderPixel; } else { set_attr.background_pixmap = ParentRelative; mask = CWBackPixmap; } } if (systray_profile) fprintf(stderr, "XCreateWindow(...)\n"); Window parent = XCreateWindow(server.display, panel->main_win, 0, 0, systray.icon_size, systray.icon_size, 0, attr.depth, InputOutput, visual, mask, &set_attr); // Add the icon to the list TrayWindow *traywin = g_new0(TrayWindow, 1); traywin->parent = parent; traywin->win = win; traywin->depth = attr.depth; // Reparenting is done at the first paint event when the window is positioned correctly over its empty background, // to prevent graphical corruptions in icons with fake transparency traywin->pid = pid; traywin->name = name; traywin->chrono = chrono; chrono++; if (!systray.area.on_screen) show(&systray.area); if (systray.sort == SYSTRAY_SORT_RIGHT2LEFT) systray.list_icons = g_slist_prepend(systray.list_icons, traywin); else systray.list_icons = g_slist_append(systray.list_icons, traywin); systray.list_icons = g_slist_sort(systray.list_icons, compare_traywindows); // print_icons(); if (!panel->is_hidden) { if (systray_profile) fprintf(stderr, "XMapRaised(server.display, traywin->parent)\n"); XMapRaised(server.display, traywin->parent); } if (systray_profile) fprintf(stderr, "[%f] %s:%d\n", profiling_get_time(), __FUNCTION__, __LINE__); // Resize and redraw the systray if (systray_profile) fprintf(stderr, BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n", profiling_get_time(), __FUNCTION__, __LINE__); systray.area.resize_needed = TRUE; panel->area.resize_needed = TRUE; schedule_redraw(&systray.area); refresh_systray = TRUE; return TRUE; }
gboolean resize_execp(void *obj) { Execp *execp = (Execp *)obj; Panel *panel = (Panel *)execp->area.panel; int horiz_padding = (panel_horizontal ? execp->area.paddingxlr : execp->area.paddingy); int vert_padding = (panel_horizontal ? execp->area.paddingy : execp->area.paddingxlr); int interior_padding = execp->area.paddingx; int icon_w, icon_h; if (reload_icon(execp)) { if (execp->backend->icon) { imlib_context_set_image(execp->backend->icon); icon_w = imlib_image_get_width(); icon_h = imlib_image_get_height(); } else { icon_w = icon_h = 0; } } else { icon_w = icon_h = 0; } int text_next_line = !panel_horizontal && icon_w > execp->area.width / 2; int txt_height_ink, txt_height, txt_width; if (panel_horizontal) { get_text_size2(execp->backend->font_desc, &txt_height_ink, &txt_height, &txt_width, panel->area.height, panel->area.width, execp->backend->text, strlen(execp->backend->text), PANGO_WRAP_WORD_CHAR, PANGO_ELLIPSIZE_NONE, execp->backend->has_markup); } else { get_text_size2(execp->backend->font_desc, &txt_height_ink, &txt_height, &txt_width, panel->area.height, !text_next_line ? execp->area.width - icon_w - (icon_w ? interior_padding : 0) - 2 * horiz_padding - left_right_border_width(&execp->area) : execp->area.width - 2 * horiz_padding - left_right_border_width(&execp->area), execp->backend->text, strlen(execp->backend->text), PANGO_WRAP_WORD_CHAR, PANGO_ELLIPSIZE_NONE, execp->backend->has_markup); } gboolean result = FALSE; if (panel_horizontal) { int new_size = txt_width; if (icon_w) new_size += interior_padding + icon_w; new_size += 2 * horiz_padding + left_right_border_width(&execp->area); if (new_size > execp->area.width || new_size < (execp->area.width - 6)) { // we try to limit the number of resize execp->area.width = new_size + 1; result = TRUE; } } else { int new_size; if (!text_next_line) { new_size = txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area); new_size = MAX(new_size, icon_h + 2 * vert_padding + top_bottom_border_width(&execp->area)); } else { new_size = icon_h + interior_padding + txt_height + 2 * vert_padding + top_bottom_border_width(&execp->area); } if (new_size != execp->area.height) { execp->area.height = new_size; result = TRUE; } } execp->frontend->textw = txt_width; execp->frontend->texth = txt_height; if (execp->backend->centered) { if (icon_w) { if (!text_next_line) { execp->frontend->icony = (execp->area.height - icon_h) / 2; execp->frontend->iconx = (execp->area.width - txt_width - interior_padding - icon_w) / 2; execp->frontend->texty = (execp->area.height - txt_height) / 2; execp->frontend->textx = execp->frontend->iconx + icon_w + interior_padding; } else { execp->frontend->icony = (execp->area.height - icon_h - interior_padding - txt_height) / 2; execp->frontend->iconx = (execp->area.width - icon_w) / 2; execp->frontend->texty = execp->frontend->icony + icon_h + interior_padding; execp->frontend->textx = (execp->area.width - txt_width) / 2; } } else { execp->frontend->texty = (execp->area.height - txt_height) / 2; execp->frontend->textx = (execp->area.width - txt_width) / 2; } } else { if (icon_w) { if (!text_next_line) { execp->frontend->icony = (execp->area.height - icon_h) / 2; execp->frontend->iconx = left_border_width(&execp->area) + horiz_padding; execp->frontend->texty = (execp->area.height - txt_height) / 2; execp->frontend->textx = execp->frontend->iconx + icon_w + interior_padding; } else { execp->frontend->icony = (execp->area.height - icon_h - interior_padding - txt_height) / 2; execp->frontend->iconx = left_border_width(&execp->area) + horiz_padding; execp->frontend->texty = execp->frontend->icony + icon_h + interior_padding; execp->frontend->textx = execp->frontend->iconx; } } else { execp->frontend->texty = (execp->area.height - txt_height) / 2; execp->frontend->textx = left_border_width(&execp->area) + horiz_padding; } } schedule_redraw(&execp->area); return result; }