marco 1.29.1
Window manager
Loading...
Searching...
No Matches
window-props.c File Reference
View source

MetaWindow property handling. More...

#include <config.h>
#include <glib/gi18n-lib.h>
#include "window-props.h"
#include "errors.h"
#include "xprops.h"
#include "frame-private.h"
#include "group.h"
#include <X11/Xatom.h>
#include <X11/extensions/XRes.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <pwd.h>
Include dependency graph for window-props.c:

Data Structures

struct  MetaWindowPropHooks
 

Macros

#define _GNU_SOURCE
 
#define _XOPEN_SOURCE   /* for gethostname() */
 
#define HOST_NAME_MAX   255
 
#define MAX_TITLE_LENGTH   512
 
#define FLAG_TOGGLED_ON(old, new, flag)
 
#define FLAG_TOGGLED_OFF(old, new, flag)
 
#define FLAG_CHANGED(old, new, flag)    (FLAG_TOGGLED_ON(old,new,flag) || FLAG_TOGGLED_OFF(old,new,flag))
 

Typedefs

typedef void(* ReloadValueFunc) (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
typedef struct MetaWindowPropHooks MetaWindowPropHooks
 

Functions

static MetaWindowPropHooks * find_hooks (MetaDisplay *display, Atom property)
 Finds the hooks for a particular property.
 
void meta_window_reload_property (MetaWindow *window, Atom property, gboolean initial)
 Requests the current values of a single property for a given window from the server, and deals with it appropriately.
 
void meta_window_reload_properties (MetaWindow *window, const Atom *properties, int n_properties, gboolean initial)
 Requests the current values of a set of properties for a given window from the server, and deals with them appropriately.
 
void meta_window_reload_property_from_xwindow (MetaWindow *window, Window xwindow, Atom property, gboolean initial)
 Requests the current values of a single property for a given window from the server, and deals with it appropriately.
 
void meta_window_reload_properties_from_xwindow (MetaWindow *window, Window xwindow, const Atom *properties, int n_properties, gboolean initial)
 Requests the current values of a set of properties for a given window from the server, and deals with them appropriately.
 
static void reload_wm_client_machine (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void complain_about_broken_client (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_net_wm_window_type (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_icon (MetaWindow *window, Atom atom)
 
static void reload_net_wm_icon (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_kwm_win_icon (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static gboolean gtk_border_equal (GtkBorder *a, GtkBorder *b)
 
static void meta_window_set_custom_frame_extents (MetaWindow *window, GtkBorder *extents)
 
static void reload_gtk_frame_extents (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_struts (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_wm_window_role (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static pid_t get_local_pid (MetaWindow *window)
 
static void reload_net_wm_pid (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_net_wm_user_time (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_net_wm_user_time_window (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static gboolean owner_of_process (pid_t process, uid_t *result)
 Finds who owns a particular process, if we can.
 
static gboolean set_title_text (MetaWindow *window, gboolean previous_was_modified, const char *title, Atom atom, char **target)
 Called by set_window_title and set_icon_title to set the value of *target to title.
 
static void set_window_title (MetaWindow *window, const char *title)
 
static void reload_net_wm_name (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_wm_name (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void set_icon_title (MetaWindow *window, const char *title)
 
static void reload_net_wm_icon_name (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_wm_icon_name (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_net_wm_state (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_mwm_hints (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_wm_class (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_net_wm_desktop (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_net_startup_id (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_update_counter (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void spew_size_hints_differences (const XSizeHints *old, const XSizeHints *new)
 
void meta_set_normal_hints (MetaWindow *window, XSizeHints *hints)
 Sets the size hints for a window.
 
static void reload_normal_hints (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_wm_protocols (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_wm_hints (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_transient_for (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_gtk_theme_variant (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_gtk_application_id (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
static void reload_bamf_desktop_file (MetaWindow *window, MetaPropValue *value, gboolean initial)
 
void meta_display_init_window_prop_hooks (MetaDisplay *display)
 Initialises the property hooks system.
 
void meta_display_free_window_prop_hooks (MetaDisplay *display)
 Frees the hooks used for the reload_propert* functions for a particular display.
 

Detailed Description

MetaWindow property handling.

A system which can inspect sets of properties of given windows and take appropriate action given their values.

Note that all the meta_window_reload_propert* functions require a round trip to the server.

The guts of this system are in meta_display_init_window_prop_hooks(). Reading this function will give you insight into how this all fits together.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

◆ _XOPEN_SOURCE

#define _XOPEN_SOURCE   /* for gethostname() */

◆ FLAG_CHANGED

#define FLAG_CHANGED (   old,
  new,
  flag 
)     (FLAG_TOGGLED_ON(old,new,flag) || FLAG_TOGGLED_OFF(old,new,flag))

◆ FLAG_TOGGLED_OFF

#define FLAG_TOGGLED_OFF (   old,
  new,
  flag 
)
Value:
(((old)->flags & (flag)) != 0 && \
((new)->flags & (flag)) == 0)

◆ FLAG_TOGGLED_ON

#define FLAG_TOGGLED_ON (   old,
  new,
  flag 
)
Value:
(((old)->flags & (flag)) == 0 && \
((new)->flags & (flag)) != 0)

◆ HOST_NAME_MAX

#define HOST_NAME_MAX   255

◆ MAX_TITLE_LENGTH

#define MAX_TITLE_LENGTH   512

Typedef Documentation

◆ MetaWindowPropHooks

◆ ReloadValueFunc

typedef void(* ReloadValueFunc) (MetaWindow *window, MetaPropValue *value, gboolean initial)

Function Documentation

◆ complain_about_broken_client()

static void complain_about_broken_client ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

References _MetaWindow::desc, and meta_warning().

Referenced by meta_display_init_window_prop_hooks().

Here is the call graph for this function:

◆ find_hooks()

static MetaWindowPropHooks * find_hooks ( MetaDisplay *  display,
Atom  property 
)
static

Finds the hooks for a particular property.

References _MetaDisplay::prop_hooks.

Referenced by meta_window_reload_properties_from_xwindow().

◆ get_local_pid()

static pid_t get_local_pid ( MetaWindow *  window)
static

◆ gtk_border_equal()

static gboolean gtk_border_equal ( GtkBorder *  a,
GtkBorder *  b 
)
static

◆ meta_display_free_window_prop_hooks()

void meta_display_free_window_prop_hooks ( MetaDisplay *  display)

Frees the hooks used for the reload_propert* functions for a particular display.

Parameters
displayThe display.

References NULL, _MetaDisplay::prop_hooks, and _MetaDisplay::prop_hooks_table.

Referenced by meta_display_close().

◆ meta_display_init_window_prop_hooks()

void meta_display_init_window_prop_hooks ( MetaDisplay *  display)

Initialises the property hooks system.

Initialises the hooks used for the reload_propert* functions on a particular display, and stores a pointer to them in the display.

Each row in the table named "hooks" represents an action to take when a property is found on a newly-created window, or when a property changes its value.

The first column shows which atom the row concerns. The second gives the type of the property data. The property will be queried for its new value, unless the type is given as META_PROP_VALUE_INVALID, in which case nothing will be queried. The third column gives the name of a callback which gets called with the new value. (If the new value was not retrieved because the second column was META_PROP_VALUE_INVALID, the callback still gets called anyway.) This value may be NULL, in which case no callback will be called.

References complain_about_broken_client(), META_PROP_VALUE_ATOM_LIST, META_PROP_VALUE_CARDINAL, META_PROP_VALUE_CARDINAL_LIST, META_PROP_VALUE_CLASS_HINT, META_PROP_VALUE_INVALID, META_PROP_VALUE_MOTIF_HINTS, META_PROP_VALUE_SIZE_HINTS, META_PROP_VALUE_STRING, META_PROP_VALUE_SYNC_COUNTER, META_PROP_VALUE_TEXT_PROPERTY, META_PROP_VALUE_UTF8, META_PROP_VALUE_WINDOW, META_PROP_VALUE_WM_HINTS, NULL, _MetaDisplay::prop_hooks, _MetaDisplay::prop_hooks_table, MetaWindowPropHooks::property, reload_bamf_desktop_file(), reload_gtk_application_id(), reload_gtk_frame_extents(), reload_gtk_theme_variant(), reload_kwm_win_icon(), reload_mwm_hints(), reload_net_startup_id(), reload_net_wm_desktop(), reload_net_wm_icon(), reload_net_wm_icon_name(), reload_net_wm_name(), reload_net_wm_pid(), reload_net_wm_state(), reload_net_wm_user_time(), reload_net_wm_user_time_window(), reload_net_wm_window_type(), reload_normal_hints(), reload_struts(), reload_transient_for(), reload_update_counter(), reload_wm_class(), reload_wm_client_machine(), reload_wm_hints(), reload_wm_icon_name(), reload_wm_name(), reload_wm_protocols(), and reload_wm_window_role().

Referenced by meta_display_open().

Here is the call graph for this function:

◆ meta_set_normal_hints()

void meta_set_normal_hints ( MetaWindow *  window,
XSizeHints *  hints 
)

Sets the size hints for a window.

This happens when a WM_NORMAL_HINTS property is set on a window, but it is public because the size hints are set to defaults when a window is created. See http://tronche.com/gui/x/icccm/sec-4.html#WM_NORMAL_HINTS for the X details.

Parameters
windowThe window to set the size hints on.
hintsEither some X size hints, or NULL for default.

References _MetaWindow::desc, META_DEBUG_GEOMETRY, and _MetaWindow::size_hints.

Referenced by meta_window_new_with_attrs(), and reload_normal_hints().

◆ meta_window_reload_properties()

void meta_window_reload_properties ( MetaWindow *  window,
const Atom *  properties,
int  n_properties,
gboolean  initial 
)

Requests the current values of a set of properties for a given window from the server, and deals with them appropriately.

Does not return them to the caller (they've been dealt with!)

Parameters
windowThe window.
propertiesA pointer to a list of X atoms, "n_properties" long.
n_propertiesThe length of the properties list.

References meta_window_reload_properties_from_xwindow(), and _MetaWindow::xwindow.

Referenced by meta_window_new_with_attrs(), and meta_window_reload_property().

Here is the call graph for this function:

◆ meta_window_reload_properties_from_xwindow()

void meta_window_reload_properties_from_xwindow ( MetaWindow *  window,
Window  xwindow,
const Atom *  properties,
int  n_properties,
gboolean  initial 
)

Requests the current values of a set of properties for a given window from the server, and deals with them appropriately.

Does not return them to the caller (they've been dealt with!)

Parameters
windowA window on the same display as the one we're investigating (only used to find the display)
xwindowThe X handle for the window.
propertiesA pointer to a list of X atoms, "n_properties" long.
n_propertiesThe length of the properties list.

References MetaPropValue::atom, _MetaWindow::display, find_hooks(), meta_prop_free_values(), meta_prop_get_values(), META_PROP_VALUE_INVALID, NULL, MetaWindowPropHooks::reload_func, MetaWindowPropHooks::type, and MetaPropValue::type.

Referenced by meta_window_reload_properties(), and meta_window_reload_property_from_xwindow().

Here is the call graph for this function:

◆ meta_window_reload_property()

void meta_window_reload_property ( MetaWindow *  window,
Atom  property,
gboolean  initial 
)

Requests the current values of a single property for a given window from the server, and deals with it appropriately.

Does not return it to the caller (it's been dealt with!)

Parameters
windowThe window.
propertyA single X atom.

References meta_window_reload_properties().

Referenced by reload_net_wm_icon_name(), and reload_net_wm_name().

Here is the call graph for this function:

◆ meta_window_reload_property_from_xwindow()

void meta_window_reload_property_from_xwindow ( MetaWindow *  window,
Window  xwindow,
Atom  property,
gboolean  initial 
)

Requests the current values of a single property for a given window from the server, and deals with it appropriately.

Does not return it to the caller (it's been dealt with!)

Parameters
windowA window on the same display as the one we're investigating (only used to find the display)
xwindowThe X handle for the window.
propertyA single X atom.

References meta_window_reload_properties_from_xwindow().

Referenced by process_property_notify(), and reload_net_wm_user_time_window().

Here is the call graph for this function:

◆ meta_window_set_custom_frame_extents()

static void meta_window_set_custom_frame_extents ( MetaWindow *  window,
GtkBorder *  extents 
)
static

References _MetaWindow::custom_frame_extents, FALSE, gtk_border_equal(), _MetaWindow::has_custom_frame_extents, META_QUEUE_MOVE_RESIZE, meta_window_queue(), and TRUE.

Referenced by reload_gtk_frame_extents().

Here is the call graph for this function:

◆ owner_of_process()

static gboolean owner_of_process ( pid_t  process,
uid_t *  result 
)
static

Finds who owns a particular process, if we can.

Parameters
processThe process's ID.
Returns
Set to the ID of the user, if we returned true.
True if we could tell.

References FALSE, and TRUE.

Referenced by set_title_text().

◆ reload_bamf_desktop_file()

static void reload_bamf_desktop_file ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

◆ reload_gtk_application_id()

static void reload_gtk_application_id ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

◆ reload_gtk_frame_extents()

static void reload_gtk_frame_extents ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

References MetaPropValue::cardinal_list, MetaPropValue::cardinals, _MetaWindow::desc, META_PROP_VALUE_INVALID, meta_window_set_custom_frame_extents(), MetaPropValue::n_cardinals, NULL, MetaPropValue::type, and MetaPropValue::v.

Referenced by meta_display_init_window_prop_hooks().

Here is the call graph for this function:

◆ reload_gtk_theme_variant()

static void reload_gtk_theme_variant ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

References _MetaWindow::desc, _MetaWindow::frame, _MetaWindow::gtk_theme_variant, META_PROP_VALUE_INVALID, meta_ui_update_frame_style(), NULL, _MetaWindow::screen, MetaPropValue::str, MetaPropValue::type, _MetaScreen::ui, MetaPropValue::v, and _MetaFrame::xwindow.

Referenced by meta_display_init_window_prop_hooks().

Here is the call graph for this function:

◆ reload_icon()

static void reload_icon ( MetaWindow *  window,
Atom  atom 
)
static

References _MetaWindow::display, _MetaWindow::icon_cache, meta_icon_cache_property_changed(), META_QUEUE_UPDATE_ICON, and meta_window_queue().

Referenced by reload_kwm_win_icon(), and reload_net_wm_icon().

Here is the call graph for this function:

◆ reload_kwm_win_icon()

static void reload_kwm_win_icon ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

References _MetaWindow::display, and reload_icon().

Referenced by meta_display_init_window_prop_hooks().

Here is the call graph for this function:

◆ reload_mwm_hints()

◆ reload_net_startup_id()

◆ reload_net_wm_desktop()

◆ reload_net_wm_icon()

static void reload_net_wm_icon ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

References _MetaWindow::display, and reload_icon().

Referenced by meta_display_init_window_prop_hooks().

Here is the call graph for this function:

◆ reload_net_wm_icon_name()

static void reload_net_wm_icon_name ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

References _MetaWindow::desc, FALSE, META_PROP_VALUE_INVALID, meta_window_reload_property(), NULL, set_icon_title(), MetaPropValue::str, _MetaWindow::title, TRUE, MetaPropValue::type, _MetaWindow::using_net_wm_icon_name, and MetaPropValue::v.

Referenced by meta_display_init_window_prop_hooks().

Here is the call graph for this function:

◆ reload_net_wm_name()

static void reload_net_wm_name ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

References _MetaWindow::desc, FALSE, META_PROP_VALUE_INVALID, meta_window_reload_property(), NULL, set_window_title(), MetaPropValue::str, _MetaWindow::title, TRUE, MetaPropValue::type, _MetaWindow::using_net_wm_name, and MetaPropValue::v.

Referenced by meta_display_init_window_prop_hooks().

Here is the call graph for this function:

◆ reload_net_wm_pid()

static void reload_net_wm_pid ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

References _, MetaPropValue::cardinal, get_local_pid(), META_PROP_VALUE_INVALID, meta_warning(), _MetaWindow::net_wm_pid, MetaPropValue::type, and MetaPropValue::v.

Referenced by meta_display_init_window_prop_hooks().

Here is the call graph for this function:

◆ reload_net_wm_state()

◆ reload_net_wm_user_time()

static void reload_net_wm_user_time ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

References MetaPropValue::cardinal, META_PROP_VALUE_INVALID, meta_window_set_user_time(), MetaPropValue::type, and MetaPropValue::v.

Referenced by meta_display_init_window_prop_hooks().

Here is the call graph for this function:

◆ reload_net_wm_user_time_window()

static void reload_net_wm_user_time_window ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

◆ reload_net_wm_window_type()

static void reload_net_wm_window_type ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

References meta_window_update_net_wm_type().

Referenced by meta_display_init_window_prop_hooks().

Here is the call graph for this function:

◆ reload_normal_hints()

static void reload_normal_hints ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

◆ reload_struts()

static void reload_struts ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

References meta_window_update_struts().

Referenced by meta_display_init_window_prop_hooks().

Here is the call graph for this function:

◆ reload_transient_for()

◆ reload_update_counter()

static void reload_update_counter ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

◆ reload_wm_class()

◆ reload_wm_client_machine()

static void reload_wm_client_machine ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

◆ reload_wm_hints()

◆ reload_wm_icon_name()

static void reload_wm_icon_name ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

References _MetaWindow::desc, META_PROP_VALUE_INVALID, NULL, set_icon_title(), MetaPropValue::str, _MetaWindow::title, MetaPropValue::type, _MetaWindow::using_net_wm_icon_name, and MetaPropValue::v.

Referenced by meta_display_init_window_prop_hooks().

Here is the call graph for this function:

◆ reload_wm_name()

static void reload_wm_name ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

References _MetaWindow::desc, META_PROP_VALUE_INVALID, NULL, set_window_title(), MetaPropValue::str, _MetaWindow::title, MetaPropValue::type, _MetaWindow::using_net_wm_name, and MetaPropValue::v.

Referenced by meta_display_init_window_prop_hooks().

Here is the call graph for this function:

◆ reload_wm_protocols()

◆ reload_wm_window_role()

static void reload_wm_window_role ( MetaWindow *  window,
MetaPropValue *  value,
gboolean  initial 
)
static

References meta_window_update_role().

Referenced by meta_display_init_window_prop_hooks().

Here is the call graph for this function:

◆ set_icon_title()

static void set_icon_title ( MetaWindow *  window,
const char *  title 
)
static

References _MetaWindow::display, FALSE, _MetaWindow::icon_name, set_title_text(), and _MetaWindow::using_net_wm_visible_icon_name.

Referenced by reload_net_wm_icon_name(), and reload_wm_icon_name().

Here is the call graph for this function:

◆ set_title_text()

static gboolean set_title_text ( MetaWindow *  window,
gboolean  previous_was_modified,
const char *  title,
Atom  atom,
char **  target 
)
static

Called by set_window_title and set_icon_title to set the value of *target to title.

It required and atom is set, it will update the appropriate property.

Returns TRUE if a new title was set.

References _, _MetaWindow::display, FALSE, HOST_NAME_MAX, MAX_TITLE_LENGTH, meta_error_trap_pop(), meta_error_trap_push(), meta_g_utf8_strndup(), meta_prop_set_utf8_string_hint(), _MetaWindow::net_wm_pid, NULL, owner_of_process(), TRUE, _MetaWindow::wm_client_machine, _MetaDisplay::xdisplay, and _MetaWindow::xwindow.

Referenced by set_icon_title(), and set_window_title().

Here is the call graph for this function:

◆ set_window_title()

static void set_window_title ( MetaWindow *  window,
const char *  title 
)
static

References _MetaWindow::desc, _MetaWindow::display, FALSE, _MetaWindow::frame, meta_ui_set_frame_title(), _MetaWindow::screen, set_title_text(), _MetaWindow::title, _MetaScreen::ui, _MetaWindow::using_net_wm_visible_name, _MetaFrame::xwindow, and _MetaWindow::xwindow.

Referenced by reload_net_wm_name(), and reload_wm_name().

Here is the call graph for this function:

◆ spew_size_hints_differences()

static void spew_size_hints_differences ( const XSizeHints *  old,
const XSizeHints *  new 
)
static