Back to index

unity  6.0.0
Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
unity::UScreen Class Reference

#include <UScreen.h>

Inheritance diagram for unity::UScreen:
Inheritance graph
[legend]
Collaboration diagram for unity::UScreen:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 UScreen ()
 ~UScreen ()
int GetPrimaryMonitor ()
int GetMonitorWithMouse ()
int GetMonitorAtPosition (int x, int y)
nux::Geometry & GetMonitorGeometry (int monitor)
std::vector< nux::Geometry > & GetMonitors ()

Static Public Member Functions

static UScreenGetDefault ()

Public Attributes

sigc::signal< void, int,
std::vector< nux::Geometry > & > 
changed
sigc::signal< void > resuming

Private Member Functions

void Changed (GdkScreen *screen)
void Refresh ()

Private Attributes

std::vector< nux::Geometry > monitors_
glib::Object< GdkScreen > screen_
glib::DBusProxy proxy_
glib::Signal< void, GdkScreen * > size_changed_signal_
glib::Signal< void, GdkScreen * > monitors_changed_signal_
glib::Source::UniquePtr refresh_idle_
int primary_

Detailed Description

Definition at line 35 of file UScreen.h.


Constructor & Destructor Documentation

Definition at line 31 of file UScreen.cpp.

  : screen_(gdk_screen_get_default(), glib::AddRef())
  , proxy_("org.freedesktop.UPower",
           "/org/freedesktop/UPower",
           "org.freedesktop.UPower",
           G_BUS_TYPE_SYSTEM)
  , primary_(0)
{
  size_changed_signal_.Connect(screen_, "size-changed", sigc::mem_fun(this, &UScreen::Changed));
  monitors_changed_signal_.Connect(screen_, "monitors-changed", sigc::mem_fun(this, &UScreen::Changed));
  proxy_.Connect("Resuming", [&] (GVariant* data) { resuming.emit(); });

  Refresh();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 46 of file UScreen.cpp.

{
  if (default_screen_ == this)
    default_screen_ = nullptr;
}

Member Function Documentation

void unity::UScreen::Changed ( GdkScreen *  screen) [private]

Definition at line 95 of file UScreen.cpp.

{
  if (refresh_idle_)
    return;

  refresh_idle_.reset(new glib::Idle([&] () {
    Refresh();
    refresh_idle_.reset();

    return false;
  }));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 52 of file UScreen.cpp.

{
  if (G_UNLIKELY(!default_screen_))
    default_screen_ = new UScreen();

  return default_screen_;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int unity::UScreen::GetMonitorAtPosition ( int  x,
int  y 
)

Definition at line 80 of file UScreen.cpp.

{
  return gdk_screen_get_monitor_at_point(screen_, x, y);
}

Here is the caller graph for this function:

nux::Geometry & unity::UScreen::GetMonitorGeometry ( int  monitor)

Definition at line 85 of file UScreen.cpp.

{
  return monitors_[monitor];
}

Here is the caller graph for this function:

std::vector< nux::Geometry > & unity::UScreen::GetMonitors ( )

Definition at line 90 of file UScreen.cpp.

{
  return monitors_;
}

Here is the caller graph for this function:

Definition at line 60 of file UScreen.cpp.

{
  GdkDevice* device;
  GdkDisplay *display;
  int x;
  int y;

  display = gdk_display_get_default();
  device = gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(display));

  gdk_device_get_position(device, nullptr, &x, &y);

  return GetMonitorAtPosition(x, y);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 75 of file UScreen.cpp.

{
  return primary_;
}

Here is the caller graph for this function:

void unity::UScreen::Refresh ( ) [private]

Definition at line 108 of file UScreen.cpp.

{
  LOG_DEBUG(logger) << "Screen geometry changed";

  nux::Geometry last_geo;
  monitors_.clear();
  primary_ = gdk_screen_get_primary_monitor(screen_);
  int monitors = gdk_screen_get_n_monitors(screen_);

  for (int i = 0; i < monitors; ++i)
  {
    GdkRectangle rect = { 0 };
    gdk_screen_get_monitor_geometry(screen_, i, &rect);
    nux::Geometry geo(rect.x, rect.y, rect.width, rect.height);

    // Check for mirrored displays
    if (geo == last_geo)
      continue;

    last_geo = geo;
    monitors_.push_back(geo);

    LOG_DEBUG(logger) << "Monitor " << i << " has geometry " << geo.x << "x"
                      << geo.y << "x" << geo.width << "x" << geo.height;
  }

  changed.emit(primary_, monitors_);
}

Here is the caller graph for this function:


Member Data Documentation

sigc::signal<void, int, std::vector<nux::Geometry>&> unity::UScreen::changed

Definition at line 51 of file UScreen.h.

std::vector<nux::Geometry> unity::UScreen::monitors_ [private]

Definition at line 59 of file UScreen.h.

Definition at line 63 of file UScreen.h.

int unity::UScreen::primary_ [private]

Definition at line 65 of file UScreen.h.

Definition at line 61 of file UScreen.h.

Definition at line 64 of file UScreen.h.

sigc::signal<void> unity::UScreen::resuming

Definition at line 52 of file UScreen.h.

glib::Object<GdkScreen> unity::UScreen::screen_ [private]

Definition at line 60 of file UScreen.h.

Definition at line 62 of file UScreen.h.


The documentation for this class was generated from the following files: